Skip to content

Commit 53b562d

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum_router: Allow appending to dev-only routes
Commit f34436a ("net/ipv6: Simplify route replace and appending into multipath route") changed the IPv6 route append logic so that dev-only routes can be appended and not only gatewayed routes. Align mlxsw with the new behaviour. Fixes: f34436a ("net/ipv6: Simplify route replace and appending into multipath route") Signed-off-by: Ido Schimmel <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6eba08c commit 53b562d

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4771,11 +4771,11 @@ mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
47714771

47724772
static struct mlxsw_sp_fib6_entry *
47734773
mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
4774-
const struct fib6_info *nrt, bool replace)
4774+
const struct fib6_info *nrt, bool append)
47754775
{
47764776
struct mlxsw_sp_fib6_entry *fib6_entry;
47774777

4778-
if (!mlxsw_sp_fib6_rt_can_mp(nrt) || replace)
4778+
if (!append)
47794779
return NULL;
47804780

47814781
list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
@@ -4790,8 +4790,7 @@ mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
47904790
break;
47914791
if (rt->fib6_metric < nrt->fib6_metric)
47924792
continue;
4793-
if (rt->fib6_metric == nrt->fib6_metric &&
4794-
mlxsw_sp_fib6_rt_can_mp(rt))
4793+
if (rt->fib6_metric == nrt->fib6_metric)
47954794
return fib6_entry;
47964795
if (rt->fib6_metric > nrt->fib6_metric)
47974796
break;
@@ -5316,7 +5315,8 @@ static void mlxsw_sp_fib6_entry_replace(struct mlxsw_sp *mlxsw_sp,
53165315
}
53175316

53185317
static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5319-
struct fib6_info *rt, bool replace)
5318+
struct fib6_info *rt, bool replace,
5319+
bool append)
53205320
{
53215321
struct mlxsw_sp_fib6_entry *fib6_entry;
53225322
struct mlxsw_sp_fib_node *fib_node;
@@ -5342,14 +5342,22 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
53425342
/* Before creating a new entry, try to append route to an existing
53435343
* multipath entry.
53445344
*/
5345-
fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, replace);
5345+
fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, append);
53465346
if (fib6_entry) {
53475347
err = mlxsw_sp_fib6_entry_nexthop_add(mlxsw_sp, fib6_entry, rt);
53485348
if (err)
53495349
goto err_fib6_entry_nexthop_add;
53505350
return 0;
53515351
}
53525352

5353+
/* We received an append event, yet did not find any route to
5354+
* append to.
5355+
*/
5356+
if (WARN_ON(append)) {
5357+
err = -EINVAL;
5358+
goto err_fib6_entry_append;
5359+
}
5360+
53535361
fib6_entry = mlxsw_sp_fib6_entry_create(mlxsw_sp, fib_node, rt);
53545362
if (IS_ERR(fib6_entry)) {
53555363
err = PTR_ERR(fib6_entry);
@@ -5367,6 +5375,7 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
53675375
err_fib6_node_entry_link:
53685376
mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry);
53695377
err_fib6_entry_create:
5378+
err_fib6_entry_append:
53705379
err_fib6_entry_nexthop_add:
53715380
mlxsw_sp_fib_node_put(mlxsw_sp, fib_node);
53725381
return err;
@@ -5717,7 +5726,7 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
57175726
struct mlxsw_sp_fib_event_work *fib_work =
57185727
container_of(work, struct mlxsw_sp_fib_event_work, work);
57195728
struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp;
5720-
bool replace;
5729+
bool replace, append;
57215730
int err;
57225731

57235732
rtnl_lock();
@@ -5728,8 +5737,10 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
57285737
case FIB_EVENT_ENTRY_APPEND: /* fall through */
57295738
case FIB_EVENT_ENTRY_ADD:
57305739
replace = fib_work->event == FIB_EVENT_ENTRY_REPLACE;
5740+
append = fib_work->event == FIB_EVENT_ENTRY_APPEND;
57315741
err = mlxsw_sp_router_fib6_add(mlxsw_sp,
5732-
fib_work->fen6_info.rt, replace);
5742+
fib_work->fen6_info.rt, replace,
5743+
append);
57335744
if (err)
57345745
mlxsw_sp_router_fib_abort(mlxsw_sp);
57355746
mlxsw_sp_rt6_release(fib_work->fen6_info.rt);

0 commit comments

Comments
 (0)