[RFC 2/5] net: bridge - add managing of BRCTL_SET_VIA_PHYS_DEV and BRCTL_SET_MASTER_DEV

Previous thread: [RFC 5/5] net: bridge - handle via_phys_dev feature on a bridge level by Cyrill Gorcunov on Monday, May 11, 2009 - 4:46 am. (2 messages)

Next thread: [RFC 3/5] net: sk_buff - introduce br_seen field to mark skb issued by a bridge by Cyrill Gorcunov on Monday, May 11, 2009 - 4:46 am. (1 message)
From: Cyrill Gorcunov
Date: Monday, May 11, 2009 - 4:46 am

Add managing via_phys_dev feature at sysctl level and ioctls as well.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
---

Note: there is no changing done for __bridge_info structure and
in handling of BRCTL_GET_BRIDGE_INFO since they are part of
userspace. So returning info about master_dev could break
userpace applications. Not sure how to better handle it
and eventually decided to not touch it at all.

 include/linux/if_bridge.h |    2 ++
 net/bridge/br_if.c        |   22 ++++++++++++++++++++++
 net/bridge/br_ioctl.c     |   29 +++++++++++++++++++++++++++++
 net/bridge/br_private.h   |    2 ++
 net/bridge/br_sysfs_br.c  |   23 +++++++++++++++++++++++
 5 files changed, 78 insertions(+)

Index: linux-2.6.git/include/linux/if_bridge.h
=====================================================================
--- linux-2.6.git.orig/include/linux/if_bridge.h
+++ linux-2.6.git/include/linux/if_bridge.h
@@ -42,6 +42,8 @@
 #define BRCTL_SET_PORT_PRIORITY 16
 #define BRCTL_SET_PATH_COST 17
 #define BRCTL_GET_FDB_ENTRIES 18
+#define BRCTL_SET_VIA_PHYS_DEV 19
+#define BRCTL_SET_MASTER_DEV 20
 
 #define BR_STATE_DISABLED 0
 #define BR_STATE_LISTENING 1
Index: linux-2.6.git/net/bridge/br_if.c
=====================================================================
--- linux-2.6.git.orig/net/bridge/br_if.c
+++ linux-2.6.git/net/bridge/br_if.c
@@ -158,6 +158,11 @@ static void del_br(struct net_bridge *br
 {
 	struct net_bridge_port *p, *n;
 
+	if (br->master_dev) {
+		dev_put(br->master_dev);
+		br->master_dev = NULL;
+	}
+
 	list_for_each_entry_safe(p, n, &br->port_list, list) {
 		del_nbp(p);
 	}
@@ -412,6 +417,19 @@ int br_add_if(struct net_bridge *br, str
 	if ((dev->flags & IFF_UP) && netif_carrier_ok(dev) &&
 	    (br->dev->flags & IFF_UP))
 		br_stp_enable_port(p);
+
+	/*
+	 * since brctl utils could not have BRCTL_SET_MASTER_DEV
+	 * yet implemented we set first port as master device
+	 * if via_phys_dev is turned on
+	 */
+	if (br->via_phys_dev) {
+		if ...
Previous thread: [RFC 5/5] net: bridge - handle via_phys_dev feature on a bridge level by Cyrill Gorcunov on Monday, May 11, 2009 - 4:46 am. (2 messages)

Next thread: [RFC 3/5] net: sk_buff - introduce br_seen field to mark skb issued by a bridge by Cyrill Gorcunov on Monday, May 11, 2009 - 4:46 am. (1 message)