Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net/sched: taprio: make q->picos_per_byte available to fill_sched_entry()

In commit b5b73b26b3ca ("taprio: Fix allowing too small intervals"), a
comparison of user input against length_to_duration(q, ETH_ZLEN) was
introduced, to avoid RCU stalls due to frequent hrtimers.

The implementation of length_to_duration() depends on q->picos_per_byte
being set for the link speed. The blamed commit in the Fixes: tag has
moved this too late, so the checks introduced above are ineffective.
The q->picos_per_byte is zero at parse_taprio_schedule() ->
parse_sched_list() -> parse_sched_entry() -> fill_sched_entry() time.

Move the taprio_set_picos_per_byte() call as one of the first things in
taprio_change(), before the bulk of the netlink attribute parsing is
done. That's because it is needed there.

Add a selftest to make sure the issue doesn't get reintroduced.

Fixes: 09dbdf28f9f9 ("net/sched: taprio: fix calculation of maximum gate durations")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240527153955.553333-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vladimir Oltean and committed by
Jakub Kicinski
e6341341 56a5cf53

+25 -1
+3 -1
net/sched/sch_taprio.c
··· 1848 1848 } 1849 1849 q->flags = taprio_flags; 1850 1850 1851 + /* Needed for length_to_duration() during netlink attribute parsing */ 1852 + taprio_set_picos_per_byte(dev, q); 1853 + 1851 1854 err = taprio_parse_mqprio_opt(dev, mqprio, extack, q->flags); 1852 1855 if (err < 0) 1853 1856 return err; ··· 1910 1907 if (err < 0) 1911 1908 goto free_sched; 1912 1909 1913 - taprio_set_picos_per_byte(dev, q); 1914 1910 taprio_update_queue_max_sdu(q, new_admin, stab); 1915 1911 1916 1912 if (FULL_OFFLOAD_IS_ENABLED(q->flags))
+22
tools/testing/selftests/tc-testing/tc-tests/qdiscs/taprio.json
··· 133 133 ] 134 134 }, 135 135 { 136 + "id": "6f62", 137 + "name": "Add taprio Qdisc with too short interval", 138 + "category": [ 139 + "qdisc", 140 + "taprio" 141 + ], 142 + "plugins": { 143 + "requires": "nsPlugin" 144 + }, 145 + "setup": [ 146 + "echo \"1 1 8\" > /sys/bus/netdevsim/new_device" 147 + ], 148 + "cmdUnderTest": "$TC qdisc add dev $ETH root handle 1: taprio num_tc 2 queues 1@0 1@1 sched-entry S 01 300 sched-entry S 02 1700 clockid CLOCK_TAI", 149 + "expExitCode": "2", 150 + "verifyCmd": "$TC qdisc show dev $ETH", 151 + "matchPattern": "qdisc taprio 1: root refcnt", 152 + "matchCount": "0", 153 + "teardown": [ 154 + "echo \"1\" > /sys/bus/netdevsim/del_device" 155 + ] 156 + }, 157 + { 136 158 "id": "3e1e", 137 159 "name": "Add taprio Qdisc with an invalid cycle-time", 138 160 "category": [