diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2021-12-06 18:57:47 +0200 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-12-08 14:31:14 -0800 |
commit | 3f9bb0301d50ce27421eff4b710c2bbe58111a83 (patch) | |
tree | 91271bc43b14b643d9b82b08df871ee3d2e8da22 /net/dsa/tag_dsa.c | |
parent | 1fe5b01262844be03de98afdd56d1d393df04d7e (diff) | |
download | linux-3f9bb0301d50ce27421eff4b710c2bbe58111a83.tar.gz linux-3f9bb0301d50ce27421eff4b710c2bbe58111a83.tar.bz2 linux-3f9bb0301d50ce27421eff4b710c2bbe58111a83.zip |
net: dsa: make dp->bridge_num one-based
I have seen too many bugs already due to the fact that we must encode an
invalid dp->bridge_num as a negative value, because the natural tendency
is to check that invalid value using (!dp->bridge_num). Latest example
can be seen in commit 1bec0f05062c ("net: dsa: fix bridge_num not
getting cleared after ports leaving the bridge").
Convert the existing users to assume that dp->bridge_num == 0 is the
encoding for invalid, and valid bridge numbers start from 1.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Alvin Šipraga <alsi@bang-olufsen.dk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/dsa/tag_dsa.c')
-rw-r--r-- | net/dsa/tag_dsa.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index b3da4b2ea11c..a7d70ae7cc97 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c @@ -140,7 +140,7 @@ static struct sk_buff *dsa_xmit_ll(struct sk_buff *skb, struct net_device *dev, * packets on behalf of a virtual switch device with an index * past the physical switches. */ - tag_dev = dst->last_switch + 1 + dp->bridge_num; + tag_dev = dst->last_switch + dp->bridge_num; tag_port = 0; } else { cmd = DSA_CMD_FROM_CPU; |