[PATCH net mlxsw 0/2] mlxsw: Fix a problem in port_vlan reference counting

Petr Machata petrm at mellanox.com
Fri Jun 8 01:01:13 AEST 2018

Switchdev notifications for addition of SWITCHDEV_OBJ_ID_PORT_VLAN are
distributed not only on clean addition, but also when flags on an
existing VLAN are changed.

But when handling these notifications, spectrum_switchdev.c in
mlxsw_sp_bridge_port_vlan_add() calls mlxsw_sp_port_vlan_get(), thus
bumping the reference count every time the VLAN flags are changed. This
then leads to discrepancies in reference counting when the VLAN is
removed. spectrum.c warns about the problem on deinit:

[13578.493090] WARNING: CPU: 0 PID: 2454 at drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2973 mlxsw_sp_port_remove+0xfd/0x110 [mlxsw_spectrum]
[13578.627106] Call Trace:
[13578.629617]  mlxsw_sp_fini+0x2a/0xe0 [mlxsw_spectrum]
[13578.634748]  mlxsw_core_bus_device_unregister+0x3e/0x130 [mlxsw_core]
[13578.641290]  mlxsw_pci_remove+0x13/0x40 [mlxsw_pci]
[13578.646238]  pci_device_remove+0x31/0xb0
[13578.650244]  device_release_driver_internal+0x14f/0x220
[13578.655562]  driver_detach+0x32/0x70
[13578.659183]  bus_remove_driver+0x47/0xa0
[13578.663134]  pci_unregister_driver+0x1e/0x80
[13578.667486]  mlxsw_sp_module_exit+0xc/0x3fa [mlxsw_spectrum]
[13578.673207]  __x64_sys_delete_module+0x13b/0x1e0
[13578.677888]  ? exit_to_usermode_loop+0x78/0x80
[13578.682374]  do_syscall_64+0x39/0xe0
[13578.685976]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fix this problem by first publishing the function
mlxsw_sp_port_vlan_create() (in patch #1) and then replacing the
problematic call with a combination of mlxsw_sp_port_vlan_find_by_vid()
and the newly-published create function (in patch #2).

Petr Machata (2):
  mlxsw: spectrum: Publish mlxsw_sp_port_vlan_create()
  mlxsw: spectrum_switchdev: Fix port_vlan refcounting

 drivers/net/ethernet/mellanox/mlxsw/spectrum.c           | 2 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h           | 2 ++
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 5 ++++-
 3 files changed, 7 insertions(+), 2 deletions(-)


More information about the Linux-mlxsw mailing list