diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-09-17 14:56:21 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:49:10 -0400 |
commit | 881d966b48b035ab3f3aeaae0f3d3f9b584f45b2 (patch) | |
tree | c579d59a4107cbbe9e2b85939bc0d496b815c887 /net/bridge | |
parent | b4b510290b056b86611757ce1175a230f1080f53 (diff) |
[NET]: Make the device list and device lookups per namespace.
This patch makes most of the generic device layer network
namespace safe. This patch makes dev_base_head a
network namespace variable, and then it picks up
a few associated variables. The functions:
dev_getbyhwaddr
dev_getfirsthwbytype
dev_get_by_flags
dev_get_by_name
__dev_get_by_name
dev_get_by_index
__dev_get_by_index
dev_ioctl
dev_ethtool
dev_load
wireless_process_ioctl
were modified to take a network namespace argument, and
deal with it.
vlan_ioctl_set and brioctl_set were modified so their
hooks will receive a network namespace argument.
So basically anthing in the core of the network stack that was
affected to by the change of dev_base was modified to handle
multiple network namespaces. The rest of the network stack was
simply modified to explicitly use &init_net the initial network
namespace. This can be fixed when those components of the network
stack are modified to handle multiple network namespaces.
For now the ifindex generator is left global.
Fundametally ifindex numbers are per namespace, or else
we will have corner case problems with migration when
we get that far.
At the same time there are assumptions in the network stack
that the ifindex of a network device won't change. Making
the ifindex number global seems a good compromise until
the network stack can cope with ifindex changes when
you change namespaces, and the like.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/bridge')
-rw-r--r-- | net/bridge/br_if.c | 4 | ||||
-rw-r--r-- | net/bridge/br_ioctl.c | 7 | ||||
-rw-r--r-- | net/bridge/br_netlink.c | 5 | ||||
-rw-r--r-- | net/bridge/br_private.h | 2 |
4 files changed, 10 insertions, 8 deletions
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 9272f12f664c..935784f736b3 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -303,7 +303,7 @@ int br_del_bridge(const char *name) | |||
303 | int ret = 0; | 303 | int ret = 0; |
304 | 304 | ||
305 | rtnl_lock(); | 305 | rtnl_lock(); |
306 | dev = __dev_get_by_name(name); | 306 | dev = __dev_get_by_name(&init_net, name); |
307 | if (dev == NULL) | 307 | if (dev == NULL) |
308 | ret = -ENXIO; /* Could not find device */ | 308 | ret = -ENXIO; /* Could not find device */ |
309 | 309 | ||
@@ -444,7 +444,7 @@ void __exit br_cleanup_bridges(void) | |||
444 | struct net_device *dev, *nxt; | 444 | struct net_device *dev, *nxt; |
445 | 445 | ||
446 | rtnl_lock(); | 446 | rtnl_lock(); |
447 | for_each_netdev_safe(dev, nxt) | 447 | for_each_netdev_safe(&init_net, dev, nxt) |
448 | if (dev->priv_flags & IFF_EBRIDGE) | 448 | if (dev->priv_flags & IFF_EBRIDGE) |
449 | del_br(dev->priv); | 449 | del_br(dev->priv); |
450 | rtnl_unlock(); | 450 | rtnl_unlock(); |
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c index bb15e9e259b1..0655a5f07f58 100644 --- a/net/bridge/br_ioctl.c +++ b/net/bridge/br_ioctl.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/if_bridge.h> | 18 | #include <linux/if_bridge.h> |
19 | #include <linux/netdevice.h> | 19 | #include <linux/netdevice.h> |
20 | #include <linux/times.h> | 20 | #include <linux/times.h> |
21 | #include <net/net_namespace.h> | ||
21 | #include <asm/uaccess.h> | 22 | #include <asm/uaccess.h> |
22 | #include "br_private.h" | 23 | #include "br_private.h" |
23 | 24 | ||
@@ -27,7 +28,7 @@ static int get_bridge_ifindices(int *indices, int num) | |||
27 | struct net_device *dev; | 28 | struct net_device *dev; |
28 | int i = 0; | 29 | int i = 0; |
29 | 30 | ||
30 | for_each_netdev(dev) { | 31 | for_each_netdev(&init_net, dev) { |
31 | if (i >= num) | 32 | if (i >= num) |
32 | break; | 33 | break; |
33 | if (dev->priv_flags & IFF_EBRIDGE) | 34 | if (dev->priv_flags & IFF_EBRIDGE) |
@@ -90,7 +91,7 @@ static int add_del_if(struct net_bridge *br, int ifindex, int isadd) | |||
90 | if (!capable(CAP_NET_ADMIN)) | 91 | if (!capable(CAP_NET_ADMIN)) |
91 | return -EPERM; | 92 | return -EPERM; |
92 | 93 | ||
93 | dev = dev_get_by_index(ifindex); | 94 | dev = dev_get_by_index(&init_net, ifindex); |
94 | if (dev == NULL) | 95 | if (dev == NULL) |
95 | return -EINVAL; | 96 | return -EINVAL; |
96 | 97 | ||
@@ -364,7 +365,7 @@ static int old_deviceless(void __user *uarg) | |||
364 | return -EOPNOTSUPP; | 365 | return -EOPNOTSUPP; |
365 | } | 366 | } |
366 | 367 | ||
367 | int br_ioctl_deviceless_stub(unsigned int cmd, void __user *uarg) | 368 | int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *uarg) |
368 | { | 369 | { |
369 | switch (cmd) { | 370 | switch (cmd) { |
370 | case SIOCGIFBR: | 371 | case SIOCGIFBR: |
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 0fcf6f073064..53ab8e0cb518 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
14 | #include <net/rtnetlink.h> | 14 | #include <net/rtnetlink.h> |
15 | #include <net/net_namespace.h> | ||
15 | #include "br_private.h" | 16 | #include "br_private.h" |
16 | 17 | ||
17 | static inline size_t br_nlmsg_size(void) | 18 | static inline size_t br_nlmsg_size(void) |
@@ -110,7 +111,7 @@ static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) | |||
110 | int idx; | 111 | int idx; |
111 | 112 | ||
112 | idx = 0; | 113 | idx = 0; |
113 | for_each_netdev(dev) { | 114 | for_each_netdev(&init_net, dev) { |
114 | /* not a bridge port */ | 115 | /* not a bridge port */ |
115 | if (dev->br_port == NULL || idx < cb->args[0]) | 116 | if (dev->br_port == NULL || idx < cb->args[0]) |
116 | goto skip; | 117 | goto skip; |
@@ -155,7 +156,7 @@ static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) | |||
155 | if (new_state > BR_STATE_BLOCKING) | 156 | if (new_state > BR_STATE_BLOCKING) |
156 | return -EINVAL; | 157 | return -EINVAL; |
157 | 158 | ||
158 | dev = __dev_get_by_index(ifm->ifi_index); | 159 | dev = __dev_get_by_index(&init_net, ifm->ifi_index); |
159 | if (!dev) | 160 | if (!dev) |
160 | return -ENODEV; | 161 | return -ENODEV; |
161 | 162 | ||
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index e6dc6f52990d..f666f7b28ff5 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -192,7 +192,7 @@ extern struct sk_buff *br_handle_frame(struct net_bridge_port *p, | |||
192 | 192 | ||
193 | /* br_ioctl.c */ | 193 | /* br_ioctl.c */ |
194 | extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); | 194 | extern int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); |
195 | extern int br_ioctl_deviceless_stub(unsigned int cmd, void __user *arg); | 195 | extern int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __user *arg); |
196 | 196 | ||
197 | /* br_netfilter.c */ | 197 | /* br_netfilter.c */ |
198 | #ifdef CONFIG_BRIDGE_NETFILTER | 198 | #ifdef CONFIG_BRIDGE_NETFILTER |