|
|
8def76 |
From 24ad28e010f1888e431631ef2179f9284b4aed43 Mon Sep 17 00:00:00 2001
|
|
|
8def76 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
8def76 |
Date: Wed, 26 Jun 2019 16:59:54 +0200
|
|
|
8def76 |
Subject: [PATCH] tc: introduce support for chain templates
|
|
|
8def76 |
|
|
|
8def76 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1710291
|
|
|
8def76 |
Upstream Status: iproute2.git commit afcd06991db26
|
|
|
8def76 |
|
|
|
8def76 |
commit afcd06991db267db2d0d4733da34c5c508d30532
|
|
|
8def76 |
Author: Jiri Pirko <jiri@mellanox.com>
|
|
|
8def76 |
Date: Mon Jul 23 09:24:40 2018 +0200
|
|
|
8def76 |
|
|
|
8def76 |
tc: introduce support for chain templates
|
|
|
8def76 |
|
|
|
8def76 |
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
|
|
|
8def76 |
Signed-off-by: David Ahern <dsahern@gmail.com>
|
|
|
8def76 |
---
|
|
|
8def76 |
man/man8/tc.8 | 26 ++++++++++
|
|
|
8def76 |
tc/tc.c | 5 +-
|
|
|
8def76 |
tc/tc_common.h | 1 +
|
|
|
8def76 |
tc/tc_filter.c | 131 ++++++++++++++++++++++++++++++++++--------------
|
|
|
8def76 |
tc/tc_monitor.c | 5 +-
|
|
|
8def76 |
5 files changed, 128 insertions(+), 40 deletions(-)
|
|
|
8def76 |
|
|
|
8def76 |
diff --git a/man/man8/tc.8 b/man/man8/tc.8
|
|
|
8def76 |
index 840880fbdba63..8a50f57fbfb2d 100644
|
|
|
8def76 |
--- a/man/man8/tc.8
|
|
|
8def76 |
+++ b/man/man8/tc.8
|
|
|
8def76 |
@@ -58,6 +58,22 @@ tc \- show / manipulate traffic control settings
|
|
|
8def76 |
.B flowid
|
|
|
8def76 |
\fIflow-id\fR
|
|
|
8def76 |
|
|
|
8def76 |
+.B tc
|
|
|
8def76 |
+.RI "[ " OPTIONS " ]"
|
|
|
8def76 |
+.B chain [ add | delete | get ] dev
|
|
|
8def76 |
+\fIDEV\fR
|
|
|
8def76 |
+.B [ parent
|
|
|
8def76 |
+\fIqdisc-id\fR
|
|
|
8def76 |
+.B | root ]\fR filtertype
|
|
|
8def76 |
+[ filtertype specific parameters ]
|
|
|
8def76 |
+
|
|
|
8def76 |
+.B tc
|
|
|
8def76 |
+.RI "[ " OPTIONS " ]"
|
|
|
8def76 |
+.B chain [ add | delete | get ] block
|
|
|
8def76 |
+\fIBLOCK_INDEX\fR filtertype
|
|
|
8def76 |
+[ filtertype specific parameters ]
|
|
|
8def76 |
+
|
|
|
8def76 |
+
|
|
|
8def76 |
.B tc
|
|
|
8def76 |
.RI "[ " OPTIONS " ]"
|
|
|
8def76 |
.RI "[ " FORMAT " ]"
|
|
|
8def76 |
@@ -80,6 +96,16 @@ tc \- show / manipulate traffic control settings
|
|
|
8def76 |
.RI "[ " OPTIONS " ]"
|
|
|
8def76 |
.B filter show block
|
|
|
8def76 |
\fIBLOCK_INDEX\fR
|
|
|
8def76 |
+.P
|
|
|
8def76 |
+.B tc
|
|
|
8def76 |
+.RI "[ " OPTIONS " ]"
|
|
|
8def76 |
+.B chain show dev
|
|
|
8def76 |
+\fIDEV\fR
|
|
|
8def76 |
+.P
|
|
|
8def76 |
+.B tc
|
|
|
8def76 |
+.RI "[ " OPTIONS " ]"
|
|
|
8def76 |
+.B chain show block
|
|
|
8def76 |
+\fIBLOCK_INDEX\fR
|
|
|
8def76 |
|
|
|
8def76 |
.P
|
|
|
8def76 |
.B tc
|
|
|
8def76 |
diff --git a/tc/tc.c b/tc/tc.c
|
|
|
8def76 |
index 88e22ba6bcd0b..1fcb3afa727f0 100644
|
|
|
8def76 |
--- a/tc/tc.c
|
|
|
8def76 |
+++ b/tc/tc.c
|
|
|
8def76 |
@@ -196,7 +196,8 @@ static void usage(void)
|
|
|
8def76 |
fprintf(stderr,
|
|
|
8def76 |
"Usage: tc [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
|
|
8def76 |
" tc [-force] -batch filename\n"
|
|
|
8def76 |
- "where OBJECT := { qdisc | class | filter | action | monitor | exec }\n"
|
|
|
8def76 |
+ "where OBJECT := { qdisc | class | filter | chain |\n"
|
|
|
8def76 |
+ " action | monitor | exec }\n"
|
|
|
8def76 |
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[aw] |\n"
|
|
|
8def76 |
" -o[neline] | -j[son] | -p[retty] | -c[olor]\n"
|
|
|
8def76 |
" -b[atch] [filename] | -n[etns] name |\n"
|
|
|
8def76 |
@@ -211,6 +212,8 @@ static int do_cmd(int argc, char **argv, void *buf, size_t buflen)
|
|
|
8def76 |
return do_class(argc-1, argv+1);
|
|
|
8def76 |
if (matches(*argv, "filter") == 0)
|
|
|
8def76 |
return do_filter(argc-1, argv+1, buf, buflen);
|
|
|
8def76 |
+ if (matches(*argv, "chain") == 0)
|
|
|
8def76 |
+ return do_chain(argc-1, argv+1, buf, buflen);
|
|
|
8def76 |
if (matches(*argv, "actions") == 0)
|
|
|
8def76 |
return do_action(argc-1, argv+1, buf, buflen);
|
|
|
8def76 |
if (matches(*argv, "monitor") == 0)
|
|
|
8def76 |
diff --git a/tc/tc_common.h b/tc/tc_common.h
|
|
|
8def76 |
index 49c24616c2c35..272d1727027d4 100644
|
|
|
8def76 |
--- a/tc/tc_common.h
|
|
|
8def76 |
+++ b/tc/tc_common.h
|
|
|
8def76 |
@@ -8,6 +8,7 @@ extern struct rtnl_handle rth;
|
|
|
8def76 |
extern int do_qdisc(int argc, char **argv);
|
|
|
8def76 |
extern int do_class(int argc, char **argv);
|
|
|
8def76 |
extern int do_filter(int argc, char **argv, void *buf, size_t buflen);
|
|
|
8def76 |
+extern int do_chain(int argc, char **argv, void *buf, size_t buflen);
|
|
|
8def76 |
extern int do_action(int argc, char **argv, void *buf, size_t buflen);
|
|
|
8def76 |
extern int do_tcmonitor(int argc, char **argv);
|
|
|
8def76 |
extern int do_exec(int argc, char **argv);
|
|
|
8def76 |
diff --git a/tc/tc_filter.c b/tc/tc_filter.c
|
|
|
8def76 |
index c5bb0bffe19b2..15044b4bc6ed9 100644
|
|
|
8def76 |
--- a/tc/tc_filter.c
|
|
|
8def76 |
+++ b/tc/tc_filter.c
|
|
|
8def76 |
@@ -45,6 +45,13 @@ static void usage(void)
|
|
|
8def76 |
"OPTIONS := ... try tc filter add <desired FILTER_KIND> help\n");
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
+static void chain_usage(void)
|
|
|
8def76 |
+{
|
|
|
8def76 |
+ fprintf(stderr,
|
|
|
8def76 |
+ "Usage: tc chain [ add | del | get | show ] [ dev STRING ]\n"
|
|
|
8def76 |
+ " tc chain [ add | del | get | show ] [ block BLOCK_INDEX ] ]\n");
|
|
|
8def76 |
+}
|
|
|
8def76 |
+
|
|
|
8def76 |
struct tc_filter_req {
|
|
|
8def76 |
struct nlmsghdr n;
|
|
|
8def76 |
struct tcmsg t;
|
|
|
8def76 |
@@ -85,7 +92,8 @@ static int tc_filter_modify(int cmd, unsigned int flags, int argc, char **argv,
|
|
|
8def76 |
req->n.nlmsg_type = cmd;
|
|
|
8def76 |
req->t.tcm_family = AF_UNSPEC;
|
|
|
8def76 |
|
|
|
8def76 |
- if (cmd == RTM_NEWTFILTER && flags & NLM_F_CREATE)
|
|
|
8def76 |
+ if ((cmd == RTM_NEWTFILTER || cmd == RTM_NEWCHAIN) &&
|
|
|
8def76 |
+ flags & NLM_F_CREATE)
|
|
|
8def76 |
protocol = htons(ETH_P_ALL);
|
|
|
8def76 |
|
|
|
8def76 |
while (argc > 0) {
|
|
|
8def76 |
@@ -261,7 +269,10 @@ int print_filter(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
8def76 |
|
|
|
8def76 |
if (n->nlmsg_type != RTM_NEWTFILTER &&
|
|
|
8def76 |
n->nlmsg_type != RTM_GETTFILTER &&
|
|
|
8def76 |
- n->nlmsg_type != RTM_DELTFILTER) {
|
|
|
8def76 |
+ n->nlmsg_type != RTM_DELTFILTER &&
|
|
|
8def76 |
+ n->nlmsg_type != RTM_NEWCHAIN &&
|
|
|
8def76 |
+ n->nlmsg_type != RTM_GETCHAIN &&
|
|
|
8def76 |
+ n->nlmsg_type != RTM_DELCHAIN) {
|
|
|
8def76 |
fprintf(stderr, "Not a filter(cmd %d)\n", n->nlmsg_type);
|
|
|
8def76 |
return 0;
|
|
|
8def76 |
}
|
|
|
8def76 |
@@ -273,27 +284,36 @@ int print_filter(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
8def76 |
|
|
|
8def76 |
parse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);
|
|
|
8def76 |
|
|
|
8def76 |
- if (tb[TCA_KIND] == NULL) {
|
|
|
8def76 |
+ if (tb[TCA_KIND] == NULL && (n->nlmsg_type == RTM_NEWTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_GETTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_DELTFILTER)) {
|
|
|
8def76 |
fprintf(stderr, "print_filter: NULL kind\n");
|
|
|
8def76 |
return -1;
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
open_json_object(NULL);
|
|
|
8def76 |
|
|
|
8def76 |
- if (n->nlmsg_type == RTM_DELTFILTER)
|
|
|
8def76 |
+ if (n->nlmsg_type == RTM_DELTFILTER || n->nlmsg_type == RTM_DELCHAIN)
|
|
|
8def76 |
print_bool(PRINT_ANY, "deleted", "deleted ", true);
|
|
|
8def76 |
|
|
|
8def76 |
- if (n->nlmsg_type == RTM_NEWTFILTER &&
|
|
|
8def76 |
+ if ((n->nlmsg_type == RTM_NEWTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_NEWCHAIN) &&
|
|
|
8def76 |
(n->nlmsg_flags & NLM_F_CREATE) &&
|
|
|
8def76 |
!(n->nlmsg_flags & NLM_F_EXCL))
|
|
|
8def76 |
print_bool(PRINT_ANY, "replaced", "replaced ", true);
|
|
|
8def76 |
|
|
|
8def76 |
- if (n->nlmsg_type == RTM_NEWTFILTER &&
|
|
|
8def76 |
+ if ((n->nlmsg_type == RTM_NEWTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_NEWCHAIN) &&
|
|
|
8def76 |
(n->nlmsg_flags & NLM_F_CREATE) &&
|
|
|
8def76 |
(n->nlmsg_flags & NLM_F_EXCL))
|
|
|
8def76 |
print_bool(PRINT_ANY, "added", "added ", true);
|
|
|
8def76 |
|
|
|
8def76 |
- print_string(PRINT_FP, NULL, "filter ", NULL);
|
|
|
8def76 |
+ if (n->nlmsg_type == RTM_NEWTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_GETTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_DELTFILTER)
|
|
|
8def76 |
+ print_string(PRINT_FP, NULL, "filter ", NULL);
|
|
|
8def76 |
+ else
|
|
|
8def76 |
+ print_string(PRINT_FP, NULL, "chain ", NULL);
|
|
|
8def76 |
if (t->tcm_ifindex == TCM_IFINDEX_MAGIC_BLOCK) {
|
|
|
8def76 |
if (!filter_block_index ||
|
|
|
8def76 |
filter_block_index != t->tcm_block_index)
|
|
|
8def76 |
@@ -317,7 +337,9 @@ int print_filter(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
8def76 |
}
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
- if (t->tcm_info) {
|
|
|
8def76 |
+ if (t->tcm_info && (n->nlmsg_type == RTM_NEWTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_DELTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_GETTFILTER)) {
|
|
|
8def76 |
f_proto = TC_H_MIN(t->tcm_info);
|
|
|
8def76 |
__u32 prio = TC_H_MAJ(t->tcm_info)>>16;
|
|
|
8def76 |
|
|
|
8def76 |
@@ -334,7 +356,8 @@ int print_filter(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
8def76 |
print_uint(PRINT_ANY, "pref", "pref %u ", prio);
|
|
|
8def76 |
}
|
|
|
8def76 |
}
|
|
|
8def76 |
- print_string(PRINT_ANY, "kind", "%s ", rta_getattr_str(tb[TCA_KIND]));
|
|
|
8def76 |
+ if (tb[TCA_KIND])
|
|
|
8def76 |
+ print_string(PRINT_ANY, "kind", "%s ", rta_getattr_str(tb[TCA_KIND]));
|
|
|
8def76 |
|
|
|
8def76 |
if (tb[TCA_CHAIN]) {
|
|
|
8def76 |
__u32 chain_index = rta_getattr_u32(tb[TCA_CHAIN]);
|
|
|
8def76 |
@@ -345,15 +368,17 @@ int print_filter(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
8def76 |
chain_index);
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
- q = get_filter_kind(RTA_DATA(tb[TCA_KIND]));
|
|
|
8def76 |
- if (tb[TCA_OPTIONS]) {
|
|
|
8def76 |
- open_json_object("options");
|
|
|
8def76 |
- if (q)
|
|
|
8def76 |
- q->print_fopt(q, fp, tb[TCA_OPTIONS], t->tcm_handle);
|
|
|
8def76 |
- else
|
|
|
8def76 |
- print_string(PRINT_FP, NULL,
|
|
|
8def76 |
- "[cannot parse parameters]", NULL);
|
|
|
8def76 |
- close_json_object();
|
|
|
8def76 |
+ if (tb[TCA_KIND]) {
|
|
|
8def76 |
+ q = get_filter_kind(RTA_DATA(tb[TCA_KIND]));
|
|
|
8def76 |
+ if (tb[TCA_OPTIONS]) {
|
|
|
8def76 |
+ open_json_object("options");
|
|
|
8def76 |
+ if (q)
|
|
|
8def76 |
+ q->print_fopt(q, fp, tb[TCA_OPTIONS], t->tcm_handle);
|
|
|
8def76 |
+ else
|
|
|
8def76 |
+ print_string(PRINT_FP, NULL,
|
|
|
8def76 |
+ "[cannot parse parameters]", NULL);
|
|
|
8def76 |
+ close_json_object();
|
|
|
8def76 |
+ }
|
|
|
8def76 |
}
|
|
|
8def76 |
print_string(PRINT_FP, NULL, "\n", NULL);
|
|
|
8def76 |
|
|
|
8def76 |
@@ -496,17 +521,19 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
8def76 |
argc--; argv++;
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
- if (!protocol_set) {
|
|
|
8def76 |
- fprintf(stderr, "Must specify filter protocol\n");
|
|
|
8def76 |
- return -1;
|
|
|
8def76 |
- }
|
|
|
8def76 |
+ if (cmd == RTM_GETTFILTER) {
|
|
|
8def76 |
+ if (!protocol_set) {
|
|
|
8def76 |
+ fprintf(stderr, "Must specify filter protocol\n");
|
|
|
8def76 |
+ return -1;
|
|
|
8def76 |
+ }
|
|
|
8def76 |
|
|
|
8def76 |
- if (!prio) {
|
|
|
8def76 |
- fprintf(stderr, "Must specify filter priority\n");
|
|
|
8def76 |
- return -1;
|
|
|
8def76 |
- }
|
|
|
8def76 |
+ if (!prio) {
|
|
|
8def76 |
+ fprintf(stderr, "Must specify filter priority\n");
|
|
|
8def76 |
+ return -1;
|
|
|
8def76 |
+ }
|
|
|
8def76 |
|
|
|
8def76 |
- req.t.tcm_info = TC_H_MAKE(prio<<16, protocol);
|
|
|
8def76 |
+ req.t.tcm_info = TC_H_MAKE(prio<<16, protocol);
|
|
|
8def76 |
+ }
|
|
|
8def76 |
|
|
|
8def76 |
if (chain_index_set)
|
|
|
8def76 |
addattr32(&req.n, sizeof(req), TCA_CHAIN, chain_index);
|
|
|
8def76 |
@@ -516,11 +543,13 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
8def76 |
return -1;
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
- if (k[0])
|
|
|
8def76 |
- addattr_l(&req.n, sizeof(req), TCA_KIND, k, strlen(k)+1);
|
|
|
8def76 |
- else {
|
|
|
8def76 |
- fprintf(stderr, "Must specify filter type\n");
|
|
|
8def76 |
- return -1;
|
|
|
8def76 |
+ if (cmd == RTM_GETTFILTER) {
|
|
|
8def76 |
+ if (k[0])
|
|
|
8def76 |
+ addattr_l(&req.n, sizeof(req), TCA_KIND, k, strlen(k)+1);
|
|
|
8def76 |
+ else {
|
|
|
8def76 |
+ fprintf(stderr, "Must specify filter type\n");
|
|
|
8def76 |
+ return -1;
|
|
|
8def76 |
+ }
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
if (d[0]) {
|
|
|
8def76 |
@@ -539,10 +568,11 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
8def76 |
return -1;
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
- if (q->parse_fopt(q, fhandle, argc, argv, &req.n))
|
|
|
8def76 |
+ if (cmd == RTM_GETTFILTER &&
|
|
|
8def76 |
+ q->parse_fopt(q, fhandle, argc, argv, &req.n))
|
|
|
8def76 |
return 1;
|
|
|
8def76 |
|
|
|
8def76 |
- if (!fhandle) {
|
|
|
8def76 |
+ if (!fhandle && cmd == RTM_GETTFILTER) {
|
|
|
8def76 |
fprintf(stderr, "Must specify filter \"handle\"\n");
|
|
|
8def76 |
return -1;
|
|
|
8def76 |
}
|
|
|
8def76 |
@@ -569,7 +599,7 @@ static int tc_filter_get(int cmd, unsigned int flags, int argc, char **argv)
|
|
|
8def76 |
return 0;
|
|
|
8def76 |
}
|
|
|
8def76 |
|
|
|
8def76 |
-static int tc_filter_list(int argc, char **argv)
|
|
|
8def76 |
+static int tc_filter_list(int cmd, int argc, char **argv)
|
|
|
8def76 |
{
|
|
|
8def76 |
struct {
|
|
|
8def76 |
struct nlmsghdr n;
|
|
|
8def76 |
@@ -577,7 +607,7 @@ static int tc_filter_list(int argc, char **argv)
|
|
|
8def76 |
char buf[MAX_MSG];
|
|
|
8def76 |
} req = {
|
|
|
8def76 |
.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)),
|
|
|
8def76 |
- .n.nlmsg_type = RTM_GETTFILTER,
|
|
|
8def76 |
+ .n.nlmsg_type = cmd,
|
|
|
8def76 |
.t.tcm_parent = TC_H_UNSPEC,
|
|
|
8def76 |
.t.tcm_family = AF_UNSPEC,
|
|
|
8def76 |
};
|
|
|
8def76 |
@@ -725,7 +755,7 @@ static int tc_filter_list(int argc, char **argv)
|
|
|
8def76 |
int do_filter(int argc, char **argv, void *buf, size_t buflen)
|
|
|
8def76 |
{
|
|
|
8def76 |
if (argc < 1)
|
|
|
8def76 |
- return tc_filter_list(0, NULL);
|
|
|
8def76 |
+ return tc_filter_list(RTM_GETTFILTER, 0, NULL);
|
|
|
8def76 |
if (matches(*argv, "add") == 0)
|
|
|
8def76 |
return tc_filter_modify(RTM_NEWTFILTER, NLM_F_EXCL|NLM_F_CREATE,
|
|
|
8def76 |
argc-1, argv+1, buf, buflen);
|
|
|
8def76 |
@@ -742,7 +772,7 @@ int do_filter(int argc, char **argv, void *buf, size_t buflen)
|
|
|
8def76 |
return tc_filter_get(RTM_GETTFILTER, 0, argc-1, argv+1);
|
|
|
8def76 |
if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0
|
|
|
8def76 |
|| matches(*argv, "lst") == 0)
|
|
|
8def76 |
- return tc_filter_list(argc-1, argv+1);
|
|
|
8def76 |
+ return tc_filter_list(RTM_GETTFILTER, argc-1, argv+1);
|
|
|
8def76 |
if (matches(*argv, "help") == 0) {
|
|
|
8def76 |
usage();
|
|
|
8def76 |
return 0;
|
|
|
8def76 |
@@ -751,3 +781,28 @@ int do_filter(int argc, char **argv, void *buf, size_t buflen)
|
|
|
8def76 |
*argv);
|
|
|
8def76 |
return -1;
|
|
|
8def76 |
}
|
|
|
8def76 |
+
|
|
|
8def76 |
+int do_chain(int argc, char **argv, void *buf, size_t buflen)
|
|
|
8def76 |
+{
|
|
|
8def76 |
+ if (argc < 1)
|
|
|
8def76 |
+ return tc_filter_list(RTM_GETCHAIN, 0, NULL);
|
|
|
8def76 |
+ if (matches(*argv, "add") == 0) {
|
|
|
8def76 |
+ return tc_filter_modify(RTM_NEWCHAIN, NLM_F_EXCL | NLM_F_CREATE,
|
|
|
8def76 |
+ argc - 1, argv + 1, buf, buflen);
|
|
|
8def76 |
+ } else if (matches(*argv, "delete") == 0) {
|
|
|
8def76 |
+ return tc_filter_modify(RTM_DELCHAIN, 0,
|
|
|
8def76 |
+ argc - 1, argv + 1, buf, buflen);
|
|
|
8def76 |
+ } else if (matches(*argv, "get") == 0) {
|
|
|
8def76 |
+ return tc_filter_get(RTM_GETCHAIN, 0,
|
|
|
8def76 |
+ argc - 1, argv + 1);
|
|
|
8def76 |
+ } else if (matches(*argv, "list") == 0 || matches(*argv, "show") == 0 ||
|
|
|
8def76 |
+ matches(*argv, "lst") == 0) {
|
|
|
8def76 |
+ return tc_filter_list(RTM_GETCHAIN, argc - 1, argv + 1);
|
|
|
8def76 |
+ } else if (matches(*argv, "help") == 0) {
|
|
|
8def76 |
+ chain_usage();
|
|
|
8def76 |
+ return 0;
|
|
|
8def76 |
+ }
|
|
|
8def76 |
+ fprintf(stderr, "Command \"%s\" is unknown, try \"tc chain help\".\n",
|
|
|
8def76 |
+ *argv);
|
|
|
8def76 |
+ return -1;
|
|
|
8def76 |
+}
|
|
|
8def76 |
diff --git a/tc/tc_monitor.c b/tc/tc_monitor.c
|
|
|
8def76 |
index 077b138d1ec58..1f1ee08fb9cf8 100644
|
|
|
8def76 |
--- a/tc/tc_monitor.c
|
|
|
8def76 |
+++ b/tc/tc_monitor.c
|
|
|
8def76 |
@@ -43,7 +43,10 @@ static int accept_tcmsg(const struct sockaddr_nl *who,
|
|
|
8def76 |
if (timestamp)
|
|
|
8def76 |
print_timestamp(fp);
|
|
|
8def76 |
|
|
|
8def76 |
- if (n->nlmsg_type == RTM_NEWTFILTER || n->nlmsg_type == RTM_DELTFILTER) {
|
|
|
8def76 |
+ if (n->nlmsg_type == RTM_NEWTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_DELTFILTER ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_NEWCHAIN ||
|
|
|
8def76 |
+ n->nlmsg_type == RTM_DELCHAIN) {
|
|
|
8def76 |
print_filter(who, n, arg);
|
|
|
8def76 |
return 0;
|
|
|
8def76 |
}
|
|
|
8def76 |
--
|
|
|
8def76 |
2.20.1
|
|
|
8def76 |
|