Skip to content

Commit b28d8f0

Browse files
paravmellanoxkuba-moo
authored andcommitted
devlink: Correct VIRTUAL port to not have phys_port attributes
Physical port name, port number attributes do not belong to virtual port flavour. When VF or SF virtual ports are registered they incorrectly append "np0" string in the netdevice name of the VF/SF. Before this fix, VF netdevice name were ens2f0np0v0, ens2f0np0v1 for VF 0 and 1 respectively. After the fix, they are ens2f0v0, ens2f0v1. With this fix, reading /sys/class/net/ens2f0v0/phys_port_name returns -EOPNOTSUPP. Also devlink port show example for 2 VFs on one PF to ensure that any physical port attributes are not exposed. $ devlink port show pci/0000:06:00.0/65535: type eth netdev ens2f0np0 flavour physical port 0 splittable false pci/0000:06:00.3/196608: type eth netdev ens2f0v0 flavour virtual splittable false pci/0000:06:00.4/262144: type eth netdev ens2f0v1 flavour virtual splittable false This change introduces a netdevice name change on systemd/udev version 245 and higher which honors phys_port_name sysfs file for generation of netdevice name. This also aligns to phys_port_name usage which is limited to switchdev ports as described in [1]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next.git/tree/Documentation/networking/switchdev.rst Fixes: acf1ee4 ("devlink: Introduce devlink port flavour virtual") Signed-off-by: Parav Pandit <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d7c5303 commit b28d8f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/core/devlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ static int devlink_nl_port_attrs_put(struct sk_buff *msg,
705705
case DEVLINK_PORT_FLAVOUR_PHYSICAL:
706706
case DEVLINK_PORT_FLAVOUR_CPU:
707707
case DEVLINK_PORT_FLAVOUR_DSA:
708-
case DEVLINK_PORT_FLAVOUR_VIRTUAL:
709708
if (nla_put_u32(msg, DEVLINK_ATTR_PORT_NUMBER,
710709
attrs->phys.port_number))
711710
return -EMSGSIZE;
@@ -8631,7 +8630,6 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
86318630

86328631
switch (attrs->flavour) {
86338632
case DEVLINK_PORT_FLAVOUR_PHYSICAL:
8634-
case DEVLINK_PORT_FLAVOUR_VIRTUAL:
86358633
if (!attrs->split)
86368634
n = snprintf(name, len, "p%u", attrs->phys.port_number);
86378635
else
@@ -8679,6 +8677,8 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
86798677
n = snprintf(name, len, "pf%usf%u", attrs->pci_sf.pf,
86808678
attrs->pci_sf.sf);
86818679
break;
8680+
case DEVLINK_PORT_FLAVOUR_VIRTUAL:
8681+
return -EOPNOTSUPP;
86828682
}
86838683

86848684
if (n >= len)

0 commit comments

Comments
 (0)