mlxsw: spectrum_router: Compare only trees which are in use during tree get
authorJiri Pirko <jiri@mellanox.com>
Tue, 25 Oct 2016 09:25:57 +0000 (11:25 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 28 Oct 2016 17:43:56 +0000 (13:43 -0400)
Only trees which are in use should be compared to requested prefix usage.

Fixes: 53342023eed9 ("mlxsw: spectrum_router: Implement LPM trees management")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

index 4cff4c043d11911074757826fc85b7354ee6ea72..4573da2c55602b8b412fdf6a90296b306d5291de 100644 (file)
@@ -345,7 +345,8 @@ mlxsw_sp_lpm_tree_get(struct mlxsw_sp *mlxsw_sp,
 
        for (i = 0; i < MLXSW_SP_LPM_TREE_COUNT; i++) {
                lpm_tree = &mlxsw_sp->router.lpm_trees[i];
-               if (lpm_tree->proto == proto &&
+               if (lpm_tree->ref_count != 0 &&
+                   lpm_tree->proto == proto &&
                    mlxsw_sp_prefix_usage_eq(&lpm_tree->prefix_usage,
                                             prefix_usage))
                        goto inc_ref_count;