OpenVZ Forum


Home » Mailing lists » Devel » [RFC PATCH 0/31] An introduction and A path for merging network namespace work
[PATCH RFC 16/31] net: Make the device list and device lookups per namespace. [message #17354 is a reply to message #17338] Thu, 25 January 2007 19:00 Go to previous messageGo to previous message
ebiederm is currently offline  ebiederm
Messages: 1354
Registered: February 2006
Senior Member
From: Eric W. Biederman <ebiederm@xmission.com> - unquoted

This patch makes most of the generic device layer network
namespace safe.  This patch makes dev_base, dev_base_lock
per network namespace variables, and then it picks up
a few associated variables.  The funnctions:
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 and dev_base_lock 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>
---
 arch/s390/appldata/appldata_net_sum.c |    6 +-
 arch/sparc64/solaris/ioctl.c          |    6 +-
 drivers/atm/idt77252.c                |    2 +-
 drivers/block/aoe/aoecmd.c            |    7 +-
 drivers/net/bonding/bond_main.c       |    6 +-
 drivers/net/bonding/bond_sysfs.c      |    3 +-
 drivers/net/eql.c                     |    9 +-
 drivers/net/pppoe.c                   |    2 +-
 drivers/net/shaper.c                  |    3 +-
 drivers/net/tun.c                     |    3 +-
 drivers/net/wan/dlci.c                |    4 +-
 drivers/net/wan/sbni.c                |    2 +-
 drivers/net/wireless/strip.c          |    8 +-
 drivers/parisc/led.c                  |    6 +-
 include/linux/if_bridge.h             |    2 +-
 include/linux/if_vlan.h               |    2 +-
 include/linux/netdevice.h             |   24 ++--
 include/net/iw_handler.h              |    2 +-
 net/802/tr.c                          |    2 +-
 net/8021q/vlan.c                      |   10 +-
 net/8021q/vlan_dev.c                  |   12 +-
 net/8021q/vlanproc.c                  |    8 +-
 net/appletalk/ddp.c                   |    6 +-
 net/atm/mpc.c                         |    2 +-
 net/ax25/af_ax25.c                    |    2 +-
 net/bridge/br_if.c                    |    6 +-
 net/bridge/br_ioctl.c                 |    7 +-
 net/bridge/br_netlink.c               |    9 +-
 net/bridge/br_private.h               |    2 +-
 net/core/dev.c                        |  282 +++++++++++++++++++++------------
 net/core/dev_mcast.c                  |   46 +++++-
 net/core/ethtool.c                    |    4 +-
 net/core/fib_rules.c                  |    4 +-
 net/core/link_watch.c                 |    5 +-
 net/core/neighbour.c                  |    6 +-
 net/core/net-sysfs.c                  |   27 ++--
 net/core/netpoll.c                    |    2 +-
 net/core/pktgen.c                     |    2 +-
 net/core/rtnetlink.c                  |   24 ++--
 net/core/sock.c                       |    3 +-
 net/core/wireless.c                   |   43 +++++-
 net/decnet/af_decnet.c                |    6 +-
 net/decnet/dn_dev.c                   |   32 ++--
 net/decnet/dn_fib.c                   |   12 +-
 net/decnet/dn_route.c                 |   14 +-
 net/decnet/sysctl_net_decnet.c        |    4 +-
 net/econet/af_econet.c                |    2 +-
 net/ipv4/arp.c                        |    4 +-
 net/ipv4/devinet.c                    |   36 ++--
 net/ipv4/fib_frontend.c               |    2 +-
 net/ipv4/fib_semantics.c              |    4 +-
 net/ipv4/igmp.c                       |   12 +-
 net/ipv4/ip_fragment.c                |    2 +-
 net/ipv4/ip_gre.c                     |    4 +-
 net/ipv4/ip_sockglue.c                |    2 +-
 net/ipv4/ipconfig.c                   |    2 +-
 net/ipv4/ipip.c                       |    4 +-
 net/ipv4/ipmr.c                       |    4 +-
 net/ipv4/ipvs/ip_vs_sync.c            |   10 +-
 net/ipv4/netfilter/ipt_CLUSTERIP.c    |    2 +-
 net/ipv4/route.c                      |    4 +-
 net/ipv6/addrconf.c                   |   44 +++---
 net/ipv6/af_inet6.c                   |    2 +-
 net/ipv6/anycast.c                    |   20 ++--
 net/ipv6/datagram.c                   |    2 +-
 net/ipv6/ip6_tunnel.c                 |    6 +-
 net/ipv6/ipv6_sockglue.c              |    2 +-
 net/ipv6/mcast.c                      |   20 ++--
 net/ipv6/raw.c                        |    2 +-
 net/ipv6/reassembly.c                 |    2 +-
 net/ipv6/route.c                      |    4 +-
 net/ipv6/sit.c                        |    4 +-
 net/ipx/af_ipx.c                      |    6 +-
 net/llc/af_llc.c                      |    4 +-
 net/llc/llc_core.c                    |    5 +-
 net/netrom/nr_route.c                 |   14 +-
 net/packet/af_packet.c                |   18 +-
 net/rose/rose_route.c                 |   20 ++--
 net/sched/act_mirred.c                |    2 +-
 net/sched/cls_api.c                   |    4 +-
 net/sched/em_meta.c                   |    2 +-
 net/sched/sch_api.c                   |   14 +-
 net/sctp/ipv6.c                       |    4 +-
 net/sctp/protocol.c                   |    6 +-
 net/socket.c                          |   22 ++-
 net/tipc/eth_media.c                  |    2 +-
 net/wanrouter/af_wanpipe.c            |   24 ++--
 net/x25/x25_route.c                   |    2 +-
 88 files changed, 597 insertions(+), 433 deletions(-)

diff --git a/arch/s390/appldata/appldata_net_sum.c b/arch/s390/appldata/appldata_net_sum.c
index 075e619..4a32370 100644
--- a/arch/s390/appldata/appldata_net_sum.c
+++ b/arch/s390/appldata/appldata_net_sum.c
@@ -106,8 +106,8 @@ static void appldata_get_net_sum_data(void *data)
 	rx_dropped = 0;
 	tx_dropped = 0;
 	collisions = 0;
-	read_lock(&dev_base_lock);
-	for (dev = dev_base; dev != NULL; dev = dev->next) {
+	read_lock(&per_net(dev_base_lock, init_net()));
+	for (dev = per_net(dev_base, init_net()); dev != NULL; dev = dev->next) {
 		if (dev->get_stats == NULL) {
 			continue;
 		}
@@ -123,7 +123,7 @@ static void appldata_get_net_sum_data(void *data)
 		collisions += stats->collisions;
 		i++;
 	}
-	read_unlock(&dev_base_lock);
+	read_unlock(&per_net(dev_base_lock, init_net()));
 	net_data->nr_interfaces = i;
 	net_data->rx_packets = rx_packets;
 	net_data->tx_packets = tx_packets;
diff --git a/arch/sparc64/solaris/ioctl.c b/arch/sparc64/solaris/ioctl.c
index 330743c..1ecf4ab 100644
--- a/arch/sparc64/solaris/ioctl.c
+++ b/arch/sparc64/solaris/ioctl.c
@@ -685,9 +685,9 @@ static inline int solaris_i(unsigned int fd, unsigned int cmd, u32 arg)
 			struct net_device *d;
 			int i = 0;
 			
-			read_lock_bh(&dev_base_lock);
-			for (d = dev_base; d; d = d->next) i++;
-			read_unlock_bh(&dev_base_lock);
+			read_lock_bh(&per_net(dev_base_lock, init_net()));
+			for (d = per_net(dev_base, init_net()); d; d = d->next) i++;
+			read_unlock_bh(&per_net(dev_base_lock, init_net()));
 
 			if (put_user (i, (int __user *)A(arg)))
 				return -EFAULT;
diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
index f407861..3e75e0e 100644
--- a/drivers/atm/idt77252.c
+++ b/drivers/atm/idt77252.c
@@ -3569,7 +3569,7 @@ init_card(struct atm_dev *dev)
 	 * XXX: <hack>
 	 */
 	sprintf(tname, "eth%d", card->index);
-	tmp = dev_get_by_name(tname);	/* jhs: was "tmp = dev_get(tname);" */
+	tmp = dev_get_by_name(init_net(), tname);	/* jhs: was "tmp = dev_get(tname);" */
 	if (tmp) {
 		memcpy(card->atmdev->esi, tmp->dev_addr, 6);
 
diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index bb022ed..9678169 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -9,6 +9,7 @@
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
 #include <linux/genhd.h>
+#include <net/net_namespace.h>
 #include <asm/unaligned.h>
 #include "aoe.h"
 
@@ -192,8 +193,8 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
 
 	sl = sl_tail = NULL;
 
-	read_lock(&dev_base_lock);
-	for (ifp = dev_base; ifp; dev_put(ifp), ifp = ifp->next) {
+	read_lock(&per_net(dev_base_lock, init_net()));
+	for (ifp = per_net(dev_base, init_net()); ifp; dev_put(ifp), ifp = ifp->next) {
 		dev_hold(ifp);
 		if (!is_aoe_netif(ifp))
 			continue;
@@ -221,7 +222,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff **tail)
 		skb->next = sl;
 		sl = skb;
 	}
-	read_unlock(&dev_base_lock);
+	read_unlock(&per_net(dev_base_lock, init_net()));
 
 	if (tail != NULL)
 		*tail = sl_tail;
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 3e04f58..2963004 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2932,7 +2932,7 @@ static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
 	int i;
 
 	/* make sure the bond won't be taken away */
-	read_lock(&dev_base_lock);
+	read_lock(&per_net(dev_base_lock, init_net()));
 	read_lock_bh(&bond->lock);
 
 	if (*pos == 0) {
@@ -2968,7 +2968,7 @@ static void bond_info_seq_stop(struct seq_file *seq, void *v)
 	struct bonding *bond = seq->private;
 
 	read_unlock_bh(&bond->lock);
-	read_unlock(&dev_base_lock);
+	read_unlock(&per_net(dev_base_lock, init_net()));
 }
 
 static void bond_info_show_master(struct seq_file *se
...

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: [ckrm-tech] [PATCH 0/2] resource control file system - aka containers on top of nsproxy!
Next Topic: [RFC] Containers infrastructure problems
Goto Forum:
  


Current Time: Sat Sep 20 15:53:18 GMT 2025

Total time taken to generate the page: 0.05970 seconds