hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/net/sched/sch_sfb.c
....@@ -1,19 +1,15 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * net/sched/sch_sfb.c Stochastic Fair Blue
34 *
45 * Copyright (c) 2008-2011 Juliusz Chroboczek <jch@pps.jussieu.fr>
56 * Copyright (c) 2011 Eric Dumazet <eric.dumazet@gmail.com>
67 *
7
- * This program is free software; you can redistribute it and/or
8
- * modify it under the terms of the GNU General Public License
9
- * version 2 as published by the Free Software Foundation.
10
- *
118 * W. Feng, D. Kandlur, D. Saha, K. Shin. Blue:
129 * A New Class of Active Queue Management Algorithms.
1310 * U. Michigan CSE-TR-387-99, April 1999.
1411 *
1512 * http://www.thefengs.com/wuchang/blue/CSE-TR-387-99.pdf
16
- *
1713 */
1814
1915 #include <linux/module.h>
....@@ -139,15 +135,15 @@
139135 }
140136 }
141137
142
-static void increment_qlen(const struct sk_buff *skb, struct sfb_sched_data *q)
138
+static void increment_qlen(const struct sfb_skb_cb *cb, struct sfb_sched_data *q)
143139 {
144140 u32 sfbhash;
145141
146
- sfbhash = sfb_hash(skb, 0);
142
+ sfbhash = cb->hashes[0];
147143 if (sfbhash)
148144 increment_one_qlen(sfbhash, 0, q);
149145
150
- sfbhash = sfb_hash(skb, 1);
146
+ sfbhash = cb->hashes[1];
151147 if (sfbhash)
152148 increment_one_qlen(sfbhash, 1, q);
153149 }
....@@ -269,7 +265,7 @@
269265 case TC_ACT_QUEUED:
270266 case TC_ACT_TRAP:
271267 *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
272
- /* fall through */
268
+ fallthrough;
273269 case TC_ACT_SHOT:
274270 return false;
275271 }
....@@ -285,8 +281,10 @@
285281 {
286282
287283 struct sfb_sched_data *q = qdisc_priv(sch);
284
+ unsigned int len = qdisc_pkt_len(skb);
288285 struct Qdisc *child = q->qdisc;
289286 struct tcf_proto *fl;
287
+ struct sfb_skb_cb cb;
290288 int i;
291289 u32 p_min = ~0;
292290 u32 minqlen = ~0;
....@@ -403,11 +401,12 @@
403401 }
404402
405403 enqueue:
404
+ memcpy(&cb, sfb_skb_cb(skb), sizeof(cb));
406405 ret = qdisc_enqueue(skb, child, to_free);
407406 if (likely(ret == NET_XMIT_SUCCESS)) {
408
- qdisc_qstats_backlog_inc(sch, skb);
407
+ sch->qstats.backlog += len;
409408 sch->q.qlen++;
410
- increment_qlen(skb, q);
409
+ increment_qlen(&cb, q);
411410 } else if (net_xmit_drop_count(ret)) {
412411 q->stats.childdrop++;
413412 qdisc_qstats_drop(sch);
....@@ -456,9 +455,8 @@
456455 {
457456 struct sfb_sched_data *q = qdisc_priv(sch);
458457
459
- qdisc_reset(q->qdisc);
460
- sch->qstats.backlog = 0;
461
- sch->q.qlen = 0;
458
+ if (likely(q->qdisc))
459
+ qdisc_reset(q->qdisc);
462460 q->slot = 0;
463461 q->double_buffering = false;
464462 sfb_zero_all_buckets(q);
....@@ -493,14 +491,15 @@
493491 struct netlink_ext_ack *extack)
494492 {
495493 struct sfb_sched_data *q = qdisc_priv(sch);
496
- struct Qdisc *child;
494
+ struct Qdisc *child, *old;
497495 struct nlattr *tb[TCA_SFB_MAX + 1];
498496 const struct tc_sfb_qopt *ctl = &sfb_default_ops;
499497 u32 limit;
500498 int err;
501499
502500 if (opt) {
503
- err = nla_parse_nested(tb, TCA_SFB_MAX, opt, sfb_policy, NULL);
501
+ err = nla_parse_nested_deprecated(tb, TCA_SFB_MAX, opt,
502
+ sfb_policy, NULL);
504503 if (err < 0)
505504 return -EINVAL;
506505
....@@ -522,9 +521,8 @@
522521 qdisc_hash_add(child, true);
523522 sch_tree_lock(sch);
524523
525
- qdisc_tree_reduce_backlog(q->qdisc, q->qdisc->q.qlen,
526
- q->qdisc->qstats.backlog);
527
- qdisc_put(q->qdisc);
524
+ qdisc_purge_queue(q->qdisc);
525
+ old = q->qdisc;
528526 q->qdisc = child;
529527
530528 q->rehash_interval = msecs_to_jiffies(ctl->rehash_interval);
....@@ -547,6 +545,7 @@
547545 sfb_init_perturbation(1, q);
548546
549547 sch_tree_unlock(sch);
548
+ qdisc_put(old);
550549
551550 return 0;
552551 }
....@@ -582,7 +581,7 @@
582581 };
583582
584583 sch->qstats.backlog = q->qdisc->qstats.backlog;
585
- opts = nla_nest_start(skb, TCA_OPTIONS);
584
+ opts = nla_nest_start_noflag(skb, TCA_OPTIONS);
586585 if (opts == NULL)
587586 goto nla_put_failure;
588587 if (nla_put(skb, TCA_SFB_PARMS, sizeof(opt), &opt))