osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 1 | /* |
| 2 | * m_police.c Parse/print policing module options. |
| 3 | * |
| 4 | * This program is free software; you can u32istribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; either version |
| 7 | * 2 of the License, or (at your option) any later version. |
| 8 | * |
| 9 | * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> |
Stephen Hemminger | ae665a5 | 2006-12-05 10:10:22 -0800 | [diff] [blame] | 10 | * FIXES: 19990619 - J Hadi Salim (hadi@cyberus.ca) |
| 11 | * simple addattr packaging fix. |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 12 | * 2002: J Hadi Salim - Add tc action extensions syntax |
| 13 | * |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include <stdio.h> |
| 17 | #include <stdlib.h> |
| 18 | #include <unistd.h> |
| 19 | #include <syslog.h> |
| 20 | #include <fcntl.h> |
| 21 | #include <sys/socket.h> |
| 22 | #include <netinet/in.h> |
| 23 | #include <arpa/inet.h> |
| 24 | #include <string.h> |
| 25 | |
| 26 | #include "utils.h" |
| 27 | #include "tc_util.h" |
| 28 | |
net[shemminger]!kaber | 95812b5 | 2004-09-28 18:35:49 +0000 | [diff] [blame] | 29 | struct action_util police_action_util = { |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 30 | .id = "police", |
| 31 | .parse_aopt = act_parse_police, |
| 32 | .print_aopt = print_police, |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
Jamal Hadi Salim | ebf3208 | 2006-08-08 12:10:08 -0700 | [diff] [blame] | 35 | static void usage(void) |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 36 | { |
| 37 | fprintf(stderr, "Usage: ... police rate BPS burst BYTES[/BYTES] [ mtu BYTES[/BYTES] ]\n"); |
Jesper Dangaard Brouer | f71f75f | 2008-03-23 23:53:57 +0100 | [diff] [blame^] | 38 | fprintf(stderr, " [ peakrate BPS ] [ avrate BPS ] [ overhead BYTES ]\n"); |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 39 | fprintf(stderr, " [ ACTIONTERM ]\n"); |
Stephen Hemminger | ef1d6f9 | 2008-01-02 16:34:58 -0800 | [diff] [blame] | 40 | fprintf(stderr, "Old Syntax ACTIONTERM := action <EXCEEDACT>[/NOTEXCEEDACT] \n"); |
Stephen Hemminger | ae665a5 | 2006-12-05 10:10:22 -0800 | [diff] [blame] | 41 | fprintf(stderr, "New Syntax ACTIONTERM := conform-exceed <EXCEEDACT>[/NOTEXCEEDACT] \n"); |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 42 | fprintf(stderr, "Where: *EXCEEDACT := pipe | ok | reclassify | drop | continue \n"); |
| 43 | fprintf(stderr, "Where: pipe is only valid for new syntax \n"); |
Jamal Hadi Salim | ebf3208 | 2006-08-08 12:10:08 -0700 | [diff] [blame] | 44 | exit(-1); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | static void explain1(char *arg) |
| 48 | { |
| 49 | fprintf(stderr, "Illegal \"%s\"\n", arg); |
| 50 | } |
| 51 | |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 52 | char *police_action_n2a(int action, char *buf, int len) |
| 53 | { |
| 54 | switch (action) { |
| 55 | case -1: |
| 56 | return "continue"; |
| 57 | break; |
| 58 | case TC_POLICE_OK: |
| 59 | return "pass"; |
| 60 | break; |
| 61 | case TC_POLICE_SHOT: |
| 62 | return "drop"; |
| 63 | break; |
| 64 | case TC_POLICE_RECLASSIFY: |
| 65 | return "reclassify"; |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 66 | case TC_POLICE_PIPE: |
| 67 | return "pipe"; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 68 | default: |
| 69 | snprintf(buf, len, "%d", action); |
| 70 | return buf; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | int police_action_a2n(char *arg, int *result) |
| 75 | { |
| 76 | int res; |
| 77 | |
| 78 | if (matches(arg, "continue") == 0) |
| 79 | res = -1; |
| 80 | else if (matches(arg, "drop") == 0) |
| 81 | res = TC_POLICE_SHOT; |
| 82 | else if (matches(arg, "shot") == 0) |
| 83 | res = TC_POLICE_SHOT; |
| 84 | else if (matches(arg, "pass") == 0) |
| 85 | res = TC_POLICE_OK; |
| 86 | else if (strcmp(arg, "ok") == 0) |
| 87 | res = TC_POLICE_OK; |
| 88 | else if (matches(arg, "reclassify") == 0) |
| 89 | res = TC_POLICE_RECLASSIFY; |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 90 | else if (matches(arg, "pipe") == 0) |
| 91 | res = TC_POLICE_PIPE; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 92 | else { |
| 93 | char dummy; |
| 94 | if (sscanf(arg, "%d%c", &res, &dummy) != 1) |
| 95 | return -1; |
| 96 | } |
| 97 | *result = res; |
| 98 | return 0; |
| 99 | } |
| 100 | |
| 101 | |
| 102 | int get_police_result(int *action, int *result, char *arg) |
| 103 | { |
| 104 | char *p = strchr(arg, '/'); |
| 105 | |
| 106 | if (p) |
| 107 | *p = 0; |
| 108 | |
| 109 | if (police_action_a2n(arg, action)) { |
| 110 | if (p) |
| 111 | *p = '/'; |
| 112 | return -1; |
| 113 | } |
| 114 | |
| 115 | if (p) { |
| 116 | *p = '/'; |
| 117 | if (police_action_a2n(p+1, result)) |
| 118 | return -1; |
| 119 | } |
| 120 | return 0; |
| 121 | } |
| 122 | |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 123 | |
| 124 | int act_parse_police(struct action_util *a,int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n) |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 125 | { |
| 126 | int argc = *argc_p; |
| 127 | char **argv = *argv_p; |
| 128 | int res = -1; |
| 129 | int ok=0; |
| 130 | struct tc_police p; |
| 131 | __u32 rtab[256]; |
| 132 | __u32 ptab[256]; |
| 133 | __u32 avrate = 0; |
| 134 | int presult = 0; |
| 135 | unsigned buffer=0, mtu=0, mpu=0; |
Jesper Dangaard Brouer | f71f75f | 2008-03-23 23:53:57 +0100 | [diff] [blame^] | 136 | unsigned short overhead; |
Stephen Hemminger | ae665a5 | 2006-12-05 10:10:22 -0800 | [diff] [blame] | 137 | int Rcell_log=-1, Pcell_log = -1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 138 | struct rtattr *tail; |
| 139 | |
| 140 | memset(&p, 0, sizeof(p)); |
| 141 | p.action = TC_POLICE_RECLASSIFY; |
| 142 | |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 143 | if (a) /* new way of doing things */ |
| 144 | NEXT_ARG(); |
| 145 | |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 146 | if (argc <= 0) |
| 147 | return -1; |
| 148 | |
| 149 | while (argc > 0) { |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 150 | |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 151 | if (matches(*argv, "index") == 0) { |
| 152 | NEXT_ARG(); |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 153 | if (get_u32(&p.index, *argv, 10)) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 154 | fprintf(stderr, "Illegal \"index\"\n"); |
| 155 | return -1; |
| 156 | } |
| 157 | } else if (matches(*argv, "burst") == 0 || |
| 158 | strcmp(*argv, "buffer") == 0 || |
| 159 | strcmp(*argv, "maxburst") == 0) { |
| 160 | NEXT_ARG(); |
| 161 | if (buffer) { |
| 162 | fprintf(stderr, "Double \"buffer/burst\" spec\n"); |
| 163 | return -1; |
| 164 | } |
| 165 | if (get_size_and_cell(&buffer, &Rcell_log, *argv) < 0) { |
| 166 | explain1("buffer"); |
| 167 | return -1; |
| 168 | } |
| 169 | } else if (strcmp(*argv, "mtu") == 0 || |
| 170 | strcmp(*argv, "minburst") == 0) { |
| 171 | NEXT_ARG(); |
| 172 | if (mtu) { |
| 173 | fprintf(stderr, "Double \"mtu/minburst\" spec\n"); |
| 174 | return -1; |
| 175 | } |
| 176 | if (get_size_and_cell(&mtu, &Pcell_log, *argv) < 0) { |
| 177 | explain1("mtu"); |
| 178 | return -1; |
| 179 | } |
| 180 | } else if (strcmp(*argv, "mpu") == 0) { |
| 181 | NEXT_ARG(); |
| 182 | if (mpu) { |
| 183 | fprintf(stderr, "Double \"mpu\" spec\n"); |
| 184 | return -1; |
| 185 | } |
| 186 | if (get_size(&mpu, *argv)) { |
| 187 | explain1("mpu"); |
| 188 | return -1; |
| 189 | } |
| 190 | } else if (strcmp(*argv, "rate") == 0) { |
| 191 | NEXT_ARG(); |
| 192 | if (p.rate.rate) { |
| 193 | fprintf(stderr, "Double \"rate\" spec\n"); |
| 194 | return -1; |
| 195 | } |
| 196 | if (get_rate(&p.rate.rate, *argv)) { |
| 197 | explain1("rate"); |
| 198 | return -1; |
| 199 | } |
| 200 | } else if (strcmp(*argv, "avrate") == 0) { |
| 201 | NEXT_ARG(); |
| 202 | if (avrate) { |
| 203 | fprintf(stderr, "Double \"avrate\" spec\n"); |
| 204 | return -1; |
| 205 | } |
| 206 | if (get_rate(&avrate, *argv)) { |
| 207 | explain1("avrate"); |
| 208 | return -1; |
| 209 | } |
| 210 | } else if (matches(*argv, "peakrate") == 0) { |
| 211 | NEXT_ARG(); |
| 212 | if (p.peakrate.rate) { |
| 213 | fprintf(stderr, "Double \"peakrate\" spec\n"); |
| 214 | return -1; |
| 215 | } |
| 216 | if (get_rate(&p.peakrate.rate, *argv)) { |
| 217 | explain1("peakrate"); |
| 218 | return -1; |
| 219 | } |
| 220 | } else if (matches(*argv, "reclassify") == 0) { |
| 221 | p.action = TC_POLICE_RECLASSIFY; |
| 222 | } else if (matches(*argv, "drop") == 0 || |
| 223 | matches(*argv, "shot") == 0) { |
| 224 | p.action = TC_POLICE_SHOT; |
| 225 | } else if (matches(*argv, "continue") == 0) { |
| 226 | p.action = TC_POLICE_UNSPEC; |
| 227 | } else if (matches(*argv, "pass") == 0) { |
| 228 | p.action = TC_POLICE_OK; |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 229 | } else if (matches(*argv, "pipe") == 0) { |
| 230 | p.action = TC_POLICE_PIPE; |
Patrick McHardy | c29391c | 2007-07-18 12:46:20 +0200 | [diff] [blame] | 231 | } else if (strcmp(*argv, "action") == 0 || |
| 232 | strcmp(*argv, "conform-exceed") == 0) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 233 | NEXT_ARG(); |
| 234 | if (get_police_result(&p.action, &presult, *argv)) { |
| 235 | fprintf(stderr, "Illegal \"action\"\n"); |
| 236 | return -1; |
| 237 | } |
Jesper Dangaard Brouer | f71f75f | 2008-03-23 23:53:57 +0100 | [diff] [blame^] | 238 | } else if (matches(*argv, "overhead") == 0) { |
| 239 | NEXT_ARG(); |
| 240 | if (get_u16(&overhead, *argv, 10)) { |
| 241 | explain1("overhead"); return -1; |
| 242 | } |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 243 | } else if (strcmp(*argv, "help") == 0) { |
Jamal Hadi Salim | ebf3208 | 2006-08-08 12:10:08 -0700 | [diff] [blame] | 244 | usage(); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 245 | } else { |
Stephen Hemminger | ef1d6f9 | 2008-01-02 16:34:58 -0800 | [diff] [blame] | 246 | break; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 247 | } |
| 248 | ok++; |
| 249 | argc--; argv++; |
| 250 | } |
| 251 | |
| 252 | if (!ok) |
| 253 | return -1; |
| 254 | |
| 255 | if (p.rate.rate && !buffer) { |
| 256 | fprintf(stderr, "\"burst\" requires \"rate\".\n"); |
| 257 | return -1; |
| 258 | } |
| 259 | if (p.peakrate.rate) { |
| 260 | if (!p.rate.rate) { |
| 261 | fprintf(stderr, "\"peakrate\" requires \"rate\".\n"); |
| 262 | return -1; |
| 263 | } |
| 264 | if (!mtu) { |
| 265 | fprintf(stderr, "\"mtu\" is required, if \"peakrate\" is requested.\n"); |
| 266 | return -1; |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | if (p.rate.rate) { |
Jesper Dangaard Brouer | d5f46f9 | 2007-09-05 10:47:47 +0200 | [diff] [blame] | 271 | p.rate.mpu = mpu; |
Jesper Dangaard Brouer | f71f75f | 2008-03-23 23:53:57 +0100 | [diff] [blame^] | 272 | p.rate.overhead = overhead; |
Jesper Dangaard Brouer | d5f46f9 | 2007-09-05 10:47:47 +0200 | [diff] [blame] | 273 | if (tc_calc_rtable(&p.rate, rtab, Rcell_log, mtu) < 0) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 274 | fprintf(stderr, "TBF: failed to calculate rate table.\n"); |
| 275 | return -1; |
| 276 | } |
| 277 | p.burst = tc_calc_xmittime(p.rate.rate, buffer); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 278 | } |
| 279 | p.mtu = mtu; |
| 280 | if (p.peakrate.rate) { |
Jesper Dangaard Brouer | d5f46f9 | 2007-09-05 10:47:47 +0200 | [diff] [blame] | 281 | p.peakrate.mpu = mpu; |
Jesper Dangaard Brouer | f71f75f | 2008-03-23 23:53:57 +0100 | [diff] [blame^] | 282 | p.peakrate.overhead = overhead; |
Jesper Dangaard Brouer | d5f46f9 | 2007-09-05 10:47:47 +0200 | [diff] [blame] | 283 | if (tc_calc_rtable(&p.peakrate, ptab, Pcell_log, mtu) < 0) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 284 | fprintf(stderr, "POLICE: failed to calculate peak rate table.\n"); |
| 285 | return -1; |
| 286 | } |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 287 | } |
| 288 | |
6!tgraf | 1b52a76 | 2005-01-18 01:24:18 +0000 | [diff] [blame] | 289 | tail = NLMSG_TAIL(n); |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 290 | addattr_l(n, MAX_MSG, tca_id, NULL, 0); |
| 291 | addattr_l(n, MAX_MSG, TCA_POLICE_TBF, &p, sizeof(p)); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 292 | if (p.rate.rate) |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 293 | addattr_l(n, MAX_MSG, TCA_POLICE_RATE, rtab, 1024); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 294 | if (p.peakrate.rate) |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 295 | addattr_l(n, MAX_MSG, TCA_POLICE_PEAKRATE, ptab, 1024); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 296 | if (avrate) |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 297 | addattr32(n, MAX_MSG, TCA_POLICE_AVRATE, avrate); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 298 | if (presult) |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 299 | addattr32(n, MAX_MSG, TCA_POLICE_RESULT, presult); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 300 | |
6!tgraf | 1b52a76 | 2005-01-18 01:24:18 +0000 | [diff] [blame] | 301 | tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 302 | res = 0; |
| 303 | |
| 304 | *argc_p = argc; |
| 305 | *argv_p = argv; |
| 306 | return res; |
| 307 | } |
| 308 | |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 309 | int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n) |
| 310 | { |
| 311 | return act_parse_police(NULL,argc_p,argv_p,tca_id,n); |
| 312 | } |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 313 | |
Stephen Hemminger | ae665a5 | 2006-12-05 10:10:22 -0800 | [diff] [blame] | 314 | int |
osdl.net!shemminger | f2f99e2 | 2004-08-31 17:45:21 +0000 | [diff] [blame] | 315 | print_police(struct action_util *a, FILE *f, struct rtattr *arg) |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 316 | { |
| 317 | SPRINT_BUF(b1); |
| 318 | struct tc_police *p; |
| 319 | struct rtattr *tb[TCA_POLICE_MAX+1]; |
| 320 | unsigned buffer; |
| 321 | |
| 322 | if (arg == NULL) |
| 323 | return 0; |
| 324 | |
6!tgraf | 14ee9e6 | 2005-01-18 22:11:58 +0000 | [diff] [blame] | 325 | parse_rtattr_nested(tb, TCA_POLICE_MAX, arg); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 326 | |
| 327 | if (tb[TCA_POLICE_TBF] == NULL) { |
| 328 | fprintf(f, "[NULL police tbf]"); |
| 329 | return 0; |
| 330 | } |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 331 | #ifndef STOOPID_8BYTE |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 332 | if (RTA_PAYLOAD(tb[TCA_POLICE_TBF]) < sizeof(*p)) { |
| 333 | fprintf(f, "[truncated police tbf]"); |
| 334 | return -1; |
| 335 | } |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 336 | #endif |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 337 | p = RTA_DATA(tb[TCA_POLICE_TBF]); |
| 338 | |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 339 | fprintf(f, " police 0x%x ", p->index); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 340 | fprintf(f, "rate %s ", sprint_rate(p->rate.rate, b1)); |
Patrick McHardy | 76dc0aa | 2007-03-04 20:14:57 +0100 | [diff] [blame] | 341 | buffer = tc_calc_xmitsize(p->rate.rate, p->burst); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 342 | fprintf(f, "burst %s ", sprint_size(buffer, b1)); |
| 343 | fprintf(f, "mtu %s ", sprint_size(p->mtu, b1)); |
| 344 | if (show_raw) |
| 345 | fprintf(f, "[%08x] ", p->burst); |
| 346 | if (p->peakrate.rate) |
| 347 | fprintf(f, "peakrate %s ", sprint_rate(p->peakrate.rate, b1)); |
| 348 | if (tb[TCA_POLICE_AVRATE]) |
| 349 | fprintf(f, "avrate %s ", sprint_rate(*(__u32*)RTA_DATA(tb[TCA_POLICE_AVRATE]), b1)); |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 350 | fprintf(f, "action %s", police_action_n2a(p->action, b1, sizeof(b1))); |
| 351 | if (tb[TCA_POLICE_RESULT]) { |
| 352 | fprintf(f, "/%s ", police_action_n2a(*(int*)RTA_DATA(tb[TCA_POLICE_RESULT]), b1, sizeof(b1))); |
| 353 | } else |
| 354 | fprintf(f, " "); |
Jesper Dangaard Brouer | f71f75f | 2008-03-23 23:53:57 +0100 | [diff] [blame^] | 355 | fprintf(f, "overhead %ub ", p->rate.overhead); |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 356 | fprintf(f, "\nref %d bind %d\n",p->refcnt, p->bindcnt); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 357 | |
| 358 | return 0; |
| 359 | } |
| 360 | |
Stephen Hemminger | ae665a5 | 2006-12-05 10:10:22 -0800 | [diff] [blame] | 361 | int |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 362 | tc_print_police(FILE *f, struct rtattr *arg) { |
net[shemminger]!kaber | 95812b5 | 2004-09-28 18:35:49 +0000 | [diff] [blame] | 363 | return print_police(&police_action_util,f,arg); |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 364 | } |