@@ -4771,11 +4771,11 @@ mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
4771
4771
4772
4772
static struct mlxsw_sp_fib6_entry *
4773
4773
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 )
4775
4775
{
4776
4776
struct mlxsw_sp_fib6_entry * fib6_entry ;
4777
4777
4778
- if (!mlxsw_sp_fib6_rt_can_mp ( nrt ) || replace )
4778
+ if (!append )
4779
4779
return NULL ;
4780
4780
4781
4781
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,
4790
4790
break ;
4791
4791
if (rt -> fib6_metric < nrt -> fib6_metric )
4792
4792
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 )
4795
4794
return fib6_entry ;
4796
4795
if (rt -> fib6_metric > nrt -> fib6_metric )
4797
4796
break ;
@@ -5316,7 +5315,8 @@ static void mlxsw_sp_fib6_entry_replace(struct mlxsw_sp *mlxsw_sp,
5316
5315
}
5317
5316
5318
5317
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 )
5320
5320
{
5321
5321
struct mlxsw_sp_fib6_entry * fib6_entry ;
5322
5322
struct mlxsw_sp_fib_node * fib_node ;
@@ -5342,14 +5342,22 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5342
5342
/* Before creating a new entry, try to append route to an existing
5343
5343
* multipath entry.
5344
5344
*/
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 );
5346
5346
if (fib6_entry ) {
5347
5347
err = mlxsw_sp_fib6_entry_nexthop_add (mlxsw_sp , fib6_entry , rt );
5348
5348
if (err )
5349
5349
goto err_fib6_entry_nexthop_add ;
5350
5350
return 0 ;
5351
5351
}
5352
5352
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
+
5353
5361
fib6_entry = mlxsw_sp_fib6_entry_create (mlxsw_sp , fib_node , rt );
5354
5362
if (IS_ERR (fib6_entry )) {
5355
5363
err = PTR_ERR (fib6_entry );
@@ -5367,6 +5375,7 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
5367
5375
err_fib6_node_entry_link :
5368
5376
mlxsw_sp_fib6_entry_destroy (mlxsw_sp , fib6_entry );
5369
5377
err_fib6_entry_create :
5378
+ err_fib6_entry_append :
5370
5379
err_fib6_entry_nexthop_add :
5371
5380
mlxsw_sp_fib_node_put (mlxsw_sp , fib_node );
5372
5381
return err ;
@@ -5717,7 +5726,7 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
5717
5726
struct mlxsw_sp_fib_event_work * fib_work =
5718
5727
container_of (work , struct mlxsw_sp_fib_event_work , work );
5719
5728
struct mlxsw_sp * mlxsw_sp = fib_work -> mlxsw_sp ;
5720
- bool replace ;
5729
+ bool replace , append ;
5721
5730
int err ;
5722
5731
5723
5732
rtnl_lock ();
@@ -5728,8 +5737,10 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
5728
5737
case FIB_EVENT_ENTRY_APPEND : /* fall through */
5729
5738
case FIB_EVENT_ENTRY_ADD :
5730
5739
replace = fib_work -> event == FIB_EVENT_ENTRY_REPLACE ;
5740
+ append = fib_work -> event == FIB_EVENT_ENTRY_APPEND ;
5731
5741
err = mlxsw_sp_router_fib6_add (mlxsw_sp ,
5732
- fib_work -> fen6_info .rt , replace );
5742
+ fib_work -> fen6_info .rt , replace ,
5743
+ append );
5733
5744
if (err )
5734
5745
mlxsw_sp_router_fib_abort (mlxsw_sp );
5735
5746
mlxsw_sp_rt6_release (fib_work -> fen6_info .rt );
0 commit comments