Skip to contentSkip to conversation

devlink: Fix length of eswitch inline-mode

PATCH Applied William Tu 4 participants 4 messages Mar 10, 2024 – Mar 11, 2024

Subsystems (4)
lore
Share & tools
lore

William Tu

author
#0 lore raw

PATCH 1/1 devlink: Fix length of eswitch inline-mode

Set eswitch inline-mode to be u8, not u16. Otherwise, errors below

$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev \
  inline-mode network
    Error: Attribute failed policy validation.
    kernel answers: Numerical result out of rang
    netlink: 'devlink': attribute type 26 has an invalid length.
Fixes f2f9dd164db0 ("netlink: specs: devlink: add the remaining command to generate complete split_ops")

---
Or we can fix the iproute2 to use u16?

---
 Documentation/netlink/specs/devlink.yaml | 2 +-
 net/devlink/netlink_gen.c                | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Documentation/netlink/specs/devlink.yaml +1 -1
index cf6eaa0da821..09fbb4c03fc8 100644
@@ -290,7 +290,7 @@ attribute-sets:
         enum: eswitch-mode
       -
         name: eswitch-inline-mode
-        type: u16
+        type: u8
         enum: eswitch-inline-mode
       -
         name: dpipe-tables
net/devlink/netlink_gen.c +1 -1
index c81cf2dd154f..f9786d51f68f 100644
@@ -198,7 +198,7 @@ static const struct nla_policy devlink_eswitch_set_nl_policy[DEVLINK_ATTR_ESWITC
 	[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING, },
 	[DEVLINK_ATTR_ESWITCH_MODE] = NLA_POLICY_MAX(NLA_U16, 1),
-	[DEVLINK_ATTR_ESWITCH_INLINE_MODE] = NLA_POLICY_MAX(NLA_U16, 3),
+	[DEVLINK_ATTR_ESWITCH_INLINE_MODE] = NLA_POLICY_MAX(NLA_U8, 3),
 	[DEVLINK_ATTR_ESWITCH_ENCAP_MODE] = NLA_POLICY_MAX(NLA_U8, 1),
 };
 
Signature · 1 line
2.38.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Sun, Mar 10, 2024 at 05:45:47PM CET, [email protected] wrote:

Set eswitch inline-mode to be u8, not u16. Otherwise, errors below

$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev \
 inline-mode network
   Error: Attribute failed policy validation.
   kernel answers: Numerical result out of rang
   netlink: 'devlink': attribute type 26 has an invalid length.
Fixes f2f9dd164db0 ("netlink: specs: devlink: add the remaining command to generate complete split_ops")

Oops. I wonder if I messed anything else.

Thanks!

Quoted 3 lines

---
Or we can fix the iproute2 to use u16?

Nope, this is UAPI.

reviewer Reviewed-by on v1 1/1
#2 lore raw
In reply to William Tu
Quoted 8 lines · William Tu

Set eswitch inline-mode to be u8, not u16. Otherwise, errors below

$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev \
  inline-mode network
    Error: Attribute failed policy validation.
    kernel answers: Numerical result out of rang
    netlink: 'devlink': attribute type 26 has an invalid length.
Quoted 4 lines
Fixes f2f9dd164db0 ("netlink: specs: devlink: add the remaining command to generate complete split_ops")

---
Or we can fix the iproute2 to use u16?

My understanding is that it was u8, prior to changes moving the code to use specs, so I think that fixing the kernel to once again use u8 is appropriate.

...

#3 lore raw
In reply to William Tu
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Sun, 10 Mar 2024 18:45:47 +0200 you wrote:

Set eswitch inline-mode to be u8, not u16. Otherwise, errors below

$ devlink dev eswitch set pci/0000:08:00.0 mode switchdev \
  inline-mode network
    Error: Attribute failed policy validation.
    kernel answers: Numerical result out of rang
    netlink: 'devlink': attribute type 26 has an invalid length.

[...]

Here is the summary with links:
- [net] devlink: Fix length of eswitch inline-mode

    https://git.kernel.org/netdev/net/c/8f4cd89bf106

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html