@@ -145,7 +145,7 @@ static int _nexthop_source_cmp(const struct nexthop *nh1,
145145}
146146
147147static int _nexthop_cmp_no_labels (const struct nexthop * next1 ,
148- const struct nexthop * next2 , bool use_weight )
148+ const struct nexthop * next2 , bool use_weight , bool use_ifindex )
149149{
150150 int ret = 0 ;
151151
@@ -181,6 +181,8 @@ static int _nexthop_cmp_no_labels(const struct nexthop *next1,
181181 ret = _nexthop_gateway_cmp (next1 , next2 );
182182 if (ret != 0 )
183183 return ret ;
184+ if (!use_ifindex )
185+ break ;
184186 fallthrough ;
185187 case NEXTHOP_TYPE_IFINDEX :
186188 if (next1 -> ifindex < next2 -> ifindex )
@@ -236,11 +238,11 @@ static int _nexthop_cmp_no_labels(const struct nexthop *next1,
236238}
237239
238240static int nexthop_cmp_internal (const struct nexthop * next1 ,
239- const struct nexthop * next2 , bool use_weight )
241+ const struct nexthop * next2 , bool use_weight , bool use_ifindex )
240242{
241243 int ret = 0 ;
242244
243- ret = _nexthop_cmp_no_labels (next1 , next2 , use_weight );
245+ ret = _nexthop_cmp_no_labels (next1 , next2 , use_weight , use_ifindex );
244246 if (ret != 0 )
245247 return ret ;
246248
@@ -255,13 +257,13 @@ static int nexthop_cmp_internal(const struct nexthop *next1,
255257
256258int nexthop_cmp (const struct nexthop * next1 , const struct nexthop * next2 )
257259{
258- return nexthop_cmp_internal (next1 , next2 , true);
260+ return nexthop_cmp_internal (next1 , next2 , true, true );
259261}
260262
261263int nexthop_cmp_no_weight (const struct nexthop * next1 ,
262264 const struct nexthop * next2 )
263265{
264- return nexthop_cmp_internal (next1 , next2 , false);
266+ return nexthop_cmp_internal (next1 , next2 , false, true );
265267}
266268
267269/*
@@ -432,6 +434,20 @@ void nexthops_free(struct nexthop *nexthop)
432434 }
433435}
434436
437+ bool nexthop_same_no_ifindex (const struct nexthop * nh1 , const struct nexthop * nh2 )
438+ {
439+ if (nh1 && !nh2 )
440+ return false;
441+
442+ if (!nh1 && nh2 )
443+ return false;
444+
445+ if (nh1 == nh2 )
446+ return true;
447+
448+ return nexthop_cmp_internal (nh1 , nh2 , true, false);
449+ }
450+
435451bool nexthop_same (const struct nexthop * nh1 , const struct nexthop * nh2 )
436452{
437453 if (nh1 && !nh2 )
@@ -461,7 +477,7 @@ bool nexthop_same_no_labels(const struct nexthop *nh1,
461477 if (nh1 == nh2 )
462478 return true;
463479
464- if (_nexthop_cmp_no_labels (nh1 , nh2 , true) != 0 )
480+ if (_nexthop_cmp_no_labels (nh1 , nh2 , true, true ) != 0 )
465481 return false;
466482
467483 return true;
0 commit comments