]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
net: dsa: sja1105: fix tc-gate schedule with single element
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 24 Jun 2020 13:54:47 +0000 (16:54 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 25 Jun 2020 23:06:56 +0000 (16:06 -0700)
commit43ce887c5050a3c213450a3058505f6a06519dd4
treeb018a46d8d216b8e33e2398293abf0db562c6786
parent82f6896a25ee2471fdf039eb7b286a692d78f504
net: dsa: sja1105: fix tc-gate schedule with single element

The sja1105_gating_cfg_time_to_interval function does this, as per the
comments:

/* The gate entries contain absolute times in their e->interval field. Convert
 * that to proper intervals (i.e. "0, 5, 10, 15" to "5, 5, 5, 5").
 */

To perform that task, it iterates over gating_cfg->entries, at each step
updating the interval of the _previous_ entry. So one interval remains
to be updated at the end of the loop: the last one (since it isn't
"prev" for anyone else).

But there was an erroneous check, that the last element's interval
should not be updated if it's also the only element. I'm not quite sure
why that check was there, but it's clearly incorrect, as a tc-gate
schedule with a single element would get an e->interval of zero,
regardless of the duration requested by the user. The switch wouldn't
even consider this configuration as valid: it will just drop all traffic
that matches the rule.

Fixes: 834f8933d5dd ("net: dsa: sja1105: implement tc-gate using time-triggered virtual links")
Reported-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/dsa/sja1105/sja1105_vl.c