Skip to contentSkip to conversation

net: introduce upper device lists and remove dev->master

PATCH Superseded Jiri Pirko 5 participants 25 messages Aug 14, 2012 – Aug 16, 2012

Subsystems (10)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Jiri Pirko

author maintainer
#0 lore raw

v2 cover net: introduce upper device lists and remove dev->master

Hi all.

Recent discussion around
"[net-next] bonding: don't allow the master to become its slave" forced me to think about upper<->lower device connections.

This patchset adds a possibility to record upper device linkage. All upper<->lower devices are converted to use this mechanism right after. That leads to dev->master removal because this info becomes redundant since "unique links" have the same value.

After all changes, there is no longer possible to do:
"bond->someotherdevice->samebond"

Also I think that drivers like cxgb3, qlcnic, qeth would benefit by this in future by being able to get more appropriate info about l3 addresses.

v1->v2:
- s/unique/master/ better naming + stays closer to the history
- fixed vlan err goto
- original patch 15 (WARN_ON change) is squashed into the first patch
- fixed netdev_unique_upper_dev_get_rcu() case of upper==NULL

Jiri Pirko (15):
net: introduce upper device lists
macvlan: add link to upper device
vlan: add link to upper device
rtnetlink: remove usage of dev->master
team: remove usage of netdev_set_master()
bridge: remove usage of netdev_set_master()
netpoll: remove usage of dev->master
cxgb3: remove usage of dev->master
qlcnic: guard __vlan_find_dev_deep() by rcu_read_lock
qeth: ensure that __vlan_find_dev_deep() is called with rcu_read_lock
vlan: remove usage of dev->master in __vlan_find_dev_deep()
nes: remove usage of dev->master
bonding: remove usage of dev->master
net: remove no longer used netdev_set_bond_master() and
netdev_set_master()
net: kill dev->master

 drivers/infiniband/hw/nes/nes.c                    |    8 +-
 drivers/infiniband/hw/nes/nes_cm.c                 |    2 +-
 drivers/net/bonding/bond_3ad.c                     |   30 +--
 drivers/net/bonding/bond_alb.c                     |    6 +-
 drivers/net/bonding/bond_main.c                    |   94 ++++----
 drivers/net/bonding/bonding.h                      |   14 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c |   11 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c   |    2 +
 drivers/net/macvlan.c                              |    9 +-
 drivers/net/team/team.c                            |   13 +-
 drivers/s390/net/qeth_l3_main.c                    |   21 +-
 include/linux/netdevice.h                          |   22 +-
 net/8021q/vlan.c                                   |   10 +-
 net/8021q/vlan_core.c                              |   18 +-
 net/bridge/br_if.c                                 |    6 +-
 net/core/dev.c                                     |  239 +++++++++++++++++---
 net/core/netpoll.c                                 |    8 +-
 net/core/rtnetlink.c                               |   45 ++--
 18 files changed, 391 insertions(+), 167 deletions(-)
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#1 lore raw

PATCH v2 1/15 net: introduce upper device lists

This lists are supposed to serve for storing pointers to all upper devices. Eventually it will replace dev->master pointer which is used for bonding, bridge, team but it cannot be used for vlan, macvlan where there might be multiple upper present. In case the upper link is replacement for dev->master, it is marked with "master" flag.

New upper device list resolves this limitation. Also, the information stored in lists is used for preventing looping setups like "bond->somethingelse->samebond"

---
 include/linux/netdevice.h |   14 +++
 net/core/dev.c            |  236 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 246 insertions(+), 4 deletions(-)
