osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 1 | /* |
| 2 | * tc_filter.c "tc filter". |
| 3 | * |
| 4 | * This program is free software; you can redistribute 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> |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <stdio.h> |
| 14 | #include <stdlib.h> |
| 15 | #include <unistd.h> |
| 16 | #include <syslog.h> |
| 17 | #include <fcntl.h> |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 18 | #include <sys/socket.h> |
| 19 | #include <netinet/in.h> |
| 20 | #include <arpa/inet.h> |
| 21 | #include <string.h> |
| 22 | #include <linux/if_ether.h> |
| 23 | |
| 24 | #include "rt_names.h" |
| 25 | #include "utils.h" |
| 26 | #include "tc_util.h" |
| 27 | #include "tc_common.h" |
| 28 | |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 29 | static void usage(void); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 30 | |
| 31 | static void usage(void) |
| 32 | { |
Hasso Tepper | e5d179d | 2006-12-10 16:33:05 +0200 | [diff] [blame] | 33 | fprintf(stderr, "Usage: tc filter [ add | del | change | replace | show ] dev STRING\n"); |
Stephen Hemminger | de33a43 | 2008-02-07 19:25:26 -0800 | [diff] [blame] | 34 | fprintf(stderr, " [ pref PRIO ] protocol PROTO\n"); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 35 | fprintf(stderr, " [ estimator INTERVAL TIME_CONSTANT ]\n"); |
| 36 | fprintf(stderr, " [ root | classid CLASSID ] [ handle FILTERID ]\n"); |
| 37 | fprintf(stderr, " [ [ FILTER_TYPE ] [ help | OPTIONS ] ]\n"); |
| 38 | fprintf(stderr, "\n"); |
| 39 | fprintf(stderr, " tc filter show [ dev STRING ] [ root | parent CLASSID ]\n"); |
| 40 | fprintf(stderr, "Where:\n"); |
| 41 | fprintf(stderr, "FILTER_TYPE := { rsvp | u32 | fw | route | etc. }\n"); |
| 42 | fprintf(stderr, "FILTERID := ... format depends on classifier, see there\n"); |
| 43 | fprintf(stderr, "OPTIONS := ... try tc filter add <desired FILTER_KIND> help\n"); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 44 | return; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | |
| 48 | int tc_filter_modify(int cmd, unsigned flags, int argc, char **argv) |
| 49 | { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 50 | struct { |
| 51 | struct nlmsghdr n; |
| 52 | struct tcmsg t; |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 53 | char buf[MAX_MSG]; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 54 | } req; |
| 55 | struct filter_util *q = NULL; |
| 56 | __u32 prio = 0; |
Patrick McHardy | 083a5f0 | 2008-03-26 07:40:03 +0100 | [diff] [blame] | 57 | __u32 protocol = ETH_P_ALL; |
| 58 | int protocol_set = 0; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 59 | char *fhandle = NULL; |
| 60 | char d[16]; |
| 61 | char k[16]; |
| 62 | struct tc_estimator est; |
| 63 | |
| 64 | memset(&req, 0, sizeof(req)); |
| 65 | memset(&est, 0, sizeof(est)); |
| 66 | memset(d, 0, sizeof(d)); |
| 67 | memset(k, 0, sizeof(k)); |
| 68 | memset(&req, 0, sizeof(req)); |
| 69 | |
| 70 | req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); |
| 71 | req.n.nlmsg_flags = NLM_F_REQUEST|flags; |
| 72 | req.n.nlmsg_type = cmd; |
| 73 | req.t.tcm_family = AF_UNSPEC; |
| 74 | |
| 75 | while (argc > 0) { |
| 76 | if (strcmp(*argv, "dev") == 0) { |
| 77 | NEXT_ARG(); |
| 78 | if (d[0]) |
| 79 | duparg("dev", *argv); |
| 80 | strncpy(d, *argv, sizeof(d)-1); |
| 81 | } else if (strcmp(*argv, "root") == 0) { |
| 82 | if (req.t.tcm_parent) { |
| 83 | fprintf(stderr, "Error: \"root\" is duplicate parent ID\n"); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 84 | return -1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 85 | } |
| 86 | req.t.tcm_parent = TC_H_ROOT; |
| 87 | } else if (strcmp(*argv, "parent") == 0) { |
| 88 | __u32 handle; |
| 89 | NEXT_ARG(); |
| 90 | if (req.t.tcm_parent) |
| 91 | duparg("parent", *argv); |
| 92 | if (get_tc_classid(&handle, *argv)) |
| 93 | invarg(*argv, "Invalid parent ID"); |
| 94 | req.t.tcm_parent = handle; |
| 95 | } else if (strcmp(*argv, "handle") == 0) { |
| 96 | NEXT_ARG(); |
| 97 | if (fhandle) |
| 98 | duparg("handle", *argv); |
| 99 | fhandle = *argv; |
| 100 | } else if (matches(*argv, "preference") == 0 || |
| 101 | matches(*argv, "priority") == 0) { |
| 102 | NEXT_ARG(); |
| 103 | if (prio) |
| 104 | duparg("priority", *argv); |
| 105 | if (get_u32(&prio, *argv, 0)) |
Stephen Hemminger | de33a43 | 2008-02-07 19:25:26 -0800 | [diff] [blame] | 106 | invarg(*argv, "invalid priority value"); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 107 | } else if (matches(*argv, "protocol") == 0) { |
| 108 | __u16 id; |
| 109 | NEXT_ARG(); |
Patrick McHardy | 083a5f0 | 2008-03-26 07:40:03 +0100 | [diff] [blame] | 110 | if (protocol_set) |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 111 | duparg("protocol", *argv); |
| 112 | if (ll_proto_a2n(&id, *argv)) |
| 113 | invarg(*argv, "invalid protocol"); |
| 114 | protocol = id; |
Patrick McHardy | 083a5f0 | 2008-03-26 07:40:03 +0100 | [diff] [blame] | 115 | protocol_set = 1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 116 | } else if (matches(*argv, "estimator") == 0) { |
| 117 | if (parse_estimator(&argc, &argv, &est) < 0) |
| 118 | return -1; |
| 119 | } else if (matches(*argv, "help") == 0) { |
| 120 | usage(); |
| 121 | } else { |
| 122 | strncpy(k, *argv, sizeof(k)-1); |
| 123 | |
| 124 | q = get_filter_kind(k); |
| 125 | argc--; argv++; |
| 126 | break; |
| 127 | } |
| 128 | |
| 129 | argc--; argv++; |
| 130 | } |
| 131 | |
| 132 | req.t.tcm_info = TC_H_MAKE(prio<<16, protocol); |
| 133 | |
| 134 | if (k[0]) |
| 135 | addattr_l(&req.n, sizeof(req), TCA_KIND, k, strlen(k)+1); |
| 136 | |
| 137 | if (q) { |
| 138 | if (q->parse_fopt(q, fhandle, argc, argv, &req.n)) |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 139 | return 1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 140 | } else { |
| 141 | if (fhandle) { |
| 142 | fprintf(stderr, "Must specify filter type when using " |
| 143 | "\"handle\"\n"); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 144 | return -1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 145 | } |
| 146 | if (argc) { |
| 147 | if (matches(*argv, "help") == 0) |
| 148 | usage(); |
| 149 | fprintf(stderr, "Garbage instead of arguments \"%s ...\". Try \"tc filter help\".\n", *argv); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 150 | return -1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | if (est.ewma_log) |
| 154 | addattr_l(&req.n, sizeof(req), TCA_RATE, &est, sizeof(est)); |
| 155 | |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 156 | |
| 157 | if (d[0]) { |
osdl.net!shemminger | 7901660 | 2005-03-14 19:34:12 +0000 | [diff] [blame] | 158 | ll_init_map(&rth); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 159 | |
| 160 | if ((req.t.tcm_ifindex = ll_name_to_index(d)) == 0) { |
| 161 | fprintf(stderr, "Cannot find device \"%s\"\n", d); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 162 | return 1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 163 | } |
| 164 | } |
| 165 | |
osdl.net!shemminger | 7901660 | 2005-03-14 19:34:12 +0000 | [diff] [blame] | 166 | if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0) { |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 167 | fprintf(stderr, "We have an error talking to the kernel\n"); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 168 | return 2; |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 169 | } |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 170 | |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 171 | return 0; |
| 172 | } |
| 173 | |
| 174 | static __u32 filter_parent; |
| 175 | static int filter_ifindex; |
| 176 | static __u32 filter_prio; |
| 177 | static __u32 filter_protocol; |
jamal | eefcbc7 | 2008-04-20 10:47:48 -0400 | [diff] [blame^] | 178 | __u16 f_proto = 0; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 179 | |
Jamal Hadi Salim | 5bec348 | 2006-08-08 11:55:15 -0700 | [diff] [blame] | 180 | int print_filter(const struct sockaddr_nl *who, |
Stephen Hemminger | ae665a5 | 2006-12-05 10:10:22 -0800 | [diff] [blame] | 181 | struct nlmsghdr *n, |
osdl.net!shemminger | de48178 | 2004-08-31 17:45:21 +0000 | [diff] [blame] | 182 | void *arg) |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 183 | { |
| 184 | FILE *fp = (FILE*)arg; |
| 185 | struct tcmsg *t = NLMSG_DATA(n); |
| 186 | int len = n->nlmsg_len; |
| 187 | struct rtattr * tb[TCA_MAX+1]; |
| 188 | struct filter_util *q; |
| 189 | char abuf[256]; |
| 190 | |
| 191 | if (n->nlmsg_type != RTM_NEWTFILTER && n->nlmsg_type != RTM_DELTFILTER) { |
| 192 | fprintf(stderr, "Not a filter\n"); |
| 193 | return 0; |
| 194 | } |
| 195 | len -= NLMSG_LENGTH(sizeof(*t)); |
| 196 | if (len < 0) { |
| 197 | fprintf(stderr, "Wrong len %d\n", len); |
| 198 | return -1; |
| 199 | } |
| 200 | |
| 201 | memset(tb, 0, sizeof(tb)); |
| 202 | parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len); |
| 203 | |
| 204 | if (tb[TCA_KIND] == NULL) { |
osdl.net!shemminger | 2373fde | 2004-08-13 23:54:55 +0000 | [diff] [blame] | 205 | fprintf(stderr, "print_filter: NULL kind\n"); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 206 | return -1; |
| 207 | } |
| 208 | |
| 209 | if (n->nlmsg_type == RTM_DELTFILTER) |
| 210 | fprintf(fp, "deleted "); |
| 211 | |
| 212 | fprintf(fp, "filter "); |
| 213 | if (!filter_ifindex || filter_ifindex != t->tcm_ifindex) |
| 214 | fprintf(fp, "dev %s ", ll_index_to_name(t->tcm_ifindex)); |
| 215 | |
| 216 | if (!filter_parent || filter_parent != t->tcm_parent) { |
| 217 | if (t->tcm_parent == TC_H_ROOT) |
| 218 | fprintf(fp, "root "); |
| 219 | else { |
| 220 | print_tc_classid(abuf, sizeof(abuf), t->tcm_parent); |
| 221 | fprintf(fp, "parent %s ", abuf); |
| 222 | } |
| 223 | } |
| 224 | if (t->tcm_info) { |
jamal | eefcbc7 | 2008-04-20 10:47:48 -0400 | [diff] [blame^] | 225 | f_proto = TC_H_MIN(t->tcm_info); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 226 | __u32 prio = TC_H_MAJ(t->tcm_info)>>16; |
jamal | eefcbc7 | 2008-04-20 10:47:48 -0400 | [diff] [blame^] | 227 | if (!filter_protocol || filter_protocol != f_proto) { |
| 228 | if (f_proto) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 229 | SPRINT_BUF(b1); |
| 230 | fprintf(fp, "protocol %s ", |
jamal | eefcbc7 | 2008-04-20 10:47:48 -0400 | [diff] [blame^] | 231 | ll_proto_n2a(f_proto, b1, sizeof(b1))); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | if (!filter_prio || filter_prio != prio) { |
| 235 | if (prio) |
| 236 | fprintf(fp, "pref %u ", prio); |
| 237 | } |
| 238 | } |
| 239 | fprintf(fp, "%s ", (char*)RTA_DATA(tb[TCA_KIND])); |
| 240 | q = get_filter_kind(RTA_DATA(tb[TCA_KIND])); |
| 241 | if (tb[TCA_OPTIONS]) { |
| 242 | if (q) |
| 243 | q->print_fopt(q, fp, tb[TCA_OPTIONS], t->tcm_handle); |
| 244 | else |
| 245 | fprintf(fp, "[cannot parse parameters]"); |
| 246 | } |
| 247 | fprintf(fp, "\n"); |
| 248 | |
ch[shemminger]!tgraf | e5879dc | 2004-12-07 23:52:52 +0000 | [diff] [blame] | 249 | if (show_stats && (tb[TCA_STATS] || tb[TCA_STATS2])) { |
| 250 | print_tcstats_attr(fp, tb, " ", NULL); |
osdl.net!shemminger | de48178 | 2004-08-31 17:45:21 +0000 | [diff] [blame] | 251 | fprintf(fp, "\n"); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 252 | } |
osdl.net!shemminger | de48178 | 2004-08-31 17:45:21 +0000 | [diff] [blame] | 253 | |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 254 | fflush(fp); |
| 255 | return 0; |
| 256 | } |
| 257 | |
| 258 | |
| 259 | int tc_filter_list(int argc, char **argv) |
| 260 | { |
| 261 | struct tcmsg t; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 262 | char d[16]; |
| 263 | __u32 prio = 0; |
| 264 | __u32 protocol = 0; |
| 265 | char *fhandle = NULL; |
| 266 | |
| 267 | memset(&t, 0, sizeof(t)); |
| 268 | t.tcm_family = AF_UNSPEC; |
| 269 | memset(d, 0, sizeof(d)); |
| 270 | |
| 271 | while (argc > 0) { |
| 272 | if (strcmp(*argv, "dev") == 0) { |
| 273 | NEXT_ARG(); |
| 274 | if (d[0]) |
| 275 | duparg("dev", *argv); |
| 276 | strncpy(d, *argv, sizeof(d)-1); |
| 277 | } else if (strcmp(*argv, "root") == 0) { |
| 278 | if (t.tcm_parent) { |
| 279 | fprintf(stderr, "Error: \"root\" is duplicate parent ID\n"); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 280 | return -1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 281 | } |
| 282 | filter_parent = t.tcm_parent = TC_H_ROOT; |
| 283 | } else if (strcmp(*argv, "parent") == 0) { |
| 284 | __u32 handle; |
| 285 | NEXT_ARG(); |
| 286 | if (t.tcm_parent) |
| 287 | duparg("parent", *argv); |
| 288 | if (get_tc_classid(&handle, *argv)) |
| 289 | invarg(*argv, "invalid parent ID"); |
| 290 | filter_parent = t.tcm_parent = handle; |
| 291 | } else if (strcmp(*argv, "handle") == 0) { |
| 292 | NEXT_ARG(); |
| 293 | if (fhandle) |
| 294 | duparg("handle", *argv); |
| 295 | fhandle = *argv; |
| 296 | } else if (matches(*argv, "preference") == 0 || |
| 297 | matches(*argv, "priority") == 0) { |
| 298 | NEXT_ARG(); |
| 299 | if (prio) |
| 300 | duparg("priority", *argv); |
| 301 | if (get_u32(&prio, *argv, 0)) |
| 302 | invarg(*argv, "invalid preference"); |
| 303 | filter_prio = prio; |
| 304 | } else if (matches(*argv, "protocol") == 0) { |
| 305 | __u16 res; |
| 306 | NEXT_ARG(); |
| 307 | if (protocol) |
| 308 | duparg("protocol", *argv); |
| 309 | if (ll_proto_a2n(&res, *argv)) |
| 310 | invarg(*argv, "invalid protocol"); |
| 311 | protocol = res; |
| 312 | filter_protocol = protocol; |
| 313 | } else if (matches(*argv, "help") == 0) { |
| 314 | usage(); |
| 315 | } else { |
| 316 | fprintf(stderr, " What is \"%s\"? Try \"tc filter help\"\n", *argv); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 317 | return -1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | argc--; argv++; |
| 321 | } |
| 322 | |
| 323 | t.tcm_info = TC_H_MAKE(prio<<16, protocol); |
| 324 | |
osdl.net!shemminger | 7901660 | 2005-03-14 19:34:12 +0000 | [diff] [blame] | 325 | ll_init_map(&rth); |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 326 | |
| 327 | if (d[0]) { |
| 328 | if ((t.tcm_ifindex = ll_name_to_index(d)) == 0) { |
| 329 | fprintf(stderr, "Cannot find device \"%s\"\n", d); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 330 | return 1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 331 | } |
| 332 | filter_ifindex = t.tcm_ifindex; |
| 333 | } |
| 334 | |
osdl.net!shemminger | 7901660 | 2005-03-14 19:34:12 +0000 | [diff] [blame] | 335 | if (rtnl_dump_request(&rth, RTM_GETTFILTER, &t, sizeof(t)) < 0) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 336 | perror("Cannot send dump request"); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 337 | return 1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 338 | } |
| 339 | |
osdl.net!shemminger | 7901660 | 2005-03-14 19:34:12 +0000 | [diff] [blame] | 340 | if (rtnl_dump_filter(&rth, print_filter, stdout, NULL, NULL) < 0) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 341 | fprintf(stderr, "Dump terminated\n"); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 342 | return 1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 343 | } |
| 344 | |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 345 | return 0; |
| 346 | } |
| 347 | |
| 348 | int do_filter(int argc, char **argv) |
| 349 | { |
| 350 | if (argc < 1) |
| 351 | return tc_filter_list(0, NULL); |
| 352 | if (matches(*argv, "add") == 0) |
| 353 | return tc_filter_modify(RTM_NEWTFILTER, NLM_F_EXCL|NLM_F_CREATE, argc-1, argv+1); |
| 354 | if (matches(*argv, "change") == 0) |
| 355 | return tc_filter_modify(RTM_NEWTFILTER, 0, argc-1, argv+1); |
| 356 | if (matches(*argv, "replace") == 0) |
| 357 | return tc_filter_modify(RTM_NEWTFILTER, NLM_F_CREATE, argc-1, argv+1); |
| 358 | if (matches(*argv, "delete") == 0) |
| 359 | return tc_filter_modify(RTM_DELTFILTER, 0, argc-1, argv+1); |
| 360 | #if 0 |
| 361 | if (matches(*argv, "get") == 0) |
| 362 | return tc_filter_get(RTM_GETTFILTER, 0, argc-1, argv+1); |
| 363 | #endif |
| 364 | if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0 |
| 365 | || matches(*argv, "lst") == 0) |
| 366 | return tc_filter_list(argc-1, argv+1); |
Hasso Tepper | e5d179d | 2006-12-10 16:33:05 +0200 | [diff] [blame] | 367 | if (matches(*argv, "help") == 0) { |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 368 | usage(); |
Hasso Tepper | e5d179d | 2006-12-10 16:33:05 +0200 | [diff] [blame] | 369 | return 0; |
| 370 | } |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 371 | fprintf(stderr, "Command \"%s\" is unknown, try \"tc filter help\".\n", *argv); |
osdl.net!shemminger | 024481b | 2005-03-14 19:02:41 +0000 | [diff] [blame] | 372 | return -1; |
osdl.org!shemminger | aba5acd | 2004-04-15 20:56:59 +0000 | [diff] [blame] | 373 | } |
| 374 | |