diff options
Diffstat (limited to 'networking/libiproute/iproute.c')
-rw-r--r-- | networking/libiproute/iproute.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 91811117c..ec0952668 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -292,7 +292,7 @@ static int print_route(struct sockaddr_nl *who ATTRIBUTE_UNUSED, | |||
292 | } | 292 | } |
293 | 293 | ||
294 | /* Return value becomes exitcode. It's okay to not return at all */ | 294 | /* Return value becomes exitcode. It's okay to not return at all */ |
295 | static int iproute_modify(int cmd, unsigned flags, int argc, char **argv) | 295 | static int iproute_modify(int cmd, unsigned flags, char **argv) |
296 | { | 296 | { |
297 | static const char keywords[] ALIGN1 = | 297 | static const char keywords[] ALIGN1 = |
298 | "src\0""via\0""mtu\0""lock\0""protocol\0"USE_FEATURE_IP_RULE("table\0") | 298 | "src\0""via\0""mtu\0""lock\0""protocol\0"USE_FEATURE_IP_RULE("table\0") |
@@ -344,7 +344,7 @@ USE_FEATURE_IP_RULE(ARG_table,) | |||
344 | mxrta->rta_type = RTA_METRICS; | 344 | mxrta->rta_type = RTA_METRICS; |
345 | mxrta->rta_len = RTA_LENGTH(0); | 345 | mxrta->rta_len = RTA_LENGTH(0); |
346 | 346 | ||
347 | while (argc > 0) { | 347 | while (*argv) { |
348 | arg = index_in_substrings(keywords, *argv); | 348 | arg = index_in_substrings(keywords, *argv); |
349 | if (arg == ARG_src) { | 349 | if (arg == ARG_src) { |
350 | inet_prefix addr; | 350 | inet_prefix addr; |
@@ -417,7 +417,7 @@ USE_FEATURE_IP_RULE(ARG_table,) | |||
417 | addattr_l(&req.n, sizeof(req), RTA_DST, &dst.data, dst.bytelen); | 417 | addattr_l(&req.n, sizeof(req), RTA_DST, &dst.data, dst.bytelen); |
418 | } | 418 | } |
419 | } | 419 | } |
420 | argc--; argv++; | 420 | argv++; |
421 | } | 421 | } |
422 | 422 | ||
423 | xrtnl_open(&rth); | 423 | xrtnl_open(&rth); |
@@ -511,7 +511,7 @@ static void iproute_reset_filter(void) | |||
511 | } | 511 | } |
512 | 512 | ||
513 | /* Return value becomes exitcode. It's okay to not return at all */ | 513 | /* Return value becomes exitcode. It's okay to not return at all */ |
514 | static int iproute_list_or_flush(int argc, char **argv, int flush) | 514 | static int iproute_list_or_flush(char **argv, int flush) |
515 | { | 515 | { |
516 | int do_ipv6 = preferred_family; | 516 | int do_ipv6 = preferred_family; |
517 | struct rtnl_handle rth; | 517 | struct rtnl_handle rth; |
@@ -534,10 +534,10 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) | |||
534 | iproute_reset_filter(); | 534 | iproute_reset_filter(); |
535 | filter.tb = RT_TABLE_MAIN; | 535 | filter.tb = RT_TABLE_MAIN; |
536 | 536 | ||
537 | if (flush && argc <= 0) | 537 | if (flush && !*argv) |
538 | bb_error_msg_and_die(bb_msg_requires_arg, "\"ip route flush\""); | 538 | bb_error_msg_and_die(bb_msg_requires_arg, "\"ip route flush\""); |
539 | 539 | ||
540 | while (argc > 0) { | 540 | while (*argv) { |
541 | arg = index_in_substrings(keywords, *argv); | 541 | arg = index_in_substrings(keywords, *argv); |
542 | if (arg == ARG_proto) { | 542 | if (arg == ARG_proto) { |
543 | uint32_t prot = 0; | 543 | uint32_t prot = 0; |
@@ -602,7 +602,6 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) | |||
602 | filter.rdst = filter.mdst; | 602 | filter.rdst = filter.mdst; |
603 | } | 603 | } |
604 | } | 604 | } |
605 | argc--; | ||
606 | argv++; | 605 | argv++; |
607 | } | 606 | } |
608 | 607 | ||
@@ -667,7 +666,7 @@ static int iproute_list_or_flush(int argc, char **argv, int flush) | |||
667 | 666 | ||
668 | 667 | ||
669 | /* Return value becomes exitcode. It's okay to not return at all */ | 668 | /* Return value becomes exitcode. It's okay to not return at all */ |
670 | static int iproute_get(int argc, char **argv) | 669 | static int iproute_get(char **argv) |
671 | { | 670 | { |
672 | struct rtnl_handle rth; | 671 | struct rtnl_handle rth; |
673 | struct { | 672 | struct { |
@@ -698,7 +697,7 @@ static int iproute_get(int argc, char **argv) | |||
698 | req.r.rtm_dst_len = 0; | 697 | req.r.rtm_dst_len = 0; |
699 | req.r.rtm_tos = 0; | 698 | req.r.rtm_tos = 0; |
700 | 699 | ||
701 | while (argc > 0) { | 700 | while (*argv) { |
702 | switch (index_in_strings(options, *argv)) { | 701 | switch (index_in_strings(options, *argv)) { |
703 | case 0: /* from */ | 702 | case 0: /* from */ |
704 | { | 703 | { |
@@ -744,7 +743,7 @@ static int iproute_get(int argc, char **argv) | |||
744 | } | 743 | } |
745 | req.r.rtm_dst_len = addr.bitlen; | 744 | req.r.rtm_dst_len = addr.bitlen; |
746 | } | 745 | } |
747 | argc--; argv++; | 746 | argv++; |
748 | } | 747 | } |
749 | } | 748 | } |
750 | 749 | ||
@@ -822,7 +821,7 @@ static int iproute_get(int argc, char **argv) | |||
822 | } | 821 | } |
823 | 822 | ||
824 | /* Return value becomes exitcode. It's okay to not return at all */ | 823 | /* Return value becomes exitcode. It's okay to not return at all */ |
825 | int do_iproute(int argc, char **argv) | 824 | int do_iproute(char **argv) |
826 | { | 825 | { |
827 | static const char ip_route_commands[] ALIGN1 = | 826 | static const char ip_route_commands[] ALIGN1 = |
828 | /*0-3*/ "add\0""append\0""change\0""chg\0" | 827 | /*0-3*/ "add\0""append\0""change\0""chg\0" |
@@ -852,10 +851,10 @@ int do_iproute(int argc, char **argv) | |||
852 | cmd = RTM_DELROUTE; | 851 | cmd = RTM_DELROUTE; |
853 | break; | 852 | break; |
854 | case 5: /* get */ | 853 | case 5: /* get */ |
855 | return iproute_get(argc-1, argv+1); | 854 | return iproute_get(argv+1); |
856 | case 6: /* list */ | 855 | case 6: /* list */ |
857 | case 7: /* show */ | 856 | case 7: /* show */ |
858 | return iproute_list_or_flush(argc-1, argv+1, 0); | 857 | return iproute_list_or_flush(argv+1, 0); |
859 | case 8: /* prepend */ | 858 | case 8: /* prepend */ |
860 | flags = NLM_F_CREATE; | 859 | flags = NLM_F_CREATE; |
861 | break; | 860 | break; |
@@ -866,10 +865,10 @@ int do_iproute(int argc, char **argv) | |||
866 | flags = NLM_F_EXCL; | 865 | flags = NLM_F_EXCL; |
867 | break; | 866 | break; |
868 | case 11: /* flush */ | 867 | case 11: /* flush */ |
869 | return iproute_list_or_flush(argc-1, argv+1, 1); | 868 | return iproute_list_or_flush(argv+1, 1); |
870 | default: | 869 | default: |
871 | bb_error_msg_and_die("unknown command %s", *argv); | 870 | bb_error_msg_and_die("unknown command %s", *argv); |
872 | } | 871 | } |
873 | 872 | ||
874 | return iproute_modify(cmd, flags, argc-1, argv+1); | 873 | return iproute_modify(cmd, flags, argv+1); |
875 | } | 874 | } |