include/linux/netdevice.h +14 -0
index a9db4f3..95345d4 100644
@@ -1173,6 +1173,8 @@ struct net_device {
 					  * which this device is member of.
 					  */
 
+	struct list_head	upper_dev_list; /* List of upper devices */
+
 	/* Interface address info used in eth_type_trans() */
 	unsigned char		*dev_addr;	/* hw address, (before bcast
 						   because most packets are
@@ -2611,6 +2613,18 @@ extern int		netdev_max_backlog;
 extern int		netdev_tstamp_prequeue;
 extern int		weight_p;
 extern int		bpf_jit_enable;
+
+extern bool netdev_has_upper_dev(struct net_device *dev,
+				 struct net_device *upper_dev);
+extern bool netdev_has_any_upper_dev(struct net_device *dev);
+extern struct net_device *netdev_master_upper_dev_get(struct net_device *dev);
+extern struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev);
+extern int netdev_upper_dev_link(struct net_device *dev,
+				 struct net_device *upper_dev);
+extern int netdev_master_upper_dev_link(struct net_device *dev,
+					struct net_device *upper_dev);
+extern void netdev_upper_dev_unlink(struct net_device *dev,
+				    struct net_device *upper_dev);
 extern int		netdev_set_master(struct net_device *dev, struct net_device *master);
 extern int netdev_set_bond_master(struct net_device *dev,
 				  struct net_device *master);
net/core/dev.c +232 -4

271 lines not on this page · raw message

Signature · 1 line
1.7.10.4
#2 lore raw

Re: [patch net-next v2 01/15] net: introduce upper device lists

Quoted 5 lines · Jiri Pirko

This lists are supposed to serve for storing pointers to all upper devices. Eventually it will replace dev->master pointer which is used for bonding, bridge, team but it cannot be used for vlan, macvlan where there might be multiple upper present. In case the upper link is replacement for dev->master, it is marked with "master" flag.

Something I found interesting is that the dev->master pointer and now netdev_master_upper_dev_get{,_rcu}() are hardly used by the stackled drivers that set the master. They also have to set an rx_handler on the lower device (which is itself mutually exclusive) which gets its own context pointer (rx_handler_data).

Instead, the master pointer is mostly used by device drivers to find out about a bridge or bonding device above *their* devices. And that seems to work only for those specific device drivers, not e.g. openvswitch or team. I wonder if we could find a better way to encapsulate the things they want do do, in a later step (not holding up this change!).

[...]

Quoted 4 lines
net/core/dev.c +4 -0
+static int __netdev_upper_dev_link(struct net_device *dev,
+                                  struct net_device *upper_dev, bool master)
+{
+       struct netdev_upper *upper;

net/core/dev.c static int __init dev_proc_init(void) · line 4550

Quoted 10 lines
net/core/dev.c +10 -0
+
+       ASSERT_RTNL();
+
+       if (dev == upper_dev)
+               return -EBUSY;
+       /*
+        * To prevent loops, check if dev is not upper device to upper_dev.
+        */
+       if (__netdev_has_upper_dev(upper_dev, dev, true))
+               return -EBUSY;

[...]

I think we will also need to limit the depth of the device stack so we don't run out of stack space here. __netif_receive() implements a kind of tail recursion whenever a packet is passed up, but __netdev_has_upper_dev() can't avoid doing real recursion (without the addition of a flag to net_device so it can mark its progress).

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#3 lore raw

Re: [patch net-next v2 01/15] net: introduce upper device lists

Quoted 13 lines · On Tue, 14 Aug 2012 23:33:44 +0100 Ben Hutchings <[email protected]>…
Quoted 5 lines · Jiri Pirko

This lists are supposed to serve for storing pointers to all upper devices. Eventually it will replace dev->master pointer which is used for bonding, bridge, team but it cannot be used for vlan, macvlan where there might be multiple upper present. In case the upper link is replacement for dev->master, it is marked with "master" flag.

Something I found interesting is that the dev->master pointer and now netdev_master_upper_dev_get{,_rcu}() are hardly used by the stackled drivers that set the master. They also have to set an rx_handler on the lower device (which is itself mutually exclusive) which gets its own context pointer (rx_handler_data).

Quoted 5 lines

Instead, the master pointer is mostly used by device drivers to find out about a bridge or bonding device above *their* devices. And that seems to work only for those specific device drivers, not e.g. openvswitch or team. I wonder if we could find a better way to encapsulate the things they want do do, in a later step (not holding up this change!).

The concept is master is very useful to user level config things like Vyatta for seeing parent/child relationship. Since is in ABI now, it must stay.

author maintainer
#4 lore raw

Re: [patch net-next v2 01/15] net: introduce upper device lists

In reply to Ben Hutchings
Quoted 13 lines · Wed, Aug 15, 2012 at 12:33:44AM CEST, [email protected] wrote:
Quoted 5 lines · Jiri Pirko

This lists are supposed to serve for storing pointers to all upper devices. Eventually it will replace dev->master pointer which is used for bonding, bridge, team but it cannot be used for vlan, macvlan where there might be multiple upper present. In case the upper link is replacement for dev->master, it is marked with "master" flag.

Something I found interesting is that the dev->master pointer and now netdev_master_upper_dev_get{,_rcu}() are hardly used by the stackled drivers that set the master. They also have to set an rx_handler on the lower device (which is itself mutually exclusive) which gets its own context pointer (rx_handler_data).

Quoted 5 lines

Instead, the master pointer is mostly used by device drivers to find out about a bridge or bonding device above *their* devices. And that seems to work only for those specific device drivers, not e.g. openvswitch or team. I wonder if we could find a better way to encapsulate the things they want do do, in a later step (not holding up this change!).

Yes. I was thinking about this as well. I believe that we should follow up with this.

Quoted 18 lines

[...]

Quoted 14 lines
net/core/dev.c +14 -0
+static int __netdev_upper_dev_link(struct net_device *dev,
+                                  struct net_device *upper_dev, bool master)
+{
+       struct netdev_upper *upper;
+
+       ASSERT_RTNL();
+
+       if (dev == upper_dev)
+               return -EBUSY;
+       /*
+        * To prevent loops, check if dev is not upper device to upper_dev.
+        */
+       if (__netdev_has_upper_dev(upper_dev, dev, true))
+               return -EBUSY;

[...]

Quoted 6 lines

I think we will also need to limit the depth of the device stack so we don't run out of stack space here. __netif_receive() implements a kind of tail recursion whenever a packet is passed up, but __netdev_has_upper_dev() can't avoid doing real recursion (without the addition of a flag to net_device so it can mark its progress).

You are probably right. I'm not sure how to handle this correctly though. Adding some hard limit number might not be correct.

The problem could be also resolved by adding another struct list_head into struct upper and use this inside __netdev_has_upper_dev(). But that does not seem right to me as well (Considering the fact that walking through the tree could be in future done under _rcu).

Quoted 7 lines

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
maintainer
#5 lore raw

Re: [patch net-next v2 01/15] net: introduce upper device lists

From: Jiri Pirko <[email protected]>
Date: Wed, 15 Aug 2012 09:46:12 +0200

Quoted 2 lines

You are probably right. I'm not sure how to handle this correctly though. Adding some hard limit number might not be correct.

I would just use a hard limit of something like 8 for now, and if we need to expand this limit we can consider how to do so with real known usage in mind rather than pure speculation.

author maintainer
#6 lore raw

Re: [patch net-next v2 01/15] net: introduce upper device lists

Quoted 9 lines · Thu, Aug 16, 2012 at 12:15:49AM CEST, davem-fT/PcQaiUtIeIZ0/[email protected]…

From: Jiri Pirko <[email protected]>
Date: Wed, 15 Aug 2012 09:46:12 +0200

Quoted 2 lines

You are probably right. I'm not sure how to handle this correctly though. Adding some hard limit number might not be correct.

I would just use a hard limit of something like 8 for now, and if we need to expand this limit we can consider how to do so with real known usage in mind rather than pure speculation.

Okay. I will repost the set soon.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#7 lore raw

Re: [patch net-next v2 01/15] net: introduce upper device lists

In reply to Ben Hutchings

From: Ben Hutchings <[email protected]>
Date: Tue, 14 Aug 2012 23:33:44 +0100

Quoted 5 lines

I think we will also need to limit the depth of the device stack so we don't run out of stack space here. __netif_receive() implements a kind of tail recursion whenever a packet is passed up, but __netdev_has_upper_dev() can't avoid doing real recursion (without the addition of a flag to net_device so it can mark its progress).

Agreed, we need some kind of limit here.

author maintainer
#8 lore raw

PATCH v2 2/15 macvlan: add link to upper device

In reply to Jiri Pirko
---
 drivers/net/macvlan.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/macvlan.c +8 -1
index 66a9bfe..f5bd8a2 100644
@@ -765,16 +765,22 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 		memcpy(dev->dev_addr, lowerdev->dev_addr, ETH_ALEN);
 	}
 
+	err = netdev_upper_dev_link(lowerdev, dev);
+	if (err)
+		goto destroy_port;
+
 	port->count += 1;
 	err = register_netdevice(dev);
 	if (err < 0)
-		goto destroy_port;
+		goto upper_dev_unlink;
 
 	list_add_tail(&vlan->list, &port->vlans);
 	netif_stacked_transfer_operstate(lowerdev, dev);
 
 	return 0;
 
+upper_dev_unlink:
+	netdev_upper_dev_unlink(lowerdev, dev);
 destroy_port:
 	port->count -= 1;
 	if (!port->count)
@@ -798,6 +804,7 @@ void macvlan_dellink(struct net_device *dev, struct list_head *head)
 
 	list_del(&vlan->list);
 	unregister_netdevice_queue(dev, head);
+	netdev_upper_dev_unlink(vlan->lowerdev, dev);
 }
 EXPORT_SYMBOL_GPL(macvlan_dellink);
 
