aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/libiproute/iprule.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/networking/libiproute/iprule.c b/networking/libiproute/iprule.c
index 535019d87..835529ec4 100644
--- a/networking/libiproute/iprule.c
+++ b/networking/libiproute/iprule.c
@@ -69,11 +69,9 @@ static int FAST_FUNC print_rule(const struct sockaddr_nl *who UNUSED_PARAM,
else if (r->rtm_family == AF_IPX)
host_len = 80;
*/
- if (tb[RTA_PRIORITY])
- printf("%u:\t", *(unsigned*)RTA_DATA(tb[RTA_PRIORITY]));
- else
- printf("0:\t");
-
+ printf("%u:\t", tb[RTA_PRIORITY] ?
+ *(unsigned*)RTA_DATA(tb[RTA_PRIORITY])
+ : 0);
printf("from ");
if (tb[RTA_SRC]) {
if (r->rtm_src_len != host_len) {
@@ -310,25 +308,13 @@ int do_iprule(char **argv)
{
static const char ip_rule_commands[] ALIGN1 =
"add\0""delete\0""list\0""show\0";
- int cmd = 2; /* list */
-
- if (!*argv)
- return iprule_list(argv);
-
- cmd = index_in_substrings(ip_rule_commands, *argv);
- switch (cmd) {
- case 0: /* add */
- cmd = RTM_NEWRULE;
- break;
- case 1: /* delete */
- cmd = RTM_DELRULE;
- break;
- case 2: /* list */
- case 3: /* show */
- return iprule_list(argv+1);
- break;
- default:
- bb_error_msg_and_die("unknown command %s", *argv);
+ if (*argv) {
+ smalluint cmd = index_in_substrings(ip_rule_commands, *argv);
+ if (cmd > 3)
+ bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
+ argv++;
+ if (cmd < 2)
+ return iprule_modify((cmd == 0) ? RTM_NEWRULE : RTM_DELRULE, argv);
}
- return iprule_modify(cmd, argv+1);
+ return iprule_list(argv);
}