diff options
-rw-r--r-- | drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c index d7ac22d7f940..bd8de6b9be71 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | |||
@@ -441,30 +441,40 @@ static int | |||
441 | mlxsw_sp_vr_lpm_tree_check(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr, | 441 | mlxsw_sp_vr_lpm_tree_check(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr, |
442 | struct mlxsw_sp_prefix_usage *req_prefix_usage) | 442 | struct mlxsw_sp_prefix_usage *req_prefix_usage) |
443 | { | 443 | { |
444 | struct mlxsw_sp_lpm_tree *lpm_tree; | 444 | struct mlxsw_sp_lpm_tree *lpm_tree = vr->lpm_tree; |
445 | struct mlxsw_sp_lpm_tree *new_tree; | ||
446 | int err; | ||
445 | 447 | ||
446 | if (mlxsw_sp_prefix_usage_eq(req_prefix_usage, | 448 | if (mlxsw_sp_prefix_usage_eq(req_prefix_usage, &lpm_tree->prefix_usage)) |
447 | &vr->lpm_tree->prefix_usage)) | ||
448 | return 0; | 449 | return 0; |
449 | 450 | ||
450 | lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, req_prefix_usage, | 451 | new_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, req_prefix_usage, |
451 | vr->proto, false); | 452 | vr->proto, false); |
452 | if (IS_ERR(lpm_tree)) { | 453 | if (IS_ERR(new_tree)) { |
453 | /* We failed to get a tree according to the required | 454 | /* We failed to get a tree according to the required |
454 | * prefix usage. However, the current tree might be still good | 455 | * prefix usage. However, the current tree might be still good |
455 | * for us if our requirement is subset of the prefixes used | 456 | * for us if our requirement is subset of the prefixes used |
456 | * in the tree. | 457 | * in the tree. |
457 | */ | 458 | */ |
458 | if (mlxsw_sp_prefix_usage_subset(req_prefix_usage, | 459 | if (mlxsw_sp_prefix_usage_subset(req_prefix_usage, |
459 | &vr->lpm_tree->prefix_usage)) | 460 | &lpm_tree->prefix_usage)) |
460 | return 0; | 461 | return 0; |
461 | return PTR_ERR(lpm_tree); | 462 | return PTR_ERR(new_tree); |
462 | } | 463 | } |
463 | 464 | ||
464 | mlxsw_sp_vr_lpm_tree_unbind(mlxsw_sp, vr); | 465 | /* Prevent packet loss by overwriting existing binding */ |
465 | mlxsw_sp_lpm_tree_put(mlxsw_sp, vr->lpm_tree); | 466 | vr->lpm_tree = new_tree; |
467 | err = mlxsw_sp_vr_lpm_tree_bind(mlxsw_sp, vr); | ||
468 | if (err) | ||
469 | goto err_tree_bind; | ||
470 | mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); | ||
471 | |||
472 | return 0; | ||
473 | |||
474 | err_tree_bind: | ||
466 | vr->lpm_tree = lpm_tree; | 475 | vr->lpm_tree = lpm_tree; |
467 | return mlxsw_sp_vr_lpm_tree_bind(mlxsw_sp, vr); | 476 | mlxsw_sp_lpm_tree_put(mlxsw_sp, new_tree); |
477 | return err; | ||
468 | } | 478 | } |
469 | 479 | ||
470 | static struct mlxsw_sp_vr *mlxsw_sp_vr_get(struct mlxsw_sp *mlxsw_sp, | 480 | static struct mlxsw_sp_vr *mlxsw_sp_vr_get(struct mlxsw_sp *mlxsw_sp, |