Signature · 1 line
1.7.10.4
author maintainer
#9 lore raw

PATCH v2 3/15 vlan: add link to upper device

In reply to Jiri Pirko
---
 net/8021q/vlan.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
net/8021q/vlan.c +9 -1
index 9096bcb..2dca0fa 100644
@@ -105,6 +105,8 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
 	 */
 	unregister_netdevice_queue(dev, head);
 
+	netdev_upper_dev_unlink(real_dev, dev);
+
 	if (grp->nr_vlan_devs == 0)
 		vlan_gvrp_uninit_applicant(real_dev);
 
@@ -162,9 +164,13 @@ int register_vlan_dev(struct net_device *dev)
 	if (err < 0)
 		goto out_uninit_applicant;
 
+	err = netdev_upper_dev_link(real_dev, dev);
+	if (err)
+		goto out_uninit_applicant;
+
 	err = register_netdevice(dev);
 	if (err < 0)
-		goto out_uninit_applicant;
+		goto out_upper_dev_unlink;
 
 	/* Account for reference in struct vlan_dev_priv */
 	dev_hold(real_dev);
@@ -180,6 +186,8 @@ int register_vlan_dev(struct net_device *dev)
 
 	return 0;
 
+out_upper_dev_unlink:
+	netdev_upper_dev_unlink(real_dev, dev);
 out_uninit_applicant:
 	if (grp->nr_vlan_devs == 0)
 		vlan_gvrp_uninit_applicant(real_dev);
Signature · 1 line
1.7.10.4
author maintainer
#10 lore raw

PATCH v2 4/15 rtnetlink: remove usage of dev->master

In reply to Jiri Pirko
---
 net/core/rtnetlink.c |   44 ++++++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 20 deletions(-)
net/core/rtnetlink.c +24 -20
index 34d975b..4d41682 100644
@@ -879,6 +879,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 	const struct rtnl_link_stats64 *stats;
 	struct nlattr *attr, *af_spec;
 	struct rtnl_af_ops *af_ops;
+	struct net_device *upper_dev = netdev_master_upper_dev_get(dev);
 
 	ASSERT_RTNL();
 	nlh = nlmsg_put(skb, pid, seq, type, sizeof(*ifm), flags);
@@ -907,8 +908,8 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
 #endif
 	    (dev->ifindex != dev->iflink &&
 	     nla_put_u32(skb, IFLA_LINK, dev->iflink)) ||
