From: Yafang Shao <laoar.shao@gmail.com>
To: Nikolay Aleksandrov <razor@blackwall.org>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, daniel@iogearbox.net,
bigeasy@linutronix.de, tgraf@suug.ch, paulmck@kernel.org,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v2] net/cls_cgroup: Fix task_get_classid() during qdisc run
Date: Fri, 22 Aug 2025 15:34:10 +0800 [thread overview]
Message-ID: <CALOAHbDoT8kmfbM9EnRcLP2o+2YpgN6ktn+p3UJMCeA=bOFopA@mail.gmail.com> (raw)
In-Reply-To: <87303e90-3c74-4e4f-8fac-2001d82b90d8@blackwall.org>
On Fri, Aug 22, 2025 at 3:26 PM Nikolay Aleksandrov <razor@blackwall.org> wrote:
>
> On 8/22/25 09:42, Yafang Shao wrote:
> > During recent testing with the netem qdisc to inject delays into TCP
> > traffic, we observed that our CLS BPF program failed to function correctly
> > due to incorrect classid retrieval from task_get_classid(). The issue
> > manifests in the following call stack:
> >
> > bpf_get_cgroup_classid+5
> > cls_bpf_classify+507
> > __tcf_classify+90
> > tcf_classify+217
> > __dev_queue_xmit+798
> > bond_dev_queue_xmit+43
> > __bond_start_xmit+211
> > bond_start_xmit+70
> > dev_hard_start_xmit+142
> > sch_direct_xmit+161
> > __qdisc_run+102 <<<<< Issue location
> > __dev_xmit_skb+1015
> > __dev_queue_xmit+637
> > neigh_hh_output+159
> > ip_finish_output2+461
> > __ip_finish_output+183
> > ip_finish_output+41
> > ip_output+120
> > ip_local_out+94
> > __ip_queue_xmit+394
> > ip_queue_xmit+21
> > __tcp_transmit_skb+2169
> > tcp_write_xmit+959
> > __tcp_push_pending_frames+55
> > tcp_push+264
> > tcp_sendmsg_locked+661
> > tcp_sendmsg+45
> > inet_sendmsg+67
> > sock_sendmsg+98
> > sock_write_iter+147
> > vfs_write+786
> > ksys_write+181
> > __x64_sys_write+25
> > do_syscall_64+56
> > entry_SYSCALL_64_after_hwframe+100
> >
> > The problem occurs when multiple tasks share a single qdisc. In such cases,
> > __qdisc_run() may transmit skbs created by different tasks. Consequently,
> > task_get_classid() retrieves an incorrect classid since it references the
> > current task's context rather than the skb's originating task.
> >
> > Given that dev_queue_xmit() always executes with bh disabled, we can safely
> > use in_softirq() instead of in_serving_softirq() to properly identify the
> > softirq context and obtain the correct classid.
> >
>
> nit: you are no longer using in_softirq() in v2, you should update the
> commit message as well.
Oh, my bad.
I will update it.
--
Regards
Yafang
next prev parent reply other threads:[~2025-08-22 7:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-22 6:42 [PATCH v2] net/cls_cgroup: Fix task_get_classid() during qdisc run Yafang Shao
2025-08-22 7:26 ` Nikolay Aleksandrov
2025-08-22 7:34 ` Yafang Shao [this message]
2025-08-28 7:55 ` Paolo Abeni
2025-08-29 3:23 ` Yafang Shao
2025-08-29 8:14 ` Daniel Borkmann
2025-08-31 3:20 ` Yafang Shao
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='CALOAHbDoT8kmfbM9EnRcLP2o+2YpgN6ktn+p3UJMCeA=bOFopA@mail.gmail.com' \
--to=laoar.shao@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=paulmck@kernel.org \
--cc=razor@blackwall.org \
--cc=tgraf@suug.ch \
/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;
as well as URLs for NNTP newsgroup(s).