diff mbox series

[net] sch_sfb: Also store skb len before calling child enqueue

Message ID 20220905192137.965549-1-toke@toke.dk (mailing list archive)
State Accepted
Commit 2f09707d0c972120bf794cfe0f0c67e2c2ddb252
Delegated to: Netdev Maintainers
Headers show
Series [net] sch_sfb: Also store skb len before calling child enqueue | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Toke Høiland-Jørgensen Sept. 5, 2022, 7:21 p.m. UTC
Cong Wang noticed that the previous fix for sch_sfb accessing the queued
skb after enqueueing it to a child qdisc was incomplete: the SFB enqueue
function was also calling qdisc_qstats_backlog_inc() after enqueue, which
reads the pkt len from the skb cb field. Fix this by also storing the skb
len, and using the stored value to increment the backlog after enqueueing.

Fixes: 9efd23297cca ("sch_sfb: Don't assume the skb is still around after enqueueing to child")
Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
---
 net/sched/sch_sfb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Cong Wang Sept. 7, 2022, 5:27 p.m. UTC | #1
On Mon, Sep 05, 2022 at 09:21:36PM +0200, Toke Høiland-Jørgensen wrote:
> Cong Wang noticed that the previous fix for sch_sfb accessing the queued
> skb after enqueueing it to a child qdisc was incomplete: the SFB enqueue
> function was also calling qdisc_qstats_backlog_inc() after enqueue, which
> reads the pkt len from the skb cb field. Fix this by also storing the skb
> len, and using the stored value to increment the backlog after enqueueing.
> 
> Fixes: 9efd23297cca ("sch_sfb: Don't assume the skb is still around after enqueueing to child")
> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>

Acked-by: Cong Wang <cong.wang@bytedance.com>

Thanks.
patchwork-bot+netdevbpf@kernel.org Sept. 8, 2022, 9:30 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Mon,  5 Sep 2022 21:21:36 +0200 you wrote:
> Cong Wang noticed that the previous fix for sch_sfb accessing the queued
> skb after enqueueing it to a child qdisc was incomplete: the SFB enqueue
> function was also calling qdisc_qstats_backlog_inc() after enqueue, which
> reads the pkt len from the skb cb field. Fix this by also storing the skb
> len, and using the stored value to increment the backlog after enqueueing.
> 
> Fixes: 9efd23297cca ("sch_sfb: Don't assume the skb is still around after enqueueing to child")
> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
> 
> [...]

Here is the summary with links:
  - [net] sch_sfb: Also store skb len before calling child enqueue
    https://git.kernel.org/netdev/net/c/2f09707d0c97

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c
index 0d761f454ae8..2829455211f8 100644
--- a/net/sched/sch_sfb.c
+++ b/net/sched/sch_sfb.c
@@ -281,6 +281,7 @@  static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 {
 
 	struct sfb_sched_data *q = qdisc_priv(sch);
+	unsigned int len = qdisc_pkt_len(skb);
 	struct Qdisc *child = q->qdisc;
 	struct tcf_proto *fl;
 	struct sfb_skb_cb cb;
@@ -403,7 +404,7 @@  static int sfb_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 	memcpy(&cb, sfb_skb_cb(skb), sizeof(cb));
 	ret = qdisc_enqueue(skb, child, to_free);
 	if (likely(ret == NET_XMIT_SUCCESS)) {
-		qdisc_qstats_backlog_inc(sch, skb);
+		sch->qstats.backlog += len;
 		sch->q.qlen++;
 		increment_qlen(&cb, q);
 	} else if (net_xmit_drop_count(ret)) {