~vcs-imports/busybox/trunk

« back to all changes in this revision

Viewing changes to networking/tc.c

  • Committer: Denys Vlasenko
  • Author(s): Christian Franke
  • Date: 2023-11-13 10:32:35 UTC
  • Revision ID: git-v1:a63b60bdd6fa26b867c80d44074118babbae7ffd
Cygwin: regenerate defconfig

Signed-off-by: Christian Franke <christian.franke@t-online.de>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
#if 0 /* IMPOSSIBLE */
112
112
        if (cid == TC_H_ROOT)
113
113
                return xasprintf("root");
114
 
        else
115
114
#endif
116
115
        if (cid == TC_H_UNSPEC)
117
116
                return xasprintf("none");
118
 
        else if (TC_H_MAJ(cid) == 0)
 
117
        if (TC_H_MAJ(cid) == 0)
119
118
                return xasprintf(":%x", TC_H_MIN(cid));
120
 
        else if (TC_H_MIN(cid) == 0)
 
119
        if (TC_H_MIN(cid) == 0)
121
120
                return xasprintf("%x:", TC_H_MAJ(cid)>>16);
122
 
        else
123
 
                return xasprintf("%x:%x", TC_H_MAJ(cid)>>16, TC_H_MIN(cid));
 
121
        return xasprintf("%x:%x", TC_H_MAJ(cid)>>16, TC_H_MIN(cid));
124
122
}
125
123
 
126
124
/* Get a qdisc handle.  Return 0 on success, !0 otherwise.  */
216
214
                return 0;
217
215
        parse_rtattr_nested_compat(tb, TCA_PRIO_MAX, opt, qopt, sizeof(*qopt));
218
216
        printf("bands %u priomap ", qopt->bands);
219
 
        for (i=0; i<=TC_PRIO_MAX; i++)
 
217
        for (i = 0; i <= TC_PRIO_MAX; i++)
220
218
                printf(" %d", qopt->priomap[i]);
221
219
 
222
220
        if (tb[TCA_PRIO_MQ])
376
374
                        prio_print_opt(tb[TCA_OPTIONS]);
377
375
                } else if (qqq == 1) { /* class based queuing */
378
376
                        cbq_print_opt(tb[TCA_OPTIONS]);
379
 
                } else
380
 
                        bb_error_msg("unknown %s", name);
 
377
                } else {
 
378
                        /* don't know how to print options for this qdisc */
 
379
                        printf("(options for %s)", name);
 
380
                }
381
381
        }
382
382
        bb_putchar('\n');
383
383
        return 0;
405
405
                return -1;
406
406
        }
407
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
409
                return 0;
410
410
        memset (tb, 0, sizeof(tb));
411
411
        parse_rtattr(tb, TCA_MAX, TCA_RTA(msg), len);
418
418
 
419
419
        name = (char*)RTA_DATA(tb[TCA_KIND]);
420
420
        classid = !msg->tcm_handle ? NULL : print_tc_classid(
421
 
                                filter_qdisc ? TC_H_MIN(msg->tcm_parent) : msg->tcm_parent);
422
 
        printf ("class %s %s", name, classid);
 
421
                                filter_qdisc ? TC_H_MIN(msg->tcm_handle) : msg->tcm_handle);
 
422
        printf ("class %s %s ", name, classid);
423
423
        if (ENABLE_FEATURE_CLEAN_UP)
424
424
                free(classid);
425
425
 
445
445
                } else if (qqq == 1) { /* class based queuing */
446
446
                        /* cbq_print_copt() is identical to cbq_print_opt(). */
447
447
                        cbq_print_opt(tb[TCA_OPTIONS]);
448
 
                } else
449
 
                        bb_error_msg("unknown %s", name);
 
448
                } else {
 
449
                        /* don't know how to print options for this class */
 
450
                        printf("(options for %s)", name);
 
451
                }
450
452
        }
451
453
        bb_putchar('\n');
452
454
 
500
502
        };
501
503
        struct rtnl_handle rth;
502
504
        struct tcmsg msg;
503
 
        int ret, obj, cmd, arg;
 
505
        int obj, cmd, arg;
504
506
        char *dev = NULL;
505
507
 
506
508
        INIT_G();
508
510
        if (!*++argv)
509
511
                bb_show_usage();
510
512
        xrtnl_open(&rth);
511
 
        ret = EXIT_SUCCESS;
512
513
 
513
514
        obj = index_in_substrings(objects, *argv++);
514
 
 
515
515
        if (obj < 0)
516
516
                bb_show_usage();
517
 
        if (!*argv)
518
 
                cmd = CMD_show; /* list is the default */
519
 
        else {
 
517
 
 
518
        cmd = CMD_show; /* list (aka show) is the default */
 
519
        if (*argv) {
520
520
                cmd = index_in_substrings(commands, *argv);
521
521
                if (cmd < 0)
522
522
                        invarg_1_to_2(*argv, argv[-1]);
538
538
                        msg.tcm_ifindex = xll_name_to_index(dev);
539
539
                        if (cmd >= CMD_show)
540
540
                                filter_ifindex = msg.tcm_ifindex;
541
 
                } else
542
 
                if ((arg == ARG_qdisc && obj == OBJ_class && cmd >= CMD_show)
543
 
                 || (arg == ARG_handle && obj == OBJ_qdisc && cmd == CMD_change)
 
541
                        continue;
 
542
                }
 
543
                if ((arg == ARG_qdisc && obj == OBJ_class && cmd >= CMD_show)    /* tc class show|list qdisc HANDLE */
 
544
                 || (arg == ARG_handle && obj == OBJ_qdisc && cmd == CMD_change) /* tc qdisc change handle HANDLE */
544
545
                ) {
545
546
                        NEXT_ARG();
546
547
                        /* We don't care about duparg2("qdisc handle",*argv) for now */
547
548
                        if (get_qdisc_handle(&filter_qdisc, *argv))
548
549
                                invarg_1_to_2(*argv, "qdisc");
549
550
                } else
550
 
                if (obj != OBJ_qdisc
 
551
                if (obj != OBJ_qdisc /* tc class|filter root|parent | tc filter preference|priority|protocol */
551
552
                 && (arg == ARG_root
552
553
                    || arg == ARG_parent
553
554
                    || (obj == OBJ_filter && arg >= ARG_pref)
623
624
        if (ENABLE_FEATURE_CLEAN_UP) {
624
625
                rtnl_close(&rth);
625
626
        }
626
 
        return ret;
 
627
        return EXIT_SUCCESS;
627
628
}