-	    (dev->master &&
-	     nla_put_u32(skb, IFLA_MASTER, dev->master->ifindex)) ||
+	    (upper_dev &&
+	     nla_put_u32(skb, IFLA_MASTER, upper_dev->ifindex)) ||
 	    (dev->qdisc &&
 	     nla_put_string(skb, IFLA_QDISC, dev->qdisc->ops->id)) ||
 	    (dev->ifalias &&
@@ -1270,16 +1271,16 @@ static int do_setvfinfo(struct net_device *dev, struct nlattr *attr)
 
 static int do_set_master(struct net_device *dev, int ifindex)
 {
-	struct net_device *master_dev;
+	struct net_device *upper_dev = netdev_master_upper_dev_get(dev);
 	const struct net_device_ops *ops;
 	int err;
 
-	if (dev->master) {
-		if (dev->master->ifindex == ifindex)
+	if (upper_dev) {
+		if (upper_dev->ifindex == ifindex)
 			return 0;
-		ops = dev->master->netdev_ops;
+		ops = upper_dev->netdev_ops;
 		if (ops->ndo_del_slave) {
-			err = ops->ndo_del_slave(dev->master, dev);
+			err = ops->ndo_del_slave(upper_dev, dev);
 			if (err)
 				return err;
 		} else {
@@ -1288,12 +1289,12 @@ static int do_set_master(struct net_device *dev, int ifindex)
 	}
 
 	if (ifindex) {
-		master_dev = __dev_get_by_index(dev_net(dev), ifindex);
-		if (!master_dev)
+		upper_dev = __dev_get_by_index(dev_net(dev), ifindex);
+		if (!upper_dev)
 			return -EINVAL;
-		ops = master_dev->netdev_ops;
+		ops = upper_dev->netdev_ops;
 		if (ops->ndo_add_slave) {
-			err = ops->ndo_add_slave(master_dev, dev);
+			err = ops->ndo_add_slave(upper_dev, dev);
 			if (err)
 				return err;
 		} else {
@@ -2050,7 +2051,6 @@ errout:
 static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 {
 	struct net *net = sock_net(skb->sk);
-	struct net_device *master = NULL;
 	struct ndmsg *ndm;
 	struct nlattr *tb[NDA_MAX+1];
 	struct net_device *dev;
@@ -2089,9 +2089,10 @@ static int rtnl_fdb_add(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 	/* Support fdb on master device the net/bridge default case */
 	if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) &&
 	    (dev->priv_flags & IFF_BRIDGE_PORT)) {
-		master = dev->master;
-		err = master->netdev_ops->ndo_fdb_add(ndm, dev, addr,
-						      nlh->nlmsg_flags);
+		struct net_device *br_dev = netdev_master_upper_dev_get(dev);
+		const struct net_device_ops *ops = br_dev->netdev_ops;
+
+		err = ops->ndo_fdb_add(ndm, dev, addr, nlh->nlmsg_flags);
 		if (err)
 			goto out;
 		else
@@ -2148,10 +2149,11 @@ static int rtnl_fdb_del(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
 	/* Support fdb on master device the net/bridge default case */
 	if ((!ndm->ndm_flags || ndm->ndm_flags & NTF_MASTER) &&
 	    (dev->priv_flags & IFF_BRIDGE_PORT)) {
-		struct net_device *master = dev->master;
+		struct net_device *br_dev = netdev_master_upper_dev_get(dev);
+		const struct net_device_ops *ops = br_dev->netdev_ops;
 
-		if (master->netdev_ops->ndo_fdb_del)
-			err = master->netdev_ops->ndo_fdb_del(ndm, dev, addr);
+		if (ops->ndo_fdb_del)
+			err = ops->ndo_fdb_del(ndm, dev, addr);
 
 		if (err)
 			goto out;
@@ -2234,9 +2236,11 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
 	rcu_read_lock();
 	for_each_netdev_rcu(net, dev) {
 		if (dev->priv_flags & IFF_BRIDGE_PORT) {
-			struct net_device *master = dev->master;
-			const struct net_device_ops *ops = master->netdev_ops;
+			struct net_device *br_dev;
+			const struct net_device_ops *ops;
 
+			br_dev = netdev_master_upper_dev_get(dev);
+			ops = br_dev->netdev_ops;
 			if (ops->ndo_fdb_dump)
 				idx = ops->ndo_fdb_dump(skb, cb, dev, idx);
 		}
Signature · 1 line
1.7.10.4
author maintainer
#11 lore raw

PATCH v2 5/15 team: remove usage of netdev_set_master()

In reply to Jiri Pirko
---
 drivers/net/team/team.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/net/team/team.c +7 -6
index ba10c46..dabddc5 100644
@@ -1040,10 +1040,11 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
 		}
 	}
 
-	err = netdev_set_master(port_dev, dev);
+	err = netdev_master_upper_dev_link(port_dev, dev);
 	if (err) {
-		netdev_err(dev, "Device %s failed to set master\n", portname);
-		goto err_set_master;
+		netdev_err(dev, "Device %s failed to set upper link\n",
+			   portname);
+		goto err_set_upper_link;
 	}
 
 	err = netdev_rx_handler_register(port_dev, team_handle_frame,
@@ -1076,9 +1077,9 @@ err_option_port_add:
 	netdev_rx_handler_unregister(port_dev);
 
 err_handler_register:
-	netdev_set_master(port_dev, NULL);
+	netdev_upper_dev_unlink(port_dev, dev);
 
-err_set_master:
+err_set_upper_link:
 	team_port_disable_netpoll(port);
 
 err_enable_netpoll:
@@ -1121,7 +1122,7 @@ static int team_port_del(struct team *team, struct net_device *port_dev)
 	team_port_disable(team, port);
 	list_del_rcu(&port->list);
 	netdev_rx_handler_unregister(port_dev);
-	netdev_set_master(port_dev, NULL);
+	netdev_upper_dev_unlink(port_dev, dev);
 	team_port_disable_netpoll(port);
 	vlan_vids_del_by_dev(port_dev, dev);
 	dev_close(port_dev);
Signature · 1 line
1.7.10.4
author maintainer
#12 lore raw

PATCH v2 6/15 bridge: remove usage of netdev_set_master()

In reply to Jiri Pirko
---
 net/bridge/br_if.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
net/bridge/br_if.c +3 -3
index e1144e1..8bea645 100644
@@ -148,7 +148,7 @@ static void del_nbp(struct net_bridge_port *p)
 	netdev_rx_handler_unregister(dev);
 	synchronize_net();
 
-	netdev_set_master(dev, NULL);
+	netdev_upper_dev_unlink(dev, br->dev);
 
 	br_multicast_del_port(p);
 
@@ -364,7 +364,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 	if (br_netpoll_info(br) && ((err = br_netpoll_enable(p))))
 		goto err3;
 
-	err = netdev_set_master(dev, br->dev);
+	err = netdev_master_upper_dev_link(dev, br->dev);
 	if (err)
 		goto err3;
 
@@ -403,7 +403,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev)
 	return 0;
 
 err4:
-	netdev_set_master(dev, NULL);
+	netdev_upper_dev_unlink(dev, br->dev);
 err3:
 	sysfs_remove_link(br->ifobj, p->dev->name);
 err2:
Signature · 1 line
1.7.10.4
author maintainer
#13 lore raw

PATCH v2 7/15 netpoll: remove usage of dev->master

In reply to Jiri Pirko
---
 net/core/netpoll.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/core/netpoll.c +6 -2
index b4c90e4..1f457a6 100644
@@ -207,12 +207,16 @@ static void netpoll_poll_dev(struct net_device *dev)
 
 	if (dev->flags & IFF_SLAVE) {
 		if (dev->npinfo) {
-			struct net_device *bond_dev = dev->master;
+			struct net_device *bond_dev;
 			struct sk_buff *skb;
+
+			rcu_read_lock();
+			bond_dev = netdev_master_upper_dev_get_rcu(dev);
 			while ((skb = skb_dequeue(&dev->npinfo->arp_tx))) {
 				skb->dev = bond_dev;
 				skb_queue_tail(&bond_dev->npinfo->arp_tx, skb);
 			}
+			rcu_read_unlock();
 		}
 	}
 
@@ -795,7 +799,7 @@ int netpoll_setup(struct netpoll *np)
 		return -ENODEV;
 	}
 
-	if (ndev->master) {
+	if (netdev_master_upper_dev_get(ndev)) {
 		np_err(np, "%s is a slave device, aborting\n", np->dev_name);
 		err = -EBUSY;
 		goto put;
Signature · 1 line
1.7.10.4
author maintainer
#14 lore raw

PATCH v2 8/15 cxgb3: remove usage of dev->master

In reply to Jiri Pirko
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c |   11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c +7 -4
index 2dbbcbb..720425d 100644
@@ -182,14 +182,17 @@ static struct net_device *get_iff_from_mac(struct adapter *adapter,
 		struct net_device *dev = adapter->port[i];
 
 		if (!memcmp(dev->dev_addr, mac, ETH_ALEN)) {
+			rcu_read_lock();
 			if (vlan && vlan != VLAN_VID_MASK) {
-				rcu_read_lock();
 				dev = __vlan_find_dev_deep(dev, vlan);
-				rcu_read_unlock();
 			} else if (netif_is_bond_slave(dev)) {
-				while (dev->master)
-					dev = dev->master;
+				struct net_device *upper_dev;
+
+				while ((upper_dev =
+					netdev_master_upper_dev_get_rcu(dev)))
+					dev = upper_dev;
 			}
+			rcu_read_unlock();
 			return dev;
 		}
 	}
Signature · 1 line
1.7.10.4
author maintainer
#15 lore raw

PATCH v2 9/15 qlcnic: guard __vlan_find_dev_deep() by rcu_read_lock

In reply to Jiri Pirko

rcu_read_lock was missing here

---
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c |    2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +2 -0
index 212c121..9eadf17 100644
@@ -4425,12 +4425,14 @@ qlcnic_restore_indev_addr(struct net_device *netdev, unsigned long event)
 
 	qlcnic_config_indev_addr(adapter, netdev, event);
 
+	rcu_read_lock();
 	for_each_set_bit(vid, adapter->vlans, VLAN_N_VID) {
 		dev = __vlan_find_dev_deep(netdev, vid);
 		if (!dev)
 			continue;
 		qlcnic_config_indev_addr(adapter, dev, event);
 	}
+	rcu_read_unlock();
 }
 
 static int qlcnic_netdev_event(struct notifier_block *this,
Signature · 1 line
1.7.10.4
author maintainer
#16 lore raw

PATCH v2 10/15 qeth: ensure that __vlan_find_dev_deep() is called with rcu_read_lock

In reply to Jiri Pirko

Also benefit from rcu_read_lock held and use __in_dev_get_rcu() in ipv4 case.

---
 drivers/s390/net/qeth_l3_main.c |   21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/s390/net/qeth_l3_main.c +11 -10
index c5f03fa..6b3988b 100644
@@ -1638,6 +1638,7 @@ static void qeth_l3_add_mc(struct qeth_card *card, struct in_device *in4_dev)
 	}
 }
 
+/* called with rcu_read_lock */
 static void qeth_l3_add_vlan_mc(struct qeth_card *card)
 {
 	struct in_device *in_dev;
@@ -1650,19 +1651,14 @@ static void qeth_l3_add_vlan_mc(struct qeth_card *card)
 	for_each_set_bit(vid, card->active_vlans, VLAN_N_VID) {
 		struct net_device *netdev;
 
-		rcu_read_lock();
 		netdev = __vlan_find_dev_deep(card->dev, vid);
-		rcu_read_unlock();
 		if (netdev == NULL ||
 		    !(netdev->flags & IFF_UP))
 			continue;
-		in_dev = in_dev_get(netdev);
+		in_dev = __in_dev_get_rcu(netdev);
 		if (!in_dev)
 			continue;
-		rcu_read_lock();
 		qeth_l3_add_mc(card, in_dev);
-		rcu_read_unlock();
-		in_dev_put(in_dev);
 	}
 }
 
@@ -1671,14 +1667,14 @@ static void qeth_l3_add_multicast_ipv4(struct qeth_card *card)
 	struct in_device *in4_dev;
 
 	QETH_CARD_TEXT(card, 4, "chkmcv4");
-	in4_dev = in_dev_get(card->dev);
-	if (in4_dev == NULL)
-		return;
 	rcu_read_lock();
+	in4_dev = __in_dev_get_rcu(card->dev);
+	if (in4_dev == NULL)
+		goto unlock;
 	qeth_l3_add_mc(card, in4_dev);
 	qeth_l3_add_vlan_mc(card);
+unlock:
 	rcu_read_unlock();
-	in_dev_put(in4_dev);
 }
 
 #ifdef CONFIG_QETH_IPV6
@@ -1703,6 +1699,7 @@ static void qeth_l3_add_mc6(struct qeth_card *card, struct inet6_dev *in6_dev)
 	}
 }
 
+/* called with rcu_read_lock */
 static void qeth_l3_add_vlan_mc6(struct qeth_card *card)
 {
 	struct inet6_dev *in_dev;
@@ -1739,10 +1736,12 @@ static void qeth_l3_add_multicast_ipv6(struct qeth_card *card)
 	in6_dev = in6_dev_get(card->dev);
 	if (in6_dev == NULL)
 		return;
+	rcu_read_lock();
 	read_lock_bh(&in6_dev->lock);
 	qeth_l3_add_mc6(card, in6_dev);
 	qeth_l3_add_vlan_mc6(card);
 	read_unlock_bh(&in6_dev->lock);
+	rcu_read_unlock();
 	in6_dev_put(in6_dev);
 }
 #endif /* CONFIG_QETH_IPV6 */
@@ -1811,8 +1810,10 @@ static void qeth_l3_free_vlan_addresses6(struct qeth_card *card,
 static void qeth_l3_free_vlan_addresses(struct qeth_card *card,
 			unsigned short vid)
 {
+	rcu_read_lock();
 	qeth_l3_free_vlan_addresses4(card, vid);
 	qeth_l3_free_vlan_addresses6(card, vid);
+	rcu_read_unlock();
 }
 
 static int qeth_l3_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
Signature · 1 line
1.7.10.4
author maintainer
#17 lore raw

PATCH v2 11/15 vlan: remove usage of dev->master in __vlan_find_dev_deep()

In reply to Jiri Pirko

Also, since all users call __vlan_find_dev_deep() with rcu_read_lock, make no possibility to call this with rtnl mutex held only.

---
 net/8021q/vlan_core.c |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
net/8021q/vlan_core.c +11 -7
index 8ca533c..d4babc6 100644
@@ -66,21 +66,25 @@ bool vlan_do_receive(struct sk_buff **skbp, bool last_handler)
 	return true;
 }
 
-/* Must be invoked with rcu_read_lock or with RTNL. */
-struct net_device *__vlan_find_dev_deep(struct net_device *real_dev,
+/* Must be invoked with rcu_read_lock. */
+struct net_device *__vlan_find_dev_deep(struct net_device *dev,
 					u16 vlan_id)
 {
-	struct vlan_info *vlan_info = rcu_dereference_rtnl(real_dev->vlan_info);
+	struct vlan_info *vlan_info = rcu_dereference(dev->vlan_info);
 
 	if (vlan_info) {
 		return vlan_group_get_device(&vlan_info->grp, vlan_id);
 	} else {
 		/*
-		 * Bonding slaves do not have grp assigned to themselves.
-		 * Grp is assigned to bonding master instead.
+		 * Lower devices of master uppers (bonding, team) do not have
+		 * grp assigned to themselves. Grp is assigned to upper device
+		 * instead.
 		 */
-		if (netif_is_bond_slave(real_dev))
-			return __vlan_find_dev_deep(real_dev->master, vlan_id);
+		struct net_device *upper_dev;
+
+		upper_dev = netdev_master_upper_dev_get_rcu(dev);
+		if (upper_dev)
+			return __vlan_find_dev_deep(upper_dev, vlan_id);
 	}
 
 	return NULL;
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#18 lore raw

PATCH v2 12/15 nes: remove usage of dev->master

In reply to Jiri Pirko
---
 drivers/infiniband/hw/nes/nes.c    |    8 +++++---
 drivers/infiniband/hw/nes/nes_cm.c |    2 +-
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/infiniband/hw/nes/nes.c +5 -3
index 7140199..6686251 100644
@@ -140,6 +140,7 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
 	struct net_device *event_netdev = ifa->ifa_dev->dev;
 	struct nes_device *nesdev;
 	struct net_device *netdev;
+	struct net_device *upper_dev;
 	struct nes_vnic *nesvnic;
 	unsigned int is_bonded;
 
@@ -150,8 +151,9 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
 				nesdev, nesdev->netdev[0]->name);
 		netdev = nesdev->netdev[0];
 		nesvnic = netdev_priv(netdev);
+		upper_dev = netdev_master_upper_dev_get(netdev);
 		is_bonded = netif_is_bond_slave(netdev) &&
-			    (netdev->master == event_netdev);
+			    (upper_dev == event_netdev);
 		if ((netdev == event_netdev) || is_bonded) {
 			if (nesvnic->rdma_enabled == 0) {
 				nes_debug(NES_DBG_NETDEV, "Returning without processing event for %s since"
@@ -184,9 +186,9 @@ static int nes_inetaddr_event(struct notifier_block *notifier,
 					/* fall through */
 				case NETDEV_CHANGEADDR:
 					/* Add the address to the IP table */
-					if (netdev->master)
+					if (upper_dev)
 						nesvnic->local_ipaddr =
-							((struct in_device *)netdev->master->ip_ptr)->ifa_list->ifa_address;
+							((struct in_device *)upper_dev->ip_ptr)->ifa_list->ifa_address;
 					else
 						nesvnic->local_ipaddr = ifa->ifa_address;
 
drivers/infiniband/hw/nes/nes_cm.c +1 -1
index 020e95c..15e6340 100644
@@ -1352,7 +1352,7 @@ static int nes_addr_resolve_neigh(struct nes_vnic *nesvnic, u32 dst_ip, int arpi
 	}
 
 	if (netif_is_bond_slave(nesvnic->netdev))
-		netdev = nesvnic->netdev->master;
+		netdev = netdev_unique_upper_dev_get(nesvnic->netdev);
 	else
 		netdev = nesvnic->netdev;
 
Signature · 1 line
1.7.10.4
author maintainer
#19 lore raw

PATCH v2 13/15 bonding: remove usage of dev->master

In reply to Jiri Pirko

Benefit from new upper dev list and free bonding from dev->master usage.

---
 drivers/net/bonding/bond_3ad.c  |   30 ++++++-------
 drivers/net/bonding/bond_alb.c  |    6 +--
 drivers/net/bonding/bond_main.c |   94 +++++++++++++++++++++++----------------
 drivers/net/bonding/bonding.h   |   14 +++---
 net/core/rtnetlink.c            |    1 +
 5 files changed, 81 insertions(+), 64 deletions(-)
drivers/net/bonding/bond_3ad.c +15 -15
index a030e63..84fabd6 100644
@@ -1127,7 +1127,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port)
 				// INFO_RECEIVED_LOOPBACK_FRAMES
 				pr_err("%s: An illegal loopback occurred on adapter (%s).\n"
 				       "Check the configuration to verify that all adapters are connected to 802.3ad compliant switch ports\n",
-				       port->slave->dev->master->name, port->slave->dev->name);
+				       port->slave->bond->dev->name, port->slave->dev->name);
 				return;
 			}
 			__update_selected(lacpdu, port);
@@ -1306,7 +1306,7 @@ static void ad_port_selection_logic(struct port *port)
 		}
 		if (!curr_port) { // meaning: the port was related to an aggregator but was not on the aggregator port list
 			pr_warning("%s: Warning: Port %d (on %s) was related to aggregator %d but was not on its port list\n",
-				   port->slave->dev->master->name,
+				   port->slave->bond->dev->name,
 				   port->actor_port_number,
 				   port->slave->dev->name,
 				   port->aggregator->aggregator_identifier);
@@ -1386,7 +1386,7 @@ static void ad_port_selection_logic(struct port *port)
 				 port->aggregator->aggregator_identifier);
 		} else {
 			pr_err("%s: Port %d (on %s) did not find a suitable aggregator\n",
-			       port->slave->dev->master->name,
+			       port->slave->bond->dev->name,
 			       port->actor_port_number, port->slave->dev->name);
 		}
 	}
@@ -1463,7 +1463,7 @@ static struct aggregator *ad_agg_selection_test(struct aggregator *best,
 
 	default:
 		pr_warning("%s: Impossible agg select mode %d\n",
-			   curr->slave->dev->master->name,
+			   curr->slave->bond->dev->name,
 			   __get_agg_selection_mode(curr->lag_ports));
 		break;
 	}
@@ -1571,7 +1571,7 @@ static void ad_agg_selection_logic(struct aggregator *agg)
 		// check if any partner replys
 		if (best->is_individual) {
 			pr_warning("%s: Warning: No 802.3ad response from the link partner for any adapters in the bond\n",
-				   best->slave ? best->slave->dev->master->name : "NULL");
+				   best->slave ? best->slave->bond->dev->name : "NULL");
 		}
 
 		best->is_active = 1;
@@ -1898,7 +1898,7 @@ int bond_3ad_bind_slave(struct slave *slave)
 
 	if (bond == NULL) {
 		pr_err("%s: The slave %s is not attached to its bond\n",
-		       slave->dev->master->name, slave->dev->name);
+		       slave->bond->dev->name, slave->dev->name);
 		return -1;
 	}
 
@@ -1973,7 +1973,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
 	// if slave is null, the whole port is not initialized
 	if (!port->slave) {
 		pr_warning("Warning: %s: Trying to unbind an uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+			   slave->bond->dev->name, slave->dev->name);
 		return;
 	}
 
@@ -2009,7 +2009,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
 
 				if ((new_aggregator->lag_ports == port) && new_aggregator->is_active) {
 					pr_info("%s: Removing an active aggregator\n",
-						aggregator->slave->dev->master->name);
+						aggregator->slave->bond->dev->name);
 					// select new active aggregator
 					 select_new_active_agg = 1;
 				}
@@ -2040,7 +2040,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
 					ad_agg_selection_logic(__get_first_agg(port));
 			} else {
 				pr_warning("%s: Warning: unbinding aggregator, and could not find a new aggregator for its ports\n",
-					   slave->dev->master->name);
+					   slave->bond->dev->name);
 			}
 		} else { // in case that the only port related to this aggregator is the one we want to remove
 			select_new_active_agg = aggregator->is_active;
@@ -2048,7 +2048,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
 			ad_clear_agg(aggregator);
 			if (select_new_active_agg) {
 				pr_info("%s: Removing an active aggregator\n",
-					slave->dev->master->name);
+					slave->bond->dev->name);
 				// select new active aggregator
 				ad_agg_selection_logic(__get_first_agg(port));
 			}
