brctl: fixing stp parameters incompatibility
function old new delta static.stp_opts - 23 +23 brctl_main 1148 1169 +21 packed_usage 26786 26794 +8 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 2/0 up/down: 52/0) Total: 52 bytes Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
1c3f117ca4
commit
30ebd7bd78
@ -187,7 +187,7 @@
|
|||||||
"\n setpathcost BRIDGE COST Set path cost" \
|
"\n setpathcost BRIDGE COST Set path cost" \
|
||||||
"\n setportprio BRIDGE PRIO Set port priority" \
|
"\n setportprio BRIDGE PRIO Set port priority" \
|
||||||
"\n setbridgeprio BRIDGE PRIO Set bridge 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 \
|
#define bunzip2_trivial_usage \
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
/* Maximum number of ports supported per bridge interface. */
|
/* Maximum number of ports supported per bridge interface. */
|
||||||
#ifndef MAX_PORTS
|
#ifndef MAX_PORTS
|
||||||
#define MAX_PORTS 32
|
# define MAX_PORTS 32
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Use internal number parsing and not the "exact" conversion. */
|
/* Use internal number parsing and not the "exact" conversion. */
|
||||||
@ -40,26 +40,26 @@
|
|||||||
#define BRCTL_USE_INTERNAL 1
|
#define BRCTL_USE_INTERNAL 1
|
||||||
|
|
||||||
#if ENABLE_FEATURE_BRCTL_FANCY
|
#if ENABLE_FEATURE_BRCTL_FANCY
|
||||||
#include <linux/if_bridge.h>
|
# include <linux/if_bridge.h>
|
||||||
|
|
||||||
/* FIXME: These 4 funcs are not really clean and could be improved */
|
/* FIXME: These 4 funcs are not really clean and could be improved */
|
||||||
static ALWAYS_INLINE void strtotimeval(struct timeval *tv,
|
static ALWAYS_INLINE void strtotimeval(struct timeval *tv,
|
||||||
const char *time_str)
|
const char *time_str)
|
||||||
{
|
{
|
||||||
double secs;
|
double secs;
|
||||||
#if BRCTL_USE_INTERNAL
|
# if BRCTL_USE_INTERNAL
|
||||||
char *endptr;
|
char *endptr;
|
||||||
secs = /*bb_*/strtod(time_str, &endptr);
|
secs = /*bb_*/strtod(time_str, &endptr);
|
||||||
if (endptr == time_str)
|
if (endptr == time_str)
|
||||||
#else
|
# else
|
||||||
if (sscanf(time_str, "%lf", &secs) != 1)
|
if (sscanf(time_str, "%lf", &secs) != 1)
|
||||||
#endif
|
# endif
|
||||||
bb_error_msg_and_die (bb_msg_invalid_arg, time_str, "timespec");
|
bb_error_msg_and_die(bb_msg_invalid_arg, time_str, "timespec");
|
||||||
tv->tv_sec = secs;
|
tv->tv_sec = secs;
|
||||||
tv->tv_usec = 1000000 * (secs - tv->tv_sec);
|
tv->tv_usec = 1000000 * (secs - tv->tv_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv)
|
static ALWAYS_INLINE unsigned long tv_to_jiffies(const struct timeval *tv)
|
||||||
{
|
{
|
||||||
unsigned long long jif;
|
unsigned long long jif;
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ static ALWAYS_INLINE unsigned long __tv_to_jiffies(const struct timeval *tv)
|
|||||||
return jif/10000;
|
return jif/10000;
|
||||||
}
|
}
|
||||||
# if 0
|
# if 0
|
||||||
static void __jiffies_to_tv(struct timeval *tv, unsigned long jiffies)
|
static void jiffies_to_tv(struct timeval *tv, unsigned long jiffies)
|
||||||
{
|
{
|
||||||
unsigned long long tvusec;
|
unsigned long long tvusec;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ static unsigned long str_to_jiffies(const char *time_str)
|
|||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
strtotimeval(&tv, time_str);
|
strtotimeval(&tv, time_str);
|
||||||
return __tv_to_jiffies(&tv);
|
return tv_to_jiffies(&tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arm_ioctl(unsigned long *args,
|
static void arm_ioctl(unsigned long *args,
|
||||||
@ -220,9 +220,14 @@ int brctl_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
}
|
}
|
||||||
#if ENABLE_FEATURE_BRCTL_FANCY
|
#if ENABLE_FEATURE_BRCTL_FANCY
|
||||||
if (key == ARG_stp) { /* stp */
|
if (key == ARG_stp) { /* stp */
|
||||||
/* FIXME: parsing yes/y/on/1 versus no/n/off/0 is too involved */
|
static const char stp_opts[] ALIGN1 =
|
||||||
arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE,
|
"0\0" "off\0" "n\0" "no\0" /* 0 .. 3 */
|
||||||
(unsigned)(**argv - '0'), 0);
|
"1\0" "on\0" "y\0" "yes\0"; /* 4 .. 7 */
|
||||||
|
int onoff = index_in_strings(stp_opts, *argv);
|
||||||
|
if (onoff < 0)
|
||||||
|
bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
|
||||||
|
onoff = (unsigned)onoff / 4;
|
||||||
|
arm_ioctl(args, BRCTL_SET_BRIDGE_STP_STATE, onoff, 0);
|
||||||
goto fire;
|
goto fire;
|
||||||
}
|
}
|
||||||
if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */
|
if ((unsigned)(key - ARG_setageing) < 4) { /* time related ops */
|
||||||
|
Loading…
Reference in New Issue
Block a user