Hi, brctl stp command has incompatible parametrs wrt. brctl from bridge-utils package what breaks use on certain platforms. Moreover, calling brctl stp br0 off will result in STP being on, what is unexpected. The patch adds options: on, off, yes, no, and if the option passed on command line is not found in allowed set of options, an error is produced.
maciek
From bb1bde725507ab7f998c4bd721914742b8323251 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki <[email protected]> Date: Wed, 17 Mar 2010 21:57:29 +0100 Subject: [PATCH] brctl: fixing stp parameters incompatibility --- include/usage.h | 2 +- networking/brctl.c | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/usage.h b/include/usage.h index f4259a1..5a69b11 100644 --- a/include/usage.h +++ b/include/usage.h @@ -187,7 +187,7 @@ "\n setpathcost BRIDGE COST Set path cost" \ "\n setportprio BRIDGE PRIO Set port priority" \ "\n setbridgeprio BRIDGE PRIO Set bridge priority" \ - "\n stp BRIDGE [1|0] STP on/off" \ + "\n stp BRIDGE [1/yes/on|0/no/off] STP on/off" \ ) \ #define bunzip2_trivial_usage \ diff --git a/networking/brctl.c b/networking/brctl.c index e062dab..b72930c 100644 --- a/networking/brctl.c +++ b/networking/brctl.c @@ -220,9 +220,19 @@ int brctl_main(int argc UNUSED_PARAM, char **argv) } #if ENABLE_FEATURE_BRCTL_FANCY if (key == ARG_stp) { /* stp */ - /* FIXME: parsing yes/y/on/1 versus no/n/off/0 is too involved */ - arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, - (unsigned)(**argv - '0'), 0); + static const char stp_opts[] ALIGN1 = + "0\0" "off\0" "no\0" /* 0 .. 2 */ + "1\0" "on\0" "yes\0"; /* 3 .. 5 */ + unsigned onoff = 0; + smallint stp_opt_key = index_in_strings(stp_opts, *argv); + if (stp_opt_key >= 0) { + if (stp_opt_key >= 3) + onoff = 1; + else + onoff = 0; + } else + bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name); + arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, onoff, 0); goto fire; } if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */ -- 1.6.3.3
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