@@ -2076,7 +2076,7 @@ void bond_3ad_unbind_slave(struct slave *slave)
 					ad_clear_agg(temp_aggregator);
 					if (select_new_active_agg) {
 						pr_info("%s: Removing an active aggregator\n",
-							slave->dev->master->name);
+							slave->bond->dev->name);
 						// select new active aggregator
 						ad_agg_selection_logic(__get_first_agg(port));
 					}
@@ -2184,7 +2184,7 @@ static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, u1
 
 		if (!port->slave) {
 			pr_warning("%s: Warning: port of slave %s is uninitialized\n",
-				   slave->dev->name, slave->dev->master->name);
+				   slave->dev->name, slave->bond->dev->name);
 			return ret;
 		}
 
@@ -2240,7 +2240,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave)
 	// if slave is null, the whole port is not initialized
 	if (!port->slave) {
 		pr_warning("Warning: %s: speed changed for uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+			   slave->bond->dev->name, slave->dev->name);
 		return;
 	}
 
@@ -2268,7 +2268,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave)
 	// if slave is null, the whole port is not initialized
 	if (!port->slave) {
 		pr_warning("%s: Warning: duplex changed for uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+			   slave->bond->dev->name, slave->dev->name);
 		return;
 	}
 
@@ -2297,7 +2297,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link)
 	// if slave is null, the whole port is not initialized
 	if (!port->slave) {
 		pr_warning("Warning: %s: link status changed for uninitialized port on %s\n",
-			   slave->dev->master->name, slave->dev->name);
+			   slave->bond->dev->name, slave->dev->name);
 		return;
 	}
 
