BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jamal Hadi Salim" <jhs@mojatatu.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net 2/3] net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains
Date: Sat, 27 Jun 2026 16:52:18 +0000	[thread overview]
Message-ID: <20260627165220.096B61F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260626165156.169012-3-jhs@mojatatu.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Removal of TC_ACT_REDIRECT support from qevents (tcf_qevent_handle) breaks existing eBPF redirect functionality.
- [Low] pr_warn_once() used inside a static inline function in a header file will print multiple times.
--

commit d96e142c03f9c1a1e9ac2e1d8c8fe26605053b10
Author: Jamal Hadi Salim <jhs@mojatatu.com>

net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains

When a TC filter attached to a qdisc filter chain returns TC_ACT_REDIRECT,
the redirect is silently lost. This patch adds a tcf_classify_qdisc()
wrapper to convert TC_ACT_REDIRECT to TC_ACT_SHOT and drops the packet.
It also removes the TC_ACT_REDIRECT case from tcf_qevent_handle() since
it is handled by the wrapper.

> diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h
> index 3bd08d7f39c18..3a542a72e9a55 100644
> --- a/include/net/pkt_cls.h
> +++ b/include/net/pkt_cls.h
[ ... ]
> @@ -159,6 +159,19 @@ static inline int tcf_classify(struct sk_buff *skb,
>  
>  #endif
>  
> +static inline int tcf_classify_qdisc(struct sk_buff *skb,
> +				     const struct tcf_proto *tp,
> +				     struct tcf_result *res, bool compat_mode)
> +{
> +	int ret = tcf_classify(skb, NULL, tp, res, compat_mode);
> +
> +	if (unlikely(ret == TC_ACT_REDIRECT)) {
> +		pr_warn_once("TC_ACT_REDIRECT from qdisc filter chains is not supported; use eBPF with clsact or mirred redirect instead\n");

[Severity: Low]
Is this going to print multiple times instead of strictly once globally?

Because tcf_classify_qdisc() is a static inline function in a header file,
each C file including it (like the various qdisc modules) will create its own
local instance of the static __already_done variable used by pr_warn_once().

> +		ret = TC_ACT_SHOT;
> +	}
> +	return ret;
> +}
> +
>  static inline unsigned long
>  __cls_set_class(unsigned long *clp, unsigned long cl)
>  {
> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
> index 3e67600a4a1a1..3ca56d060e28f 100644
> --- a/net/sched/cls_api.c
> +++ b/net/sched/cls_api.c
> @@ -4033,7 +4033,7 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, stru
>  
>  	fl = rcu_dereference_bh(qe->filter_chain);
>  
> -	switch (tcf_classify(skb, NULL, fl, &cl_res, false)) {
> +	switch (tcf_classify_qdisc(skb, fl, &cl_res, false)) {

[Severity: High]
Does this break existing eBPF redirect functionality for qevents?

Prior to this patch, tcf_qevent_handle() correctly handled TC_ACT_REDIRECT
by calling skb_do_redirect(skb). By using the tcf_classify_qdisc() wrapper
here, TC_ACT_REDIRECT is unconditionally converted to TC_ACT_SHOT. This
inadvertently drops packets that were legitimately redirecting from qevents.

>  	case TC_ACT_SHOT:
>  		qdisc_qstats_drop(sch);
>  		__qdisc_drop(skb, to_free);
> @@ -4045,10 +4045,6 @@ struct sk_buff *tcf_qevent_handle(struct tcf_qevent *qe, struct Qdisc *sch, stru
>  		__qdisc_drop(skb, to_free);
>  		*ret = __NET_XMIT_STOLEN;
>  		return NULL;
> -	case TC_ACT_REDIRECT:
> -		skb_do_redirect(skb);
> -		*ret = __NET_XMIT_STOLEN;
> -		return NULL;
>  	case TC_ACT_CONSUMED:
>  		*ret = __NET_XMIT_STOLEN;
>  		return NULL;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626165156.169012-1-jhs@mojatatu.com?part=2

  reply	other threads:[~2026-06-27 16:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 16:51 [PATCH net 0/3] Fix broken TC_ACT_REDIRECT Jamal Hadi Salim
2026-06-26 16:51 ` [PATCH net 1/3] net: Extend bpf_net_context lifetime to cover qdisc enqueue Jamal Hadi Salim
2026-06-27 16:52   ` sashiko-bot
2026-06-28 12:16     ` Jamal Hadi Salim
2026-06-29 10:29   ` Sebastian Andrzej Siewior
2026-06-29 10:47     ` Jamal Hadi Salim
2026-06-26 16:51 ` [PATCH net 2/3] net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains Jamal Hadi Salim
2026-06-27 16:52   ` sashiko-bot [this message]
2026-06-28 12:28     ` Jamal Hadi Salim
2026-06-26 16:51 ` [PATCH net 3/3] selftests/tc-testing: Verify bpf redirect on RED block with preceding clsact (egress) classifier Jamal Hadi Salim
2026-06-27 16:52   ` sashiko-bot
2026-06-28 12:36     ` Jamal Hadi Salim
  -- strict thread matches above, loose matches on Subject: below --
2026-06-30 12:33 [PATCH net 0/3] Fix broken TC_ACT_REDIRECT from qdiscs Daniel Borkmann
2026-06-30 12:33 ` [PATCH net 2/3] net/sched: Handle TC_ACT_REDIRECT from qdisc filter chains Daniel Borkmann
2026-06-30 15:16   ` Jamal Hadi Salim
2026-06-30 15:23     ` Daniel Borkmann
2026-07-01 15:35       ` Jamal Hadi Salim
2026-07-01 12:33   ` sashiko-bot
2026-07-01 13:07     ` Daniel Borkmann

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=20260627165220.096B61F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox