mlxsw: spectrum_router: Fix handling of neighbour structure
authorJiri Pirko <jiri@mellanox.com>
Thu, 10 Nov 2016 11:31:04 +0000 (12:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Nov 2016 18:02:15 +0000 (13:02 -0500)
commit33b1341cd1bf5c89e7ef332aa8ac3ed614a3d942
tree516ea68da5d5e948bf32aeb098a72e2042165470
parent2ce0af8fd0a6c2938e49630a0fdf3257464576e3
mlxsw: spectrum_router: Fix handling of neighbour structure

__neigh_create function works in a different way than assumed.
It passes "n" as a parameter to ndo_neigh_construct. But this "n" might
be destroyed right away before __neigh_create() returns in case there is
already another neighbour struct in the hashtable with the same dev and
primary key. That is not expected by mlxsw_sp_router_neigh_construct()
and the stored "n" points to freed memory, eventually leading to crash.

Fix this by doing tight 1:1 coupling between neighbour struct and
internal driver neigh_entry. That allows to narrow down the key in
internal driver hashtable to do lookups by "n" only.

Fixes: 6cf3c971dc84 ("mlxsw: spectrum_router: Add private neigh table")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c