aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIdo Schimmel <idosch@mellanox.com>2017-02-28 02:55:40 -0500
committerDavid S. Miller <davem@davemloft.net>2017-03-01 12:50:58 -0500
commitf7df4923fa986247e93ec2cdff5ca168fff14dcf (patch)
treed2d146826f43a321b88dc26d76adb728b87dd7cf
parent4f7bfb3982e02aacc5fb6e1a121e5326c1778ac3 (diff)
mlxsw: spectrum_router: Avoid potential packets loss
When the structure of the LPM tree changes (f.e., due to the addition of a new prefix), we unbind the old tree and then bind the new one. This may result in temporary packet loss. Instead, overwrite the old binding with the new one. Fixes: 6b75c4807db3 ("mlxsw: spectrum_router: Add virtual router management") 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>
-rw-r--r--drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c30
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
441mlxsw_sp_vr_lpm_tree_check(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr, 441mlxsw_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
474err_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
470static struct mlxsw_sp_vr *mlxsw_sp_vr_get(struct mlxsw_sp *mlxsw_sp, 480static struct mlxsw_sp_vr *mlxsw_sp_vr_get(struct mlxsw_sp *mlxsw_sp,