]>
Commit | Line | Data |
---|---|---|
a65d4bac GKH |
1 | From foo@baz Sat Jul 28 10:25:26 CEST 2018 |
2 | From: Petr Machata <petrm@mellanox.com> | |
3 | Date: Fri, 15 Jun 2018 16:23:38 +0300 | |
4 | Subject: mlxsw: spectrum_switchdev: Fix port_vlan refcounting | |
5 | ||
6 | From: Petr Machata <petrm@mellanox.com> | |
7 | ||
8 | [ Upstream commit 9e25826ffc942e985b8595b2f1cf2065d3880514 ] | |
9 | ||
10 | Switchdev notifications for addition of SWITCHDEV_OBJ_ID_PORT_VLAN are | |
11 | distributed not only on clean addition, but also when flags on an | |
12 | existing VLAN are changed. mlxsw_sp_bridge_port_vlan_add() calls | |
13 | mlxsw_sp_port_vlan_get() to get at the port_vlan in question, which | |
14 | implicitly references the object. This then leads to discrepancies in | |
15 | reference counting when the VLAN is removed. spectrum.c warns about the | |
16 | problem when the module is removed: | |
17 | ||
18 | [13578.493090] WARNING: CPU: 0 PID: 2454 at drivers/net/ethernet/mellanox/mlxsw/spectrum.c:2973 mlxsw_sp_port_remove+0xfd/0x110 [mlxsw_spectrum] | |
19 | [...] | |
20 | [13578.627106] Call Trace: | |
21 | [13578.629617] mlxsw_sp_fini+0x2a/0xe0 [mlxsw_spectrum] | |
22 | [13578.634748] mlxsw_core_bus_device_unregister+0x3e/0x130 [mlxsw_core] | |
23 | [13578.641290] mlxsw_pci_remove+0x13/0x40 [mlxsw_pci] | |
24 | [13578.646238] pci_device_remove+0x31/0xb0 | |
25 | [13578.650244] device_release_driver_internal+0x14f/0x220 | |
26 | [13578.655562] driver_detach+0x32/0x70 | |
27 | [13578.659183] bus_remove_driver+0x47/0xa0 | |
28 | [13578.663134] pci_unregister_driver+0x1e/0x80 | |
29 | [13578.667486] mlxsw_sp_module_exit+0xc/0x3fa [mlxsw_spectrum] | |
30 | [13578.673207] __x64_sys_delete_module+0x13b/0x1e0 | |
31 | [13578.677888] ? exit_to_usermode_loop+0x78/0x80 | |
32 | [13578.682374] do_syscall_64+0x39/0xe0 | |
33 | [13578.685976] entry_SYSCALL_64_after_hwframe+0x44/0xa9 | |
34 | ||
35 | Fix by putting the port_vlan when mlxsw_sp_port_vlan_bridge_join() | |
36 | determines it's a flag-only change. | |
37 | ||
38 | Fixes: b3529af6bb0d ("spectrum: Reference count VLAN entries") | |
39 | Signed-off-by: Petr Machata <petrm@mellanox.com> | |
40 | Acked-by: Jiri Pirko <jiri@mellanox.com> | |
41 | Signed-off-by: Ido Schimmel <idosch@mellanox.com> | |
42 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
43 | Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> | |
44 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
45 | --- | |
46 | drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 4 +++- | |
47 | 1 file changed, 3 insertions(+), 1 deletion(-) | |
48 | ||
49 | --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | |
50 | +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | |
51 | @@ -912,8 +912,10 @@ mlxsw_sp_port_vlan_bridge_join(struct ml | |
52 | int err; | |
53 | ||
54 | /* No need to continue if only VLAN flags were changed */ | |
55 | - if (mlxsw_sp_port_vlan->bridge_port) | |
56 | + if (mlxsw_sp_port_vlan->bridge_port) { | |
57 | + mlxsw_sp_port_vlan_put(mlxsw_sp_port_vlan); | |
58 | return 0; | |
59 | + } | |
60 | ||
61 | err = mlxsw_sp_port_vlan_fid_join(mlxsw_sp_port_vlan, bridge_port); | |
62 | if (err) |