diff mbox

[rdma-next,1/2] IB/core: Namespace is a mandatory input parameter for address resolution

Message ID 20170523074845.10845-1-leon@kernel.org (mailing list archive)
State Accepted
Headers show

Commit Message

Leon Romanovsky May 23, 2017, 7:48 a.m. UTC
From: Moni Shoua <monis@mellanox.com>

In function addr_resolve() the namespace is a required input parameter
and not an output. It is passed later for searching the routing table
and device addresses. Also, it shouldn't be copied back to the caller.

Fixes: 565edd1d5555 ('IB/addr: Pass network namespace as a parameter')
Cc: <stable@vger.kernel.org> # v4.3+
Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
---
 drivers/infiniband/core/addr.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Doug Ledford July 22, 2017, 5:05 p.m. UTC | #1
On 5/23/2017 3:48 AM, Leon Romanovsky wrote:
> From: Moni Shoua <monis@mellanox.com>
> 
> In function addr_resolve() the namespace is a required input parameter
> and not an output. It is passed later for searching the routing table
> and device addresses. Also, it shouldn't be copied back to the caller.
> 
> Fixes: 565edd1d5555 ('IB/addr: Pass network namespace as a parameter')
> Cc: <stable@vger.kernel.org> # v4.3+
> Signed-off-by: Moni Shoua <monis@mellanox.com>
> Signed-off-by: Leon Romanovsky <leon@kernel.org>

This series has been accepted into 4.13-rc, thanks.
diff mbox

Patch

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 02971e239a18..d2afcb3dd81a 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -518,6 +518,11 @@  static int addr_resolve(struct sockaddr *src_in,
 	struct dst_entry *dst;
 	int ret;
 
+	if (!addr->net) {
+		pr_warn_ratelimited("%s: missing namespace\n", __func__);
+		return -EINVAL;
+	}
+
 	if (src_in->sa_family == AF_INET) {
 		struct rtable *rt = NULL;
 		const struct sockaddr_in *dst_in4 =
@@ -555,7 +560,6 @@  static int addr_resolve(struct sockaddr *src_in,
 	}
 
 	addr->bound_dev_if = ndev->ifindex;
-	addr->net = dev_net(ndev);
 	dev_put(ndev);
 
 	return ret;