drivers/net/bonding/bond_alb.c +3 -3
index e15cc11..6dc3625 100644
@@ -491,7 +491,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
 				 client_info->mac_dst);
 		if (!skb) {
 			pr_err("%s: Error: failed to create an ARP packet\n",
-			       client_info->slave->dev->master->name);
+			       client_info->slave->bond->dev->name);
 			continue;
 		}
 
@@ -501,7 +501,7 @@ static void rlb_update_client(struct rlb_client_info *client_info)
 			skb = vlan_put_tag(skb, client_info->vlan_id);
 			if (!skb) {
 				pr_err("%s: Error: failed to insert VLAN tag\n",
-				       client_info->slave->dev->master->name);
+				       client_info->slave->bond->dev->name);
 				continue;
 			}
 		}
@@ -914,7 +914,7 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[])
 	if (dev_set_mac_address(dev, &s_addr)) {
 		pr_err("%s: Error: dev_set_mac_address of dev %s failed!\n"
 		       "ALB mode requires that the base driver support setting the hw address also when the network device's interface is open\n",
-		       dev->master->name, dev->name);
+		       slave->bond->dev->name, dev->name);
 		return -EOPNOTSUPP;
 	}
 	return 0;
drivers/net/bonding/bond_main.c +55 -39

193 lines not on this page · raw message

