Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Peilin Ye <yepeilin.cs@gmail.com>
To: netdev@vger.kernel.org, David Ahern <dsahern@gmail.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>,
Daniel Borkmann <daniel@iogearbox.net>,
Cong Wang <cong.wang@bytedance.com>,
Peilin Ye <peilin.ye@bytedance.com>,
Peilin Ye <yepeilin.cs@gmail.com>
Subject: [PATCH iproute2-next] tc/ingress: Introduce clsact egress mini-Qdisc option
Date: Mon, 2 Aug 2021 13:51:11 -0700 [thread overview]
Message-ID: <20210802205111.8220-1-yepeilin.cs@gmail.com> (raw)
In-Reply-To: <20210721232053.39077-1-yepeilin.cs@gmail.com>
From: Peilin Ye <peilin.ye@bytedance.com>
If the ingress Qdisc is in use, currently it is not possible to add
another clsact egress mini-Qdisc to the same device without taking down
the ingress Qdisc, since both sch_ingress and sch_clsact use the same
handle (0xFFFF0000).
To solve this issue, recently we added a new clsact egress mini-Qdisc
option for sch_ingress in the kernel. Support it in the q_ingress front
end, and update the usage message accordingly.
To turn on the egress mini-Qdisc:
$ tc qdisc add dev eth0 ingress
$ tc qdisc change dev eth0 ingress clsact-on
Then users can add filters to the egress mini-Qdisc as usual:
$ tc filter add dev eth0 egress protocol ip prio 10 \
matchall action skbmod swap mac
Deleting the ingress Qdisc removes the egress mini-Qdisc as well. To
remove egress mini-Qdisc only, use:
$ tc qdisc change dev eth0 ingress clsact-off
Finally, if the egress mini-Qdisc is enabled, the "show" command will
print out a "clsact" flag to indicate it:
$ tc qdisc show ingress
qdisc ingress ffff: dev eth0 parent ffff:fff1 ----------------
$ tc qdisc change dev eth0 ingress clsact-on
$ tc qdisc show ingress
qdisc ingress ffff: dev eth0 parent ffff:fff1 ---------------- clsact
Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Peilin Ye <peilin.ye@bytedance.com>
---
include/uapi/linux/pkt_sched.h | 12 +++++++++
tc/q_ingress.c | 46 ++++++++++++++++++++++++++++++++--
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index 79a699f106b1..cb0eb5dd848a 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -586,6 +586,18 @@ enum {
#define TCA_ATM_MAX (__TCA_ATM_MAX - 1)
+/* INGRESS section */
+
+enum {
+ TCA_INGRESS_UNSPEC,
+ TCA_INGRESS_FLAGS,
+#define TC_INGRESS_CLSACT _BITUL(0) /* enable clsact egress mini-Qdisc */
+#define TC_INGRESS_SUPPORTED_FLAGS TC_INGRESS_CLSACT
+ __TCA_INGRESS_MAX,
+};
+
+#define TCA_INGRESS_MAX (__TCA_INGRESS_MAX - 1)
+
/* Network emulator */
enum {
diff --git a/tc/q_ingress.c b/tc/q_ingress.c
index 93313c9c2aec..25bf2dce0b56 100644
--- a/tc/q_ingress.c
+++ b/tc/q_ingress.c
@@ -17,21 +17,45 @@
static void explain(void)
{
- fprintf(stderr, "Usage: ... ingress\n");
+ fprintf(stderr,
+ "Usage: [ add | replace | link | delete ] ... ingress\n"
+ " change ... ingress [ clsact-on | clsact-off ]\n"
+ " clsact-on\tenable clsact egress mini-Qdisc\n"
+ " clsact-off\tdelete clsact egress mini-Qdisc\n");
}
static int ingress_parse_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n, const char *dev)
{
+ struct nla_bitfield32 flags = {
+ .selector = TC_INGRESS_SUPPORTED_FLAGS,
+ };
+ bool change = false;
+ struct rtattr *tail;
+
while (argc > 0) {
if (strcmp(*argv, "handle") == 0) {
NEXT_ARG();
- argc--; argv++;
+ } else if (strcmp(*argv, "clsact-on") == 0) {
+ flags.value |= TC_INGRESS_CLSACT;
+ change = true;
+ } else if (strcmp(*argv, "clsact-off") == 0) {
+ flags.value &= ~TC_INGRESS_CLSACT;
+ change = true;
} else {
fprintf(stderr, "What is \"%s\"?\n", *argv);
explain();
return -1;
}
+
+ argc--;
+ argv++;
+ }
+
+ if (change) {
+ tail = addattr_nest(n, 1024, TCA_OPTIONS);
+ addattr_l(n, 1024, TCA_INGRESS_FLAGS, &flags, sizeof(flags));
+ addattr_nest_end(n, tail);
}
return 0;
@@ -40,7 +64,25 @@ static int ingress_parse_opt(struct qdisc_util *qu, int argc, char **argv,
static int ingress_print_opt(struct qdisc_util *qu, FILE *f,
struct rtattr *opt)
{
+ struct rtattr *tb[TCA_INGRESS_MAX + 1];
+ struct nla_bitfield32 *flags;
+
print_string(PRINT_FP, NULL, "---------------- ", NULL);
+
+ if (!opt)
+ return 0;
+
+ parse_rtattr_nested(tb, TCA_INGRESS_MAX, opt);
+
+ if (!tb[TCA_INGRESS_FLAGS])
+ return -1;
+ if (RTA_PAYLOAD(tb[TCA_INGRESS_FLAGS]) < sizeof(*flags))
+ return -1;
+
+ flags = RTA_DATA(tb[TCA_INGRESS_FLAGS]);
+ if (flags->value & TC_INGRESS_CLSACT)
+ print_string(PRINT_FP, NULL, "clsact", NULL);
+
return 0;
}
--
2.20.1
next prev parent reply other threads:[~2021-08-02 20:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 23:20 [PATCH iproute2-next] tc/skbmod: Introduce SKBMOD_F_ECN option Peilin Ye
2021-08-02 16:28 ` David Ahern
2021-08-02 17:54 ` [PATCH iproute2-next v2] " Peilin Ye
2021-08-04 15:25 ` David Ahern
2021-08-02 20:51 ` Peilin Ye [this message]
2021-08-04 18:15 ` [PATCH iproute2-next v3] " Peilin Ye
2021-08-08 17:59 ` David Ahern
2021-08-08 18:00 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210802205111.8220-1-yepeilin.cs@gmail.com \
--to=yepeilin.cs@gmail.com \
--cc=cong.wang@bytedance.com \
--cc=daniel@iogearbox.net \
--cc=dsahern@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=peilin.ye@bytedance.com \
--cc=stephen@networkplumber.org \
--cc=xiyou.wangcong@gmail.com \
--subject='Re: [PATCH iproute2-next] tc/ingress: Introduce clsact egress mini-Qdisc option' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).