rtnetlink: remove redundant checks for nlattr IFLA_BRIDGE_MODE
authorLin Ma <linma@zju.edu.cn>
Mon, 7 Aug 2023 09:13:47 +0000 (17:13 +0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 8 Aug 2023 22:10:37 +0000 (15:10 -0700)
The commit d73ef2d69c0d ("rtnetlink: let rtnl_bridge_setlink checks
IFLA_BRIDGE_MODE length") added the nla_len check in rtnl_bridge_setlink,
which is the only caller for ndo_bridge_setlink handlers defined in
low-level driver codes. Hence, this patch cleanups the redundant checks in
each ndo_bridge_setlink handler function.

Suggested-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Lin Ma <linma@zju.edu.cn>
Acked-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20230807091347.3804523-1-linma@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/emulex/benet/be_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c

index eb168ca983b753663ee99fbda1db6639a93f2fa7..7be917a8da482bb287296e7439e7de5e0b823bcb 100644 (file)
@@ -13132,9 +13132,6 @@ static int bnxt_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
                if (nla_type(attr) != IFLA_BRIDGE_MODE)
                        continue;
 
-               if (nla_len(attr) < sizeof(mode))
-                       return -EINVAL;
-
                mode = nla_get_u16(attr);
                if (mode == bp->br_mode)
                        break;
index 0616b5fe241cbe26f022f7c36fe01185fdb92fbe..ad862ed7888ac40cd51a2cb01f058331e73cfb7e 100644 (file)
@@ -4986,9 +4986,6 @@ static int be_ndo_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
                if (nla_type(attr) != IFLA_BRIDGE_MODE)
                        continue;
 
-               if (nla_len(attr) < sizeof(mode))
-                       return -EINVAL;
-
                mode = nla_get_u16(attr);
                if (BE3_chip(adapter) && mode == BRIDGE_MODE_VEPA)
                        return -EOPNOTSUPP;
index 8eb9839a3ca690196e9285a1036bd228c61276ad..dd03b017dfc518c464373732e09027f4c68db07a 100644 (file)
@@ -10042,9 +10042,6 @@ static int ixgbe_ndo_bridge_setlink(struct net_device *dev,
                if (nla_type(attr) != IFLA_BRIDGE_MODE)
                        continue;
 
-               if (nla_len(attr) < sizeof(mode))
-                       return -EINVAL;
-
                mode = nla_get_u16(attr);
                status = ixgbe_configure_bridge_mode(adapter, mode);
                if (status)
index c8ec6467d4d16d80e1ec370012d7528d6051cb06..ca80c220e4b0edbaba69a067b13ded313743d947 100644 (file)
@@ -4896,9 +4896,6 @@ static int mlx5e_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
                if (nla_type(attr) != IFLA_BRIDGE_MODE)
                        continue;
 
-               if (nla_len(attr) < sizeof(mode))
-                       return -EINVAL;
-
                mode = nla_get_u16(attr);
                if (mode > BRIDGE_MODE_VEPA)
                        return -EINVAL;
index f18c791cf698f6b83eb26df4c86089e40db51569..de0a5d5ded305b7ed40e984e2c7fc8f0635d3367 100644 (file)
@@ -2108,9 +2108,6 @@ static int nfp_net_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh,
                if (nla_type(attr) != IFLA_BRIDGE_MODE)
                        continue;
 
-               if (nla_len(attr) < sizeof(mode))
-                       return -EINVAL;
-
                new_ctrl = nn->dp.ctrl;
                mode = nla_get_u16(attr);
                if (mode == BRIDGE_MODE_VEPA)