drivers/net/bonding/bonding.h +7 -7
index f8af2fc..c9cd1c0 100644
@@ -257,6 +257,9 @@ static inline bool bond_vlan_used(struct bonding *bond)
 #define bond_slave_get_rcu(dev) \
 	((struct slave *) rcu_dereference(dev->rx_handler_data))
 
+#define bond_slave_get_rtnl(dev) \
+	((struct slave *) rtnl_dereference(dev->rx_handler_data))
+
 /**
  * Returns NULL if the net_device does not belong to any of the bond's slaves
  *
@@ -279,11 +282,9 @@ static inline struct slave *bond_get_slave_by_dev(struct bonding *bond,
 
 static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
 {
-	if (!slave || !slave->dev->master) {
+	if (!slave || !slave->bond)
 		return NULL;
-	}
-
-	return netdev_priv(slave->dev->master);
+	return slave->bond;
 }
 
 static inline bool bond_is_lb(const struct bonding *bond)
@@ -359,10 +360,9 @@ static inline void bond_netpoll_send_skb(const struct slave *slave,
 
 static inline void bond_set_slave_inactive_flags(struct slave *slave)
 {
-	struct bonding *bond = netdev_priv(slave->dev->master);
-	if (!bond_is_lb(bond))
+	if (!bond_is_lb(slave->bond))
 		bond_set_backup_slave(slave);
-	if (!bond->params.all_slaves_active)
+	if (!slave->bond->params.all_slaves_active)
 		slave->inactive = 1;
 }
 
net/core/rtnetlink.c +1 -0
index 4d41682..f05e56f 100644
@@ -1989,6 +1989,7 @@ errout:
 	if (err < 0)
 		rtnl_set_sk_err(net, RTNLGRP_LINK, err);
 }
+EXPORT_SYMBOL(rtmsg_ifinfo);
 
 static int nlmsg_populate_fdb_fill(struct sk_buff *skb,
 				   struct net_device *dev,
Signature · 1 line
1.7.10.4
author maintainer
#20 lore raw

PATCH v2 14/15 net: remove no longer used netdev_set_bond_master() and netdev_set_master()

In reply to Jiri Pirko
---
 include/linux/netdevice.h |    6 +----
 net/core/dev.c            |   63 ---------------------------------------------
 2 files changed, 1 insertion(+), 68 deletions(-)
include/linux/netdevice.h +1 -5
index 95345d4..c689593 100644
@@ -886,8 +886,7 @@ struct netdev_fcoe_hbainfo {
  *	flow_id is a flow ID to be passed to rps_may_expire_flow() later.
  *	Return the filter ID on success, or a negative error code.
  *
- *	Slave management functions (for bridge, bonding, etc). User should
- *	call netdev_set_master() to set dev->master properly.
+ *	Slave management functions (for bridge, bonding, etc).
  * int (*ndo_add_slave)(struct net_device *dev, struct net_device *slave_dev);
  *	Called to make another netdev an underling.
  *
@@ -2625,9 +2624,6 @@ extern int netdev_master_upper_dev_link(struct net_device *dev,
 					struct net_device *upper_dev);
 extern void netdev_upper_dev_unlink(struct net_device *dev,
 				    struct net_device *upper_dev);
-extern int		netdev_set_master(struct net_device *dev, struct net_device *master);
-extern int netdev_set_bond_master(struct net_device *dev,
-				  struct net_device *master);
 extern int skb_checksum_help(struct sk_buff *skb);
 extern struct sk_buff *skb_gso_segment(struct sk_buff *skb,
 	netdev_features_t features);
net/core/dev.c +0 -63

69 lines not on this page · raw message

Signature · 1 line
1.7.10.4
author maintainer
#21 lore raw

PATCH v2 15/15 net: kill dev->master

In reply to Jiri Pirko

Nobody uses this now. Remove it.

---
 include/linux/netdevice.h |    4 ----
 1 file changed, 4 deletions(-)
include/linux/netdevice.h +0 -4
index c689593..8459f72 100644
@@ -1168,10 +1168,6 @@ struct net_device {
 						 * avoid dirtying this cache line.
 						 */
 
-	struct net_device	*master; /* Pointer to master device of a group,
-					  * which this device is member of.
-					  */
-
 	struct list_head	upper_dev_list; /* List of upper devices */
 
 	/* Interface address info used in eth_type_trans() */
Signature · 1 line
1.7.10.4
#22 lore raw
In reply to Jiri Pirko
Quoted 14 lines · Jiri Pirko

Hi all.

Recent discussion around
"[net-next] bonding: don't allow the master to become its slave" forced me to think about upper<->lower device connections.

This patchset adds a possibility to record upper device linkage. All upper<->lower devices are converted to use this mechanism right after. That leads to dev->master removal because this info becomes redundant since "unique links" have the same value.

After all changes, there is no longer possible to do:
"bond->someotherdevice->samebond"

