]>
git.proxmox.com Git - mirror_iproute2.git/blob - tc/tc_filter.c
2 * tc_filter.c "tc filter".
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.
9 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
17 #include <sys/socket.h>
18 #include <netinet/in.h>
19 #include <arpa/inet.h>
21 #include <linux/if_ether.h>
26 #include "tc_common.h"
28 static void usage(void)
31 "Usage: tc filter [ add | del | change | replace | show ] [ dev STRING ]\n"
32 " tc filter [ add | del | change | replace | show ] [ block BLOCK_INDEX ]\n"
33 " tc filter get dev STRING parent CLASSID protocol PROTO handle FILTERID pref PRIO FILTER_TYPE\n"
34 " tc filter get block BLOCK_INDEX protocol PROTO handle FILTERID pref PRIO FILTER_TYPE\n"
35 " [ pref PRIO ] protocol PROTO [ chain CHAIN_INDEX ]\n"
36 " [ estimator INTERVAL TIME_CONSTANT ]\n"
37 " [ root | ingress | egress | parent CLASSID ]\n"
38 " [ handle FILTERID ] [ [ FILTER_TYPE ] [ help | OPTIONS ] ]\n"
40 " tc filter show [ dev STRING ] [ root | ingress | egress | parent CLASSID ]\n"
41 " tc filter show [ block BLOCK_INDEX ]\n"
43 "FILTER_TYPE := { rsvp | u32 | bpf | fw | route | etc. }\n"
44 "FILTERID := ... format depends on classifier, see there\n"
45 "OPTIONS := ... try tc filter add <desired FILTER_KIND> help\n");
48 static void chain_usage(void)
51 "Usage: tc chain [ add | del | get | show ] [ dev STRING ]\n"
52 " tc chain [ add | del | get | show ] [ block BLOCK_INDEX ] ]\n");
55 struct tc_filter_req
{
61 static int tc_filter_modify(int cmd
, unsigned int flags
, int argc
, char **argv
,
62 void *buf
, size_t buflen
)
64 struct tc_filter_req
*req
, filter_req
;
65 struct filter_util
*q
= NULL
;
66 struct tc_estimator est
= {};
67 char k
[FILTER_NAMESZ
] = {};
68 int chain_index_set
= 0;
69 char d
[IFNAMSIZ
] = {};
71 __u32 block_index
= 0;
81 if (buflen
< sizeof (struct tc_filter_req
)) {
82 fprintf(stderr
, "buffer is too small: %zu\n", buflen
);
86 memset(&filter_req
, 0, sizeof (struct tc_filter_req
));
90 req
->n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct tcmsg
));
91 req
->n
.nlmsg_flags
= NLM_F_REQUEST
| flags
;
92 req
->n
.nlmsg_type
= cmd
;
93 req
->t
.tcm_family
= AF_UNSPEC
;
95 if ((cmd
== RTM_NEWTFILTER
|| cmd
== RTM_NEWCHAIN
) &&
97 protocol
= htons(ETH_P_ALL
);
100 if (strcmp(*argv
, "dev") == 0) {
103 duparg("dev", *argv
);
105 fprintf(stderr
, "Error: \"dev\" and \"block\" are mutually exlusive\n");
108 strncpy(d
, *argv
, sizeof(d
)-1);
109 } else if (matches(*argv
, "block") == 0) {
112 duparg("block", *argv
);
114 fprintf(stderr
, "Error: \"dev\" and \"block\" are mutually exlusive\n");
117 if (get_u32(&block_index
, *argv
, 0) || !block_index
)
118 invarg("invalid block index value", *argv
);
119 } else if (strcmp(*argv
, "root") == 0) {
120 if (req
->t
.tcm_parent
) {
122 "Error: \"root\" is duplicate parent ID\n");
125 req
->t
.tcm_parent
= TC_H_ROOT
;
126 } else if (strcmp(*argv
, "ingress") == 0) {
127 if (req
->t
.tcm_parent
) {
129 "Error: \"ingress\" is duplicate parent ID\n");
132 req
->t
.tcm_parent
= TC_H_MAKE(TC_H_CLSACT
,
134 } else if (strcmp(*argv
, "egress") == 0) {
135 if (req
->t
.tcm_parent
) {
137 "Error: \"egress\" is duplicate parent ID\n");
140 req
->t
.tcm_parent
= TC_H_MAKE(TC_H_CLSACT
,
142 } else if (strcmp(*argv
, "parent") == 0) {
146 if (req
->t
.tcm_parent
)
147 duparg("parent", *argv
);
148 if (get_tc_classid(&handle
, *argv
))
149 invarg("Invalid parent ID", *argv
);
150 req
->t
.tcm_parent
= handle
;
151 } else if (strcmp(*argv
, "handle") == 0) {
154 duparg("handle", *argv
);
156 } else if (matches(*argv
, "preference") == 0 ||
157 matches(*argv
, "priority") == 0) {
160 duparg("priority", *argv
);
161 if (get_u32(&prio
, *argv
, 0) || prio
> 0xFFFF)
162 invarg("invalid priority value", *argv
);
163 } else if (matches(*argv
, "protocol") == 0) {
168 duparg("protocol", *argv
);
169 if (ll_proto_a2n(&id
, *argv
))
170 invarg("invalid protocol", *argv
);
173 } else if (matches(*argv
, "chain") == 0) {
176 duparg("chain", *argv
);
177 if (get_u32(&chain_index
, *argv
, 0))
178 invarg("invalid chain index value", *argv
);
180 } else if (matches(*argv
, "estimator") == 0) {
181 if (parse_estimator(&argc
, &argv
, &est
) < 0)
183 } else if (matches(*argv
, "help") == 0) {
187 strncpy(k
, *argv
, sizeof(k
)-1);
189 q
= get_filter_kind(k
);
197 req
->t
.tcm_info
= TC_H_MAKE(prio
<<16, protocol
);
200 addattr32(&req
->n
, sizeof(*req
), TCA_CHAIN
, chain_index
);
203 addattr_l(&req
->n
, sizeof(*req
), TCA_KIND
, k
, strlen(k
)+1);
208 req
->t
.tcm_ifindex
= ll_name_to_index(d
);
209 if (!req
->t
.tcm_ifindex
)
211 } else if (block_index
) {
212 req
->t
.tcm_ifindex
= TCM_IFINDEX_MAGIC_BLOCK
;
213 req
->t
.tcm_block_index
= block_index
;
217 if (q
->parse_fopt(q
, fhandle
, argc
, argv
, &req
->n
))
222 "Must specify filter type when using \"handle\"\n");
226 if (matches(*argv
, "help") == 0)
229 "Garbage instead of arguments \"%s ...\". Try \"tc filter help\".\n",
236 addattr_l(&req
->n
, sizeof(*req
), TCA_RATE
, &est
, sizeof(est
));
241 iov
.iov_base
= &req
->n
;
242 iov
.iov_len
= req
->n
.nlmsg_len
;
243 ret
= rtnl_talk_iov(&rth
, &iov
, 1, NULL
);
245 fprintf(stderr
, "We have an error talking to the kernel, %d\n", ret
);
252 static __u32 filter_parent
;
253 static int filter_ifindex
;
254 static __u32 filter_prio
;
255 static __u32 filter_protocol
;
256 static __u32 filter_chain_index
;
257 static int filter_chain_index_set
;
258 static __u32 filter_block_index
;
261 int print_filter(struct nlmsghdr
*n
, void *arg
)
263 FILE *fp
= (FILE *)arg
;
264 struct tcmsg
*t
= NLMSG_DATA(n
);
265 int len
= n
->nlmsg_len
;
266 struct rtattr
*tb
[TCA_MAX
+1];
267 struct filter_util
*q
;
270 if (n
->nlmsg_type
!= RTM_NEWTFILTER
&&
271 n
->nlmsg_type
!= RTM_GETTFILTER
&&
272 n
->nlmsg_type
!= RTM_DELTFILTER
&&
273 n
->nlmsg_type
!= RTM_NEWCHAIN
&&
274 n
->nlmsg_type
!= RTM_GETCHAIN
&&
275 n
->nlmsg_type
!= RTM_DELCHAIN
) {
276 fprintf(stderr
, "Not a filter(cmd %d)\n", n
->nlmsg_type
);
279 len
-= NLMSG_LENGTH(sizeof(*t
));
281 fprintf(stderr
, "Wrong len %d\n", len
);
285 parse_rtattr(tb
, TCA_MAX
, TCA_RTA(t
), len
);
287 if (tb
[TCA_KIND
] == NULL
&& (n
->nlmsg_type
== RTM_NEWTFILTER
||
288 n
->nlmsg_type
== RTM_GETTFILTER
||
289 n
->nlmsg_type
== RTM_DELTFILTER
)) {
290 fprintf(stderr
, "print_filter: NULL kind\n");
294 open_json_object(NULL
);
296 if (n
->nlmsg_type
== RTM_DELTFILTER
|| n
->nlmsg_type
== RTM_DELCHAIN
)
297 print_bool(PRINT_ANY
, "deleted", "deleted ", true);
299 if ((n
->nlmsg_type
== RTM_NEWTFILTER
||
300 n
->nlmsg_type
== RTM_NEWCHAIN
) &&
301 (n
->nlmsg_flags
& NLM_F_CREATE
) &&
302 !(n
->nlmsg_flags
& NLM_F_EXCL
))
303 print_bool(PRINT_ANY
, "replaced", "replaced ", true);
305 if ((n
->nlmsg_type
== RTM_NEWTFILTER
||
306 n
->nlmsg_type
== RTM_NEWCHAIN
) &&
307 (n
->nlmsg_flags
& NLM_F_CREATE
) &&
308 (n
->nlmsg_flags
& NLM_F_EXCL
))
309 print_bool(PRINT_ANY
, "added", "added ", true);
311 if (n
->nlmsg_type
== RTM_NEWTFILTER
||
312 n
->nlmsg_type
== RTM_GETTFILTER
||
313 n
->nlmsg_type
== RTM_DELTFILTER
)
314 print_string(PRINT_FP
, NULL
, "filter ", NULL
);
316 print_string(PRINT_FP
, NULL
, "chain ", NULL
);
317 if (t
->tcm_ifindex
== TCM_IFINDEX_MAGIC_BLOCK
) {
318 if (!filter_block_index
||
319 filter_block_index
!= t
->tcm_block_index
)
320 print_uint(PRINT_ANY
, "block", "block %u ",
323 if (!filter_ifindex
|| filter_ifindex
!= t
->tcm_ifindex
)
324 print_devname(PRINT_ANY
, t
->tcm_ifindex
);
326 if (!filter_parent
|| filter_parent
!= t
->tcm_parent
) {
327 if (t
->tcm_parent
== TC_H_ROOT
)
328 print_bool(PRINT_ANY
, "root", "root ", true);
329 else if (t
->tcm_parent
== TC_H_MAKE(TC_H_CLSACT
, TC_H_MIN_INGRESS
))
330 print_bool(PRINT_ANY
, "ingress", "ingress ", true);
331 else if (t
->tcm_parent
== TC_H_MAKE(TC_H_CLSACT
, TC_H_MIN_EGRESS
))
332 print_bool(PRINT_ANY
, "egress", "egress ", true);
334 print_tc_classid(abuf
, sizeof(abuf
), t
->tcm_parent
);
335 print_string(PRINT_ANY
, "parent", "parent %s ", abuf
);
340 if (t
->tcm_info
&& (n
->nlmsg_type
== RTM_NEWTFILTER
||
341 n
->nlmsg_type
== RTM_DELTFILTER
||
342 n
->nlmsg_type
== RTM_GETTFILTER
)) {
343 f_proto
= TC_H_MIN(t
->tcm_info
);
344 __u32 prio
= TC_H_MAJ(t
->tcm_info
)>>16;
346 if (!filter_protocol
|| filter_protocol
!= f_proto
) {
349 print_string(PRINT_ANY
, "protocol",
351 ll_proto_n2a(f_proto
, b1
, sizeof(b1
)));
354 if (!filter_prio
|| filter_prio
!= prio
) {
356 print_uint(PRINT_ANY
, "pref", "pref %u ", prio
);
360 print_string(PRINT_ANY
, "kind", "%s ", rta_getattr_str(tb
[TCA_KIND
]));
363 __u32 chain_index
= rta_getattr_u32(tb
[TCA_CHAIN
]);
365 if (!filter_chain_index_set
||
366 filter_chain_index
!= chain_index
)
367 print_uint(PRINT_ANY
, "chain", "chain %u ",
372 q
= get_filter_kind(RTA_DATA(tb
[TCA_KIND
]));
373 if (tb
[TCA_OPTIONS
]) {
374 open_json_object("options");
376 q
->print_fopt(q
, fp
, tb
[TCA_OPTIONS
], t
->tcm_handle
);
378 print_string(PRINT_FP
, NULL
,
379 "[cannot parse parameters]", NULL
);
383 print_string(PRINT_FP
, NULL
, "\n", NULL
);
385 if (show_stats
&& (tb
[TCA_STATS
] || tb
[TCA_STATS2
])) {
386 print_tcstats_attr(fp
, tb
, " ", NULL
);
387 print_string(PRINT_FP
, NULL
, "\n", NULL
);
395 static int tc_filter_get(int cmd
, unsigned int flags
, int argc
, char **argv
)
402 .n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct tcmsg
)),
403 /* NLM_F_ECHO is for backward compatibility. old kernels never
404 * respond without it and newer kernels will ignore it.
405 * In old kernels there is a side effect:
406 * In addition to a response to the GET you will receive an
407 * event (if you do tc mon).
409 .n
.nlmsg_flags
= NLM_F_REQUEST
| NLM_F_ECHO
| flags
,
411 .t
.tcm_parent
= TC_H_UNSPEC
,
412 .t
.tcm_family
= AF_UNSPEC
,
414 struct nlmsghdr
*answer
;
415 struct filter_util
*q
= NULL
;
418 int protocol_set
= 0;
420 int chain_index_set
= 0;
421 __u32 block_index
= 0;
422 __u32 parent_handle
= 0;
423 char *fhandle
= NULL
;
424 char d
[IFNAMSIZ
] = {};
425 char k
[FILTER_NAMESZ
] = {};
428 if (strcmp(*argv
, "dev") == 0) {
431 duparg("dev", *argv
);
433 fprintf(stderr
, "Error: \"dev\" and \"block\" are mutually exlusive\n");
436 strncpy(d
, *argv
, sizeof(d
)-1);
437 } else if (matches(*argv
, "block") == 0) {
440 duparg("block", *argv
);
442 fprintf(stderr
, "Error: \"dev\" and \"block\" are mutually exlusive\n");
445 if (get_u32(&block_index
, *argv
, 0) || !block_index
)
446 invarg("invalid block index value", *argv
);
447 } else if (strcmp(*argv
, "root") == 0) {
448 if (req
.t
.tcm_parent
) {
450 "Error: \"root\" is duplicate parent ID\n");
453 req
.t
.tcm_parent
= TC_H_ROOT
;
454 } else if (strcmp(*argv
, "ingress") == 0) {
455 if (req
.t
.tcm_parent
) {
457 "Error: \"ingress\" is duplicate parent ID\n");
460 req
.t
.tcm_parent
= TC_H_MAKE(TC_H_CLSACT
,
462 } else if (strcmp(*argv
, "egress") == 0) {
463 if (req
.t
.tcm_parent
) {
465 "Error: \"egress\" is duplicate parent ID\n");
468 req
.t
.tcm_parent
= TC_H_MAKE(TC_H_CLSACT
,
470 } else if (strcmp(*argv
, "parent") == 0) {
473 if (req
.t
.tcm_parent
)
474 duparg("parent", *argv
);
475 if (get_tc_classid(&parent_handle
, *argv
))
476 invarg("Invalid parent ID", *argv
);
477 req
.t
.tcm_parent
= parent_handle
;
478 } else if (strcmp(*argv
, "handle") == 0) {
481 duparg("handle", *argv
);
483 } else if (matches(*argv
, "preference") == 0 ||
484 matches(*argv
, "priority") == 0) {
487 duparg("priority", *argv
);
488 if (get_u32(&prio
, *argv
, 0) || prio
> 0xFFFF)
489 invarg("invalid priority value", *argv
);
490 } else if (matches(*argv
, "protocol") == 0) {
495 duparg("protocol", *argv
);
496 if (ll_proto_a2n(&id
, *argv
))
497 invarg("invalid protocol", *argv
);
500 } else if (matches(*argv
, "chain") == 0) {
503 duparg("chain", *argv
);
504 if (get_u32(&chain_index
, *argv
, 0))
505 invarg("invalid chain index value", *argv
);
507 } else if (matches(*argv
, "help") == 0) {
512 invarg("invalid filter name", *argv
);
514 strncpy(k
, *argv
, sizeof(k
)-1);
516 q
= get_filter_kind(k
);
524 if (cmd
== RTM_GETTFILTER
) {
526 fprintf(stderr
, "Must specify filter protocol\n");
531 fprintf(stderr
, "Must specify filter priority\n");
535 req
.t
.tcm_info
= TC_H_MAKE(prio
<<16, protocol
);
539 addattr32(&req
.n
, sizeof(req
), TCA_CHAIN
, chain_index
);
541 if (req
.t
.tcm_parent
== TC_H_UNSPEC
) {
542 fprintf(stderr
, "Must specify filter parent\n");
546 if (cmd
== RTM_GETTFILTER
) {
548 addattr_l(&req
.n
, sizeof(req
), TCA_KIND
, k
, strlen(k
)+1);
550 fprintf(stderr
, "Must specify filter type\n");
558 req
.t
.tcm_ifindex
= ll_name_to_index(d
);
559 if (!req
.t
.tcm_ifindex
)
561 filter_ifindex
= req
.t
.tcm_ifindex
;
562 } else if (block_index
) {
563 req
.t
.tcm_ifindex
= TCM_IFINDEX_MAGIC_BLOCK
;
564 req
.t
.tcm_block_index
= block_index
;
565 filter_block_index
= block_index
;
567 fprintf(stderr
, "Must specify netdevice \"dev\" or block index \"block\"\n");
571 if (cmd
== RTM_GETTFILTER
&&
572 q
->parse_fopt(q
, fhandle
, argc
, argv
, &req
.n
))
575 if (!fhandle
&& cmd
== RTM_GETTFILTER
) {
576 fprintf(stderr
, "Must specify filter \"handle\"\n");
581 if (matches(*argv
, "help") == 0)
584 "Garbage instead of arguments \"%s ...\". Try \"tc filter help\".\n",
589 if (rtnl_talk(&rth
, &req
.n
, &answer
) < 0) {
590 fprintf(stderr
, "We have an error talking to the kernel\n");
595 print_filter(answer
, (void *)stdout
);
602 static int tc_filter_list(int cmd
, int argc
, char **argv
)
609 .n
.nlmsg_len
= NLMSG_LENGTH(sizeof(struct tcmsg
)),
611 .t
.tcm_parent
= TC_H_UNSPEC
,
612 .t
.tcm_family
= AF_UNSPEC
,
614 char d
[IFNAMSIZ
] = {};
618 __u32 block_index
= 0;
619 char *fhandle
= NULL
;
622 if (strcmp(*argv
, "dev") == 0) {
625 duparg("dev", *argv
);
627 fprintf(stderr
, "Error: \"dev\" cannot be used in the same time as \"block\"\n");
630 strncpy(d
, *argv
, sizeof(d
)-1);
631 } else if (matches(*argv
, "block") == 0) {
634 duparg("block", *argv
);
636 fprintf(stderr
, "Error: \"block\" cannot be used in the same time as \"dev\"\n");
639 if (get_u32(&block_index
, *argv
, 0) || !block_index
)
640 invarg("invalid block index value", *argv
);
641 } else if (strcmp(*argv
, "root") == 0) {
642 if (req
.t
.tcm_parent
) {
644 "Error: \"root\" is duplicate parent ID\n");
647 filter_parent
= req
.t
.tcm_parent
= TC_H_ROOT
;
648 } else if (strcmp(*argv
, "ingress") == 0) {
649 if (req
.t
.tcm_parent
) {
651 "Error: \"ingress\" is duplicate parent ID\n");
654 filter_parent
= TC_H_MAKE(TC_H_CLSACT
,
656 req
.t
.tcm_parent
= filter_parent
;
657 } else if (strcmp(*argv
, "egress") == 0) {
658 if (req
.t
.tcm_parent
) {
660 "Error: \"egress\" is duplicate parent ID\n");
663 filter_parent
= TC_H_MAKE(TC_H_CLSACT
,
665 req
.t
.tcm_parent
= filter_parent
;
666 } else if (strcmp(*argv
, "parent") == 0) {
670 if (req
.t
.tcm_parent
)
671 duparg("parent", *argv
);
672 if (get_tc_classid(&handle
, *argv
))
673 invarg("invalid parent ID", *argv
);
674 filter_parent
= req
.t
.tcm_parent
= handle
;
675 } else if (strcmp(*argv
, "handle") == 0) {
678 duparg("handle", *argv
);
680 } else if (matches(*argv
, "preference") == 0 ||
681 matches(*argv
, "priority") == 0) {
684 duparg("priority", *argv
);
685 if (get_u32(&prio
, *argv
, 0))
686 invarg("invalid preference", *argv
);
688 } else if (matches(*argv
, "protocol") == 0) {
693 duparg("protocol", *argv
);
694 if (ll_proto_a2n(&res
, *argv
))
695 invarg("invalid protocol", *argv
);
697 filter_protocol
= protocol
;
698 } else if (matches(*argv
, "chain") == 0) {
700 if (filter_chain_index_set
)
701 duparg("chain", *argv
);
702 if (get_u32(&chain_index
, *argv
, 0))
703 invarg("invalid chain index value", *argv
);
704 filter_chain_index_set
= 1;
705 filter_chain_index
= chain_index
;
706 } else if (matches(*argv
, "help") == 0) {
710 " What is \"%s\"? Try \"tc filter help\"\n",
718 req
.t
.tcm_info
= TC_H_MAKE(prio
<<16, protocol
);
723 req
.t
.tcm_ifindex
= ll_name_to_index(d
);
724 if (!req
.t
.tcm_ifindex
)
726 filter_ifindex
= req
.t
.tcm_ifindex
;
727 } else if (block_index
) {
728 if (!tc_qdisc_block_exists(block_index
)) {
729 fprintf(stderr
, "Cannot find block \"%u\"\n", block_index
);
732 req
.t
.tcm_ifindex
= TCM_IFINDEX_MAGIC_BLOCK
;
733 req
.t
.tcm_block_index
= block_index
;
734 filter_block_index
= block_index
;
737 if (filter_chain_index_set
)
738 addattr32(&req
.n
, sizeof(req
), TCA_CHAIN
, chain_index
);
740 if (rtnl_dump_request_n(&rth
, &req
.n
) < 0) {
741 perror("Cannot send dump request");
746 if (rtnl_dump_filter(&rth
, print_filter
, stdout
) < 0) {
747 fprintf(stderr
, "Dump terminated\n");
755 int do_filter(int argc
, char **argv
, void *buf
, size_t buflen
)
758 return tc_filter_list(RTM_GETTFILTER
, 0, NULL
);
759 if (matches(*argv
, "add") == 0)
760 return tc_filter_modify(RTM_NEWTFILTER
, NLM_F_EXCL
|NLM_F_CREATE
,
761 argc
-1, argv
+1, buf
, buflen
);
762 if (matches(*argv
, "change") == 0)
763 return tc_filter_modify(RTM_NEWTFILTER
, 0, argc
-1, argv
+1,
765 if (matches(*argv
, "replace") == 0)
766 return tc_filter_modify(RTM_NEWTFILTER
, NLM_F_CREATE
, argc
-1,
767 argv
+1, buf
, buflen
);
768 if (matches(*argv
, "delete") == 0)
769 return tc_filter_modify(RTM_DELTFILTER
, 0, argc
-1, argv
+1,
771 if (matches(*argv
, "get") == 0)
772 return tc_filter_get(RTM_GETTFILTER
, 0, argc
-1, argv
+1);
773 if (matches(*argv
, "list") == 0 || matches(*argv
, "show") == 0
774 || matches(*argv
, "lst") == 0)
775 return tc_filter_list(RTM_GETTFILTER
, argc
-1, argv
+1);
776 if (matches(*argv
, "help") == 0) {
780 fprintf(stderr
, "Command \"%s\" is unknown, try \"tc filter help\".\n",
785 int do_chain(int argc
, char **argv
, void *buf
, size_t buflen
)
788 return tc_filter_list(RTM_GETCHAIN
, 0, NULL
);
789 if (matches(*argv
, "add") == 0) {
790 return tc_filter_modify(RTM_NEWCHAIN
, NLM_F_EXCL
| NLM_F_CREATE
,
791 argc
- 1, argv
+ 1, buf
, buflen
);
792 } else if (matches(*argv
, "delete") == 0) {
793 return tc_filter_modify(RTM_DELCHAIN
, 0,
794 argc
- 1, argv
+ 1, buf
, buflen
);
795 } else if (matches(*argv
, "get") == 0) {
796 return tc_filter_get(RTM_GETCHAIN
, 0,
798 } else if (matches(*argv
, "list") == 0 || matches(*argv
, "show") == 0 ||
799 matches(*argv
, "lst") == 0) {
800 return tc_filter_list(RTM_GETCHAIN
, argc
- 1, argv
+ 1);
801 } else if (matches(*argv
, "help") == 0) {
805 fprintf(stderr
, "Command \"%s\" is unknown, try \"tc chain help\".\n",