diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-11 14:50:04 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-07-11 14:50:04 +0200 |
| commit | f5f336e787fd8367d24de5fe3b341ebffb74c2c2 (patch) | |
| tree | 513104ab2332a6db50471d82b99a5cc600c2170d | |
| parent | 39aabfe8f033c9c62acf676b660dc979714d26a7 (diff) | |
| download | busybox-w32-f5f336e787fd8367d24de5fe3b341ebffb74c2c2.tar.gz busybox-w32-f5f336e787fd8367d24de5fe3b341ebffb74c2c2.tar.bz2 busybox-w32-f5f336e787fd8367d24de5fe3b341ebffb74c2c2.zip | |
tc: fix for parsing of "dev IFACE" and printing of "class list"
First part (parsing fix) is from Steffen Nurpmeso <steffen@sdaoden.eu>
function old new delta
.rodata 104120 104138 +18
print_qdisc 469 464 -5
tc_main 980 969 -11
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 18/-16) Total: 2 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | networking/tc.c | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/networking/tc.c b/networking/tc.c index 510684443..46ad23d8b 100644 --- a/networking/tc.c +++ b/networking/tc.c | |||
| @@ -111,16 +111,14 @@ static char* print_tc_classid(uint32_t cid) | |||
| 111 | #if 0 /* IMPOSSIBLE */ | 111 | #if 0 /* IMPOSSIBLE */ |
| 112 | if (cid == TC_H_ROOT) | 112 | if (cid == TC_H_ROOT) |
| 113 | return xasprintf("root"); | 113 | return xasprintf("root"); |
| 114 | else | ||
| 115 | #endif | 114 | #endif |
| 116 | if (cid == TC_H_UNSPEC) | 115 | if (cid == TC_H_UNSPEC) |
| 117 | return xasprintf("none"); | 116 | return xasprintf("none"); |
| 118 | else if (TC_H_MAJ(cid) == 0) | 117 | if (TC_H_MAJ(cid) == 0) |
| 119 | return xasprintf(":%x", TC_H_MIN(cid)); | 118 | return xasprintf(":%x", TC_H_MIN(cid)); |
| 120 | else if (TC_H_MIN(cid) == 0) | 119 | if (TC_H_MIN(cid) == 0) |
| 121 | return xasprintf("%x:", TC_H_MAJ(cid)>>16); | 120 | return xasprintf("%x:", TC_H_MAJ(cid)>>16); |
| 122 | else | 121 | return xasprintf("%x:%x", TC_H_MAJ(cid)>>16, TC_H_MIN(cid)); |
| 123 | return xasprintf("%x:%x", TC_H_MAJ(cid)>>16, TC_H_MIN(cid)); | ||
| 124 | } | 122 | } |
| 125 | 123 | ||
| 126 | /* Get a qdisc handle. Return 0 on success, !0 otherwise. */ | 124 | /* Get a qdisc handle. Return 0 on success, !0 otherwise. */ |
| @@ -376,8 +374,10 @@ static FAST_FUNC int print_qdisc( | |||
| 376 | prio_print_opt(tb[TCA_OPTIONS]); | 374 | prio_print_opt(tb[TCA_OPTIONS]); |
| 377 | } else if (qqq == 1) { /* class based queuing */ | 375 | } else if (qqq == 1) { /* class based queuing */ |
| 378 | cbq_print_opt(tb[TCA_OPTIONS]); | 376 | cbq_print_opt(tb[TCA_OPTIONS]); |
| 379 | } else | 377 | } else { |
| 380 | bb_error_msg("unknown %s", name); | 378 | /* don't know how to print options for this qdisc */ |
| 379 | printf("(options for %s)", name); | ||
| 380 | } | ||
| 381 | } | 381 | } |
| 382 | bb_putchar('\n'); | 382 | bb_putchar('\n'); |
| 383 | return 0; | 383 | return 0; |
| @@ -405,7 +405,7 @@ static FAST_FUNC int print_class( | |||
| 405 | return -1; | 405 | return -1; |
| 406 | } | 406 | } |
| 407 | /* not the desired interface? */ | 407 | /* not the desired interface? */ |
| 408 | if (filter_qdisc && TC_H_MAJ(msg->tcm_handle^filter_qdisc)) | 408 | if (filter_qdisc && TC_H_MAJ(msg->tcm_handle ^ filter_qdisc)) |
| 409 | return 0; | 409 | return 0; |
| 410 | memset (tb, 0, sizeof(tb)); | 410 | memset (tb, 0, sizeof(tb)); |
| 411 | parse_rtattr(tb, TCA_MAX, TCA_RTA(msg), len); | 411 | parse_rtattr(tb, TCA_MAX, TCA_RTA(msg), len); |
| @@ -418,8 +418,8 @@ static FAST_FUNC int print_class( | |||
| 418 | 418 | ||
| 419 | name = (char*)RTA_DATA(tb[TCA_KIND]); | 419 | name = (char*)RTA_DATA(tb[TCA_KIND]); |
| 420 | classid = !msg->tcm_handle ? NULL : print_tc_classid( | 420 | classid = !msg->tcm_handle ? NULL : print_tc_classid( |
| 421 | filter_qdisc ? TC_H_MIN(msg->tcm_parent) : msg->tcm_parent); | 421 | filter_qdisc ? TC_H_MIN(msg->tcm_handle) : msg->tcm_handle); |
| 422 | printf ("class %s %s", name, classid); | 422 | printf ("class %s %s ", name, classid); |
| 423 | if (ENABLE_FEATURE_CLEAN_UP) | 423 | if (ENABLE_FEATURE_CLEAN_UP) |
| 424 | free(classid); | 424 | free(classid); |
| 425 | 425 | ||
| @@ -445,8 +445,10 @@ static FAST_FUNC int print_class( | |||
| 445 | } else if (qqq == 1) { /* class based queuing */ | 445 | } else if (qqq == 1) { /* class based queuing */ |
| 446 | /* cbq_print_copt() is identical to cbq_print_opt(). */ | 446 | /* cbq_print_copt() is identical to cbq_print_opt(). */ |
| 447 | cbq_print_opt(tb[TCA_OPTIONS]); | 447 | cbq_print_opt(tb[TCA_OPTIONS]); |
| 448 | } else | 448 | } else { |
| 449 | bb_error_msg("unknown %s", name); | 449 | /* don't know how to print options for this class */ |
| 450 | printf("(options for %s)", name); | ||
| 451 | } | ||
| 450 | } | 452 | } |
| 451 | bb_putchar('\n'); | 453 | bb_putchar('\n'); |
| 452 | 454 | ||
| @@ -511,12 +513,11 @@ int tc_main(int argc UNUSED_PARAM, char **argv) | |||
| 511 | ret = EXIT_SUCCESS; | 513 | ret = EXIT_SUCCESS; |
| 512 | 514 | ||
| 513 | obj = index_in_substrings(objects, *argv++); | 515 | obj = index_in_substrings(objects, *argv++); |
| 514 | |||
| 515 | if (obj < 0) | 516 | if (obj < 0) |
| 516 | bb_show_usage(); | 517 | bb_show_usage(); |
| 517 | if (!*argv) | 518 | |
| 518 | cmd = CMD_show; /* list is the default */ | 519 | cmd = CMD_show; /* list (aka show) is the default */ |
| 519 | else { | 520 | if (*argv) { |
| 520 | cmd = index_in_substrings(commands, *argv); | 521 | cmd = index_in_substrings(commands, *argv); |
| 521 | if (cmd < 0) | 522 | if (cmd < 0) |
| 522 | invarg_1_to_2(*argv, argv[-1]); | 523 | invarg_1_to_2(*argv, argv[-1]); |
| @@ -538,16 +539,17 @@ int tc_main(int argc UNUSED_PARAM, char **argv) | |||
| 538 | msg.tcm_ifindex = xll_name_to_index(dev); | 539 | msg.tcm_ifindex = xll_name_to_index(dev); |
| 539 | if (cmd >= CMD_show) | 540 | if (cmd >= CMD_show) |
| 540 | filter_ifindex = msg.tcm_ifindex; | 541 | filter_ifindex = msg.tcm_ifindex; |
| 541 | } else | 542 | continue; |
| 542 | if ((arg == ARG_qdisc && obj == OBJ_class && cmd >= CMD_show) | 543 | } |
| 543 | || (arg == ARG_handle && obj == OBJ_qdisc && cmd == CMD_change) | 544 | if ((arg == ARG_qdisc && obj == OBJ_class && cmd >= CMD_show) /* tc class show|list qdisc HANDLE */ |
| 545 | || (arg == ARG_handle && obj == OBJ_qdisc && cmd == CMD_change) /* tc qdisc change handle HANDLE */ | ||
| 544 | ) { | 546 | ) { |
| 545 | NEXT_ARG(); | 547 | NEXT_ARG(); |
| 546 | /* We don't care about duparg2("qdisc handle",*argv) for now */ | 548 | /* We don't care about duparg2("qdisc handle",*argv) for now */ |
| 547 | if (get_qdisc_handle(&filter_qdisc, *argv)) | 549 | if (get_qdisc_handle(&filter_qdisc, *argv)) |
| 548 | invarg_1_to_2(*argv, "qdisc"); | 550 | invarg_1_to_2(*argv, "qdisc"); |
| 549 | } else | 551 | } else |
| 550 | if (obj != OBJ_qdisc | 552 | if (obj != OBJ_qdisc /* tc class|filter root|parent | tc filter preference|priority|protocol */ |
| 551 | && (arg == ARG_root | 553 | && (arg == ARG_root |
| 552 | || arg == ARG_parent | 554 | || arg == ARG_parent |
| 553 | || (obj == OBJ_filter && arg >= ARG_pref) | 555 | || (obj == OBJ_filter && arg >= ARG_pref) |