Quoted 8 lines

Also I think that drivers like cxgb3, qlcnic, qeth would benefit by this in future by being able to get more appropriate info about l3 addresses.

v1->v2:
- s/unique/master/ better naming + stays closer to the history
- fixed vlan err goto
- original patch 15 (WARN_ON change) is squashed into the first patch
- fixed netdev_unique_upper_dev_get_rcu() case of upper==NULL

I just started to review v1 when v2 came out, but luckily the changes were not too significant that I need to start all over.

The first note is that I didn't like the use of the term 'upper' -- it seems like 'stacked' might be a better alternative as these are stacked devices.

One thing to note is that I don't see any clear changelog that states the current goals for this. You have stated in several places that it will no longer be possible to create bonds of bonds, but there are probably a few more things it might be wise to intentionally outlaw.

What about teams of teams? Or teams of bonds? Or bonds of teams? Bonds of vlans?

Quoted 30 lines

Jiri Pirko (15):
net: introduce upper device lists
macvlan: add link to upper device
vlan: add link to upper device
rtnetlink: remove usage of dev->master
team: remove usage of netdev_set_master()
bridge: remove usage of netdev_set_master()
netpoll: remove usage of dev->master
cxgb3: remove usage of dev->master
qlcnic: guard __vlan_find_dev_deep() by rcu_read_lock
qeth: ensure that __vlan_find_dev_deep() is called with rcu_read_lock
vlan: remove usage of dev->master in __vlan_find_dev_deep()
nes: remove usage of dev->master
bonding: remove usage of dev->master
net: remove no longer used netdev_set_bond_master() and
netdev_set_master()
net: kill dev->master

 drivers/infiniband/hw/nes/nes.c                    |    8 +-
 drivers/infiniband/hw/nes/nes_cm.c                 |    2 +-
 drivers/net/bonding/bond_3ad.c                     |   30 +--
 drivers/net/bonding/bond_alb.c                     |    6 +-
 drivers/net/bonding/bond_main.c                    |   94 ++++----
 drivers/net/bonding/bonding.h                      |   14 +-
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_offload.c |   11 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c   |    2 +
 drivers/net/macvlan.c                              |    9 +-
 drivers/net/team/team.c                            |   13 +-
 drivers/s390/net/qeth_l3_main.c                    |   21 +-
Quoted 16 lines
 include/linux/netdevice.h                          |   22 +-
 net/8021q/vlan.c                                   |   10 +-
 net/8021q/vlan_core.c                              |   18 +-
 net/bridge/br_if.c                                 |    6 +-
 net/core/dev.c                                     |  239 +++++++++++++++++---
 net/core/netpoll.c                                 |    8 +-
 net/core/rtnetlink.c                               |   45 ++--
 18 files changed, 391 insertions(+), 167 deletions(-)
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#23 lore raw
Quoted 23 lines · Andy Gospodarek
Quoted 14 lines · Jiri Pirko

Hi all.

Recent discussion around
"[net-next] bonding: don't allow the master to become its slave" forced me to think about upper<->lower device connections.

This patchset adds a possibility to record upper device linkage. All upper<->lower devices are converted to use this mechanism right after. That leads to dev->master removal because this info becomes redundant since "unique links" have the same value.

After all changes, there is no longer possible to do:
"bond->someotherdevice->samebond"

Quoted 8 lines

Also I think that drivers like cxgb3, qlcnic, qeth would benefit by this in future by being able to get more appropriate info about l3 addresses.

v1->v2:
- s/unique/master/ better naming + stays closer to the history
- fixed vlan err goto
- original patch 15 (WARN_ON change) is squashed into the first patch
- fixed netdev_unique_upper_dev_get_rcu() case of upper==NULL

Quoted 6 lines

I just started to review v1 when v2 came out, but luckily the changes were not too significant that I need to start all over.

The first note is that I didn't like the use of the term 'upper' -- it seems like 'stacked' might be a better alternative as these are stacked devices.

When linking any two devices in a stack, one will be upper and the other lower. The lower device might itself be stacked on top of a further device, so 'stacked' is not a useful distinguishing adjective in variable names. It might be a useful term in the commit messages and kernel-doc, though.

Quoted 7 lines

One thing to note is that I don't see any clear changelog that states the current goals for this. You have stated in several places that it will no longer be possible to create bonds of bonds, but there are probably a few more things it might be wise to intentionally outlaw.

What about teams of teams? Or teams of bonds? Or bonds of teams? Bonds of vlans?

[...]

It doesn't disallow bonds of bonds (unless I'm missing something). It disallows loops that involve any or all of those types of stacked devices.

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
author maintainer
#24 lore raw
Quoted 42 lines · Tue, Aug 14, 2012 at 10:32:53PM CEST, [email protected] wrote:
Quoted 23 lines · Andy Gospodarek
Quoted 14 lines · Jiri Pirko

Hi all.

Recent discussion around
"[net-next] bonding: don't allow the master to become its slave" forced me to think about upper<->lower device connections.

This patchset adds a possibility to record upper device linkage. All upper<->lower devices are converted to use this mechanism right after. That leads to dev->master removal because this info becomes redundant since "unique links" have the same value.

After all changes, there is no longer possible to do:
"bond->someotherdevice->samebond"

Quoted 8 lines

Also I think that drivers like cxgb3, qlcnic, qeth would benefit by this in future by being able to get more appropriate info about l3 addresses.

v1->v2:
- s/unique/master/ better naming + stays closer to the history
- fixed vlan err goto
- original patch 15 (WARN_ON change) is squashed into the first patch
- fixed netdev_unique_upper_dev_get_rcu() case of upper==NULL

Quoted 6 lines

I just started to review v1 when v2 came out, but luckily the changes were not too significant that I need to start all over.

The first note is that I didn't like the use of the term 'upper' -- it seems like 'stacked' might be a better alternative as these are stacked devices.

When linking any two devices in a stack, one will be upper and the other lower. The lower device might itself be stacked on top of a further device, so 'stacked' is not a useful distinguishing adjective in variable names. It might be a useful term in the commit messages and kernel-doc, though.

Quoted 5 lines

One thing to note is that I don't see any clear changelog that states the current goals for this. You have stated in several places that it will no longer be possible to create bonds of bonds, but there are probably a few more things it might be wise to intentionally outlaw.

Quoted 7 lines
Quoted 2 lines

What about teams of teams? Or teams of bonds? Or bonds of teams? Bonds of vlans?

[...]

It doesn't disallow bonds of bonds (unless I'm missing something). It disallows loops that involve any or all of those types of stacked devices.

Exactly. It's every "upper driver" responsibility to check which device it allows to be added as lower.

Quoted 8 lines

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.