OSDN Git Service

mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree
authorIdo Schimmel <idosch@mellanox.com>
Mon, 22 Jan 2018 08:17:42 +0000 (09:17 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 22 Jan 2018 14:22:11 +0000 (09:22 -0500)
commit2b52ce02e1d17986ad7da8bc6e96c632dfa73219
tree5f8907de0f205a4f96fd8c4dd5772592006816af
parent3aad95df920ede6a487ef244a5d3dbd6a8e68c5b
mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree

In commit fc922bb0dd94 ("mlxsw: spectrum_router: Use one LPM tree for
all virtual routers") I tried to make sure only used prefix lengths are
present in the LPM tree shared between all virtual routers.

However, this optimization had to be removed in commit a69518cf0b4c
("mlxsw: spectrum_router: Avoid expensive lookup during route removal"),
since determining the used prefix lengths required us to traverse all
the active virtual routers, which could result in a hung task depending
on the number of VRFs and whether routes were removed due to abort or
not.

Re-introduce the optimization by moving the prefix usage accounting from
the virtual routers to the LPM tree, as this accounting is only used in
order to determine the tree's structure.

To make the sharing of the trees more explicit, the two trees (for IPv4
and IPv6) are stored in the shared router struct and upon the creation
of a virtual router it is immediately bound to both.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c