Commit 1ab35276 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by David S. Miller

[NETNS]: Add namespace parameter to ip_dev_find.

in_dev_find() need a namespace to pass it to fib_get_table(), so add
an argument.
Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 010278ec
...@@ -110,7 +110,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr) ...@@ -110,7 +110,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
__be32 ip = ((struct sockaddr_in *) addr)->sin_addr.s_addr; __be32 ip = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
int ret; int ret;
dev = ip_dev_find(ip); dev = ip_dev_find(&init_net, ip);
if (!dev) if (!dev)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
...@@ -261,7 +261,7 @@ static int addr_resolve_local(struct sockaddr_in *src_in, ...@@ -261,7 +261,7 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
__be32 dst_ip = dst_in->sin_addr.s_addr; __be32 dst_ip = dst_in->sin_addr.s_addr;
int ret; int ret;
dev = ip_dev_find(dst_ip); dev = ip_dev_find(&init_net, dst_ip);
if (!dev) if (!dev)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
......
...@@ -1289,7 +1289,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id, ...@@ -1289,7 +1289,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
atomic_inc(&conn_id->dev_remove); atomic_inc(&conn_id->dev_remove);
conn_id->state = CMA_CONNECT; conn_id->state = CMA_CONNECT;
dev = ip_dev_find(iw_event->local_addr.sin_addr.s_addr); dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr);
if (!dev) { if (!dev) {
ret = -EADDRNOTAVAIL; ret = -EADDRNOTAVAIL;
cma_enable_remove(conn_id); cma_enable_remove(conn_id);
......
...@@ -129,7 +129,7 @@ struct in_ifaddr ...@@ -129,7 +129,7 @@ struct in_ifaddr
extern int register_inetaddr_notifier(struct notifier_block *nb); extern int register_inetaddr_notifier(struct notifier_block *nb);
extern int unregister_inetaddr_notifier(struct notifier_block *nb); extern int unregister_inetaddr_notifier(struct notifier_block *nb);
extern struct net_device *ip_dev_find(__be32 addr); extern struct net_device *ip_dev_find(struct net *net, __be32 addr);
extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b); extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
extern int devinet_ioctl(unsigned int cmd, void __user *); extern int devinet_ioctl(unsigned int cmd, void __user *);
extern void devinet_init(void); extern void devinet_init(void);
......
...@@ -153,7 +153,7 @@ static void fib_flush(struct net *net) ...@@ -153,7 +153,7 @@ static void fib_flush(struct net *net)
* Find the first device with a given source address. * Find the first device with a given source address.
*/ */
struct net_device * ip_dev_find(__be32 addr) struct net_device * ip_dev_find(struct net *net, __be32 addr)
{ {
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } }; struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } } };
struct fib_result res; struct fib_result res;
...@@ -164,7 +164,7 @@ struct net_device * ip_dev_find(__be32 addr) ...@@ -164,7 +164,7 @@ struct net_device * ip_dev_find(__be32 addr)
res.r = NULL; res.r = NULL;
#endif #endif
local_table = fib_get_table(&init_net, RT_TABLE_LOCAL); local_table = fib_get_table(net, RT_TABLE_LOCAL);
if (!local_table || local_table->tb_lookup(local_table, &fl, &res)) if (!local_table || local_table->tb_lookup(local_table, &fl, &res))
return NULL; return NULL;
if (res.type != RTN_LOCAL) if (res.type != RTN_LOCAL)
......
...@@ -1395,7 +1395,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) ...@@ -1395,7 +1395,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr)
return idev; return idev;
} }
if (imr->imr_address.s_addr) { if (imr->imr_address.s_addr) {
dev = ip_dev_find(imr->imr_address.s_addr); dev = ip_dev_find(&init_net, imr->imr_address.s_addr);
if (!dev) if (!dev)
return NULL; return NULL;
dev_put(dev); dev_put(dev);
......
...@@ -594,7 +594,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, ...@@ -594,7 +594,7 @@ static int do_ip_setsockopt(struct sock *sk, int level,
err = 0; err = 0;
break; break;
} }
dev = ip_dev_find(mreq.imr_address.s_addr); dev = ip_dev_find(&init_net, mreq.imr_address.s_addr);
if (dev) { if (dev) {
mreq.imr_ifindex = dev->ifindex; mreq.imr_ifindex = dev->ifindex;
dev_put(dev); dev_put(dev);
......
...@@ -423,7 +423,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock) ...@@ -423,7 +423,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock)
return -ENOBUFS; return -ENOBUFS;
break; break;
case 0: case 0:
dev = ip_dev_find(vifc->vifc_lcl_addr.s_addr); dev = ip_dev_find(&init_net, vifc->vifc_lcl_addr.s_addr);
if (!dev) if (!dev)
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
dev_put(dev); dev_put(dev);
......
...@@ -2282,14 +2282,14 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp) ...@@ -2282,14 +2282,14 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp)
goto out; goto out;
/* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */ /* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
dev_out = ip_dev_find(oldflp->fl4_src); dev_out = ip_dev_find(&init_net, oldflp->fl4_src);
if (dev_out == NULL) if (dev_out == NULL)
goto out; goto out;
/* I removed check for oif == dev_out->oif here. /* I removed check for oif == dev_out->oif here.
It was wrong for two reasons: It was wrong for two reasons:
1. ip_dev_find(saddr) can return wrong iface, if saddr is 1. ip_dev_find(net, saddr) can return wrong iface, if saddr
assigned to multiple interfaces. is assigned to multiple interfaces.
2. Moreover, we are allowed to send packets with saddr 2. Moreover, we are allowed to send packets with saddr
of another iface. --ANK of another iface. --ANK
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment