~ubuntu-branches/ubuntu/karmic/iproute/karmic

« back to all changes in this revision

Viewing changes to tc/tc_qdisc.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Henriksson
  • Date: 2009-03-26 12:36:10 UTC
  • mfrom: (1.1.8 upstream) (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090326123610-00avh089ttrj5bsg
Tags: 20090324-1
* New upstream release v2.6.29-1 (includes "Fix headers needed for gre")
  - fixed to link against xtables rather then ipt. (Closes: #510924)
* Make sure clean drops any potential left-over files from WRR qdisc patch.
* Bump standards version to policy 3.8.1, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <arpa/inet.h>
21
21
#include <string.h>
22
22
#include <math.h>
 
23
#include <malloc.h>
23
24
 
24
25
#include "utils.h"
25
26
#include "tc_util.h"
32
33
        fprintf(stderr, "Usage: tc qdisc [ add | del | replace | change | show ] dev STRING\n");
33
34
        fprintf(stderr, "       [ handle QHANDLE ] [ root | ingress | parent CLASSID ]\n");
34
35
        fprintf(stderr, "       [ estimator INTERVAL TIME_CONSTANT ]\n");
 
36
        fprintf(stderr, "       [ stab [ help | STAB_OPTIONS] ]\n");
35
37
        fprintf(stderr, "       [ [ QDISC_KIND ] [ help | OPTIONS ] ]\n");
36
38
        fprintf(stderr, "\n");
37
39
        fprintf(stderr, "       tc qdisc show [ dev STRING ] [ingress]\n");
38
40
        fprintf(stderr, "Where:\n");
39
41
        fprintf(stderr, "QDISC_KIND := { [p|b]fifo | tbf | prio | cbq | red | etc. }\n");
40
42
        fprintf(stderr, "OPTIONS := ... try tc qdisc add <desired QDISC_KIND> help\n");
 
43
        fprintf(stderr, "STAB_OPTIONS := ... try tc qdisc add stab help\n");
41
44
        return -1;
42
45
}
43
46
 
45
48
{
46
49
        struct qdisc_util *q = NULL;
47
50
        struct tc_estimator est;
 
51
        struct {
 
52
                struct tc_sizespec      szopts;
 
53
                __u16                   *data;
 
54
        } stab;
48
55
        char  d[16];
49
56
        char  k[16];
50
57
        struct {
54
61
        } req;
55
62
 
56
63
        memset(&req, 0, sizeof(req));
 
64
        memset(&stab, 0, sizeof(stab));
57
65
        memset(&est, 0, sizeof(est));
58
66
        memset(&d, 0, sizeof(d));
59
67
        memset(&k, 0, sizeof(k));
108
116
                } else if (matches(*argv, "estimator") == 0) {
109
117
                        if (parse_estimator(&argc, &argv, &est))
110
118
                                return -1;
 
119
                } else if (matches(*argv, "stab") == 0) {
 
120
                        if (parse_size_table(&argc, &argv, &stab.szopts) < 0)
 
121
                                return -1;
 
122
                        continue;
111
123
                } else if (matches(*argv, "help") == 0) {
112
124
                        usage();
113
125
                } else {
142
154
                }
143
155
        }
144
156
 
 
157
        if (check_size_table_opts(&stab.szopts)) {
 
158
                struct rtattr *tail;
 
159
 
 
160
                if (tc_calc_size_table(&stab.szopts, &stab.data) < 0) {
 
161
                        fprintf(stderr, "failed to calculate size table.\n");
 
162
                        return -1;
 
163
                }
 
164
 
 
165
                tail = NLMSG_TAIL(&req.n);
 
166
                addattr_l(&req.n, sizeof(req), TCA_STAB, NULL, 0);
 
167
                addattr_l(&req.n, sizeof(req), TCA_STAB_BASE, &stab.szopts,
 
168
                          sizeof(stab.szopts));
 
169
                if (stab.data)
 
170
                        addattr_l(&req.n, sizeof(req), TCA_STAB_DATA, stab.data,
 
171
                                  stab.szopts.tsize * sizeof(__u16));
 
172
                tail->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail;
 
173
                if (stab.data)
 
174
                        free(stab.data);
 
175
        }
 
176
 
145
177
        if (d[0])  {
146
178
                int idx;
147
179
 
223
255
                        fprintf(fp, "[cannot parse qdisc parameters]");
224
256
        }
225
257
        fprintf(fp, "\n");
 
258
        if (show_details && tb[TCA_STAB]) {
 
259
                print_size_table(fp, " ", tb[TCA_STAB]);
 
260
                fprintf(fp, "\n");
 
261
        }
226
262
        if (show_stats) {
227
263
                struct rtattr *xstats = NULL;
228
264