Bridge allows the userspace to configure the bridge parameters with values not defined in the IEEE 802.1D std
Subsystems (3)
PATCH 1/1 Bridge allows the userspace to configure the bridge parameters with values not defined in the IEEE 802.1D std
--- include/linux/if_bridge.h | 28 +++++++++++++++ net/bridge/br_ioctl.c | 35 +++++++----------- net/bridge/br_private.h | 7 +++- net/bridge/br_stp_if.c | 7 +++- net/bridge/br_sysfs_br.c | 83 ++++++++++++++++++++++++++++++++++++--------- net/bridge/br_sysfs_if.c | 3 +- 6 files changed, 122 insertions(+), 41 deletions(-)
include/linux/if_bridge.h +28 -0
@@ -49,6 +49,34 @@#define BR_STATE_FORWARDING 3#define BR_STATE_BLOCKING 4 +/*802.1D STP compatibility Range*/ +#define BR_DEFAULT_BRIDGE_PRIORITY 32768 +#define BR_MIN_BRIDGE_PRIORITY 0 +#define BR_MAX_BRIDGE_PRIORITY 65535 + +#define BR_DEFAULT_PORT_PRIORITY 128 +#define BR_MIN_PORT_PRIORITY 0 +#define BR_MAX_PORT_PRIORITY 240 + +#define BR_MIN_PATH_COST 1 +#define BR_MAX_PATH_COST 200000000 + +#define BR_DEFAULT_HELLO_TIME 2 +#define BR_MIN_HELLO_TIME 1 +#define BR_MAX_HELLO_TIME 10 + +#define BR_DEFAULT_MAX_AGE 20 +#define BR_MIN_MAX_AGE 6 +#define BR_MAX_MAX_AGE 40 + +#define BR_DEFAULT_FORWARD_DELAY 15 +#define BR_MIN_FORWARD_DELAY 2 +#define BR_MAX_FORWARD_DELAY 30 + +#define BR_DEFAULT_AGEING_TIME 300 +#define BR_MIN_AGEING_TIME 10 +#define BR_MAX_AGEING_TIME 1000000 +struct __bridge_info {__u64 designated_root;__u64 bridge_id;
net/bridge/br_ioctl.c +14 -21
@@ -112,6 +112,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {struct net_bridge *br =netdev_priv (dev);unsigned long args[4 ]; +int rval =0 ;if (copy_from_user (args, rq->ifr_data,sizeof (args)))return -EFAULT ;
@@ -182,27 +183,19 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)return -EPERM ;spin_lock_bh (&br->lock); - br->bridge_forward_delay =clock_t_to_jiffies (args[1 ]); -if (br_is_root_bridge (br)) - br->forward_delay = br->bridge_forward_delay; + rval =set_forward_delay (br, args[1 ]);spin_unlock_bh (&br->lock); -return 0 ; +return rval;case BRCTL_SET_BRIDGE_HELLO_TIME : { -unsigned long t =clock_t_to_jiffies (args[1 ]);if (!capable (CAP_NET_ADMIN ))return -EPERM ; -if (t <HZ ) -return -EINVAL ; -spin_lock_bh (&br->lock); - br->bridge_hello_time = t; -if (br_is_root_bridge (br)) - br->hello_time = br->bridge_hello_time; + rval =set_hello_time (br, args[1 ]);spin_unlock_bh (&br->lock); -return 0 ; +return rval; }case BRCTL_SET_BRIDGE_MAX_AGE :
@@ -210,18 +203,18 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)return -EPERM ;spin_lock_bh (&br->lock); - br->bridge_max_age =clock_t_to_jiffies (args[1 ]); -if (br_is_root_bridge (br)) - br->max_age = br->bridge_max_age; + rval =set_max_age (br, args[1 ]);spin_unlock_bh (&br->lock); -return 0 ; +return rval;case BRCTL_SET_AGEING_TIME :if (!capable (CAP_NET_ADMIN ))return -EPERM ; - br->ageing_time =clock_t_to_jiffies (args[1 ]); -return 0 ; +spin_lock_bh (&br->lock); + rval =set_ageing_time (br, args[1 ]); +spin_unlock_bh (&br->lock); +return rval;case BRCTL_GET_PORT_INFO : {
@@ -268,9 +261,9 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)return -EPERM ;spin_lock_bh (&br->lock); -br_stp_set_bridge_priority (br, args[1 ]); + rval =set_priority (br, args[1 ]);spin_unlock_bh (&br->lock); -return 0 ; +return rval;case BRCTL_SET_PORT_PRIORITY : {
@@ -303,7 +296,7 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)if ((p =br_get_port (br, args[1 ])) ==NULL ) ret = -EINVAL ;else -br_stp_set_path_cost (p, args[2 ]); + ret =br_stp_set_path_cost (p, args[2 ]);return ret; }
net/bridge/br_private.h +6 -1
@@ -503,7 +503,7 @@ extern void br_stp_set_bridge_priority(struct net_bridge *br, u16 newprio);extern void br_stp_set_port_priority (struct net_bridge_port *p,u8 newprio); -extern void br_stp_set_path_cost (struct net_bridge_port *p, +extern int br_stp_set_path_cost (struct net_bridge_port *p,u32 path_cost);extern ssize_t br_show_bridge_id (char *buf,const struct bridge_id *id);
@@ -536,6 +536,11 @@ extern int br_sysfs_renameif(struct net_bridge_port *p);/* br_sysfs_br.c */ extern int br_sysfs_addbr (struct net_device *dev);extern void br_sysfs_delbr (struct net_device *dev); +extern int set_forward_delay (struct net_bridge *br,unsigned long val); +extern int set_max_age (struct net_bridge *br,unsigned long val); +extern int set_hello_time (struct net_bridge *br,unsigned long val); +extern int set_priority (struct net_bridge *br,unsigned long val); +extern int set_ageing_time (struct net_bridge *br,unsigned long val);#else
net/bridge/br_stp_if.c +6 -1
@@ -269,11 +269,16 @@ void br_stp_set_port_priority(struct net_bridge_port *p, u8 newprio) }/* called under bridge lock */ -void br_stp_set_path_cost (struct net_bridge_port *p,u32 path_cost) +int br_stp_set_path_cost (struct net_bridge_port *p,u32 path_cost) { +if (path_cost <BR_MIN_PATH_COST && + path_cost >BR_MAX_PATH_COST ) +return -ERANGE ; + p->path_cost = path_cost;br_configuration_update (p->br);br_port_state_selection (p->br); +return 0 ; }ssize_t br_show_bridge_id (char *buf,const struct bridge_id *id)
net/bridge/br_sysfs_br.c +67 -16
124 lines not on this page · raw message
net/bridge/br_sysfs_if.c +1 -2
@@ -40,8 +40,7 @@ static ssize_t show_path_cost(struct net_bridge_port *p, char *buf) }static ssize_t store_path_cost (struct net_bridge_port *p,unsigned long v) { -br_stp_set_path_cost (p, v); -return 0 ; +return br_stp_set_path_cost (p, v); } static BRPORT_ATTR(path_cost, S_IRUGO | S_IWUSR, show_path_cost, store_path_cost);
Signature · 1 line
1.7.3.4
Quoted 3 lines · On Sat, 26 Mar 2011 20:19:57 +0530 Sasikanth V <[email protected]> wrote:
Signed-off-by Sasikanth V <[email protected]>---
I will clean this up. There are things like introducing global function names (set_forward_delay, etc) that need to be fixed.
Quoted 11 lines · Stephen Hemminger
Quoted 3 lines · On Sat, 26 Mar 2011 20:19:57 +0530 Sasikanth V <[email protected]> wrote:
Signed-off-by Sasikanth V <[email protected]>---
I will clean this up. There are things like introducing global function names (
set_forward_delay, etc) that need to be fixed.
Thanks for looking at the patch. I made 5 set functions
(set_forward_delay, set_max_age,
set_hello_time, set_priority and set_ageing_time) in br_sysfs_br.c global
to use in br_ioctl.c to
avoid code duplication (but it looks it is not a good idea).
Now i thought something like making those 5 functions static inline and
moving it to br_private.h.
If this is fine , I will resend the patch
Quoted 23 lines · Sasikanth V
Quoted 11 lines · Stephen Hemminger
Quoted 3 lines · On Sat, 26 Mar 2011 20:19:57 +0530 Sasikanth V <[email protected]> wrote:
Signed-off-by Sasikanth V <[email protected]>---
I will clean this up. There are things like introducing global function names (
set_forward_delay, etc) that need to be fixed.Thanks for looking at the patch. I made 5 set functions
(set_forward_delay,set_max_age,
set_hello_time,set_priorityandset_ageing_time) inbr_sysfs_br.c
global to use inbr_ioctl.cto
avoid code duplication (but it looks it is not a good idea).
Quoted 7 lines
Now i thought something like making those 5 functions static inline and
moving it tobr_private.h.
If this is fine , I will resend the patchSince I am new to patch states and workflow. Can you guys please let me,
what I have to do when the
patch state is in Awaiting Stream.
Thanks