@@ -454,16 +454,16 @@ static void *zebra_nhg_hash_alloc(void *arg)
454454 *
455455 * A proto-owned ID is always a group.
456456 */
457- if (!PROTO_OWNED (nhe ) && nhe -> nhg . nexthop && ! nhe -> nhg .nexthop -> next
458- && ! nhe -> nhg .nexthop -> resolved && nhe -> nhg . nexthop -> ifindex ) {
457+ if (!PROTO_OWNED (nhe ) && ( ZEBRA_NHG_IS_SINGLETON ( nhe ) && nhe -> nhg .nexthop -> ifindex &&
458+ ! CHECK_FLAG ( nhe -> nhg .nexthop -> flags , NEXTHOP_FLAG_RECURSIVE )) ) {
459459 struct interface * ifp = NULL ;
460460
461461 ifp = if_lookup_by_index (nhe -> nhg .nexthop -> ifindex ,
462462 nhe -> nhg .nexthop -> vrf_id );
463463 if (ifp )
464464 zebra_nhg_set_if (nhe , ifp );
465465 else {
466- if (IS_ZEBRA_DEBUG_NHG )
466+ if (IS_ZEBRA_DEBUG_NHG_DETAIL )
467467 zlog_debug (
468468 "Failed to lookup an interface with ifindex=%d in vrf=%u for NHE %pNG" ,
469469 nhe -> nhg .nexthop -> ifindex ,
@@ -830,8 +830,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
830830 nh = backup_nhe -> nhg .nexthop ;
831831
832832 /* Singleton recursive NH */
833- if (nh -> next == NULL &&
834- CHECK_FLAG (nh -> flags , NEXTHOP_FLAG_RECURSIVE )) {
833+ if (ZEBRA_NHG_IS_SINGLETON (backup_nhe ) && CHECK_FLAG (nh -> flags , NEXTHOP_FLAG_RECURSIVE )) {
835834 if (IS_ZEBRA_DEBUG_NHG_DETAIL )
836835 zlog_debug ("%s: backup depend NH %pNHv (R)" ,
837836 __func__ , nh );
@@ -1111,13 +1110,8 @@ void zebra_nhg_check_valid(struct nhg_hash_entry *nhe)
11111110 struct nhg_connected * rb_node_dep = NULL ;
11121111 bool valid = false;
11131112
1114- /*
1115- * If I have other nhe's depending on me, or I have nothing
1116- * I am depending on then this is a
1117- * singleton nhe so set this nexthops flag as appropriate.
1118- */
1119- if (nhg_connected_tree_count (& nhe -> nhg_depends ) ||
1120- nhg_connected_tree_count (& nhe -> nhg_dependents ) == 0 ) {
1113+ /* Singleton means it has no depends and has only dependents */
1114+ if (ZEBRA_NHG_IS_SINGLETON (nhe )) {
11211115 UNSET_FLAG (nhe -> nhg .nexthop -> flags , NEXTHOP_FLAG_FIB );
11221116 UNSET_FLAG (nhe -> nhg .nexthop -> flags , NEXTHOP_FLAG_ACTIVE );
11231117 }
@@ -1700,14 +1694,13 @@ static void zebra_nhg_free_members(struct nhg_hash_entry *nhe)
17001694void zebra_nhg_free (struct nhg_hash_entry * nhe )
17011695{
17021696 if (IS_ZEBRA_DEBUG_NHG_DETAIL ) {
1703- /* Group or singleton? */
1704- if (nhe -> nhg .nexthop && nhe -> nhg .nexthop -> next )
1705- zlog_debug ("%s: nhe %p (%pNG), refcnt %d" , __func__ ,
1706- nhe , nhe , nhe -> refcnt );
1707- else
1697+ if (ZEBRA_NHG_IS_SINGLETON (nhe ))
17081698 zlog_debug ("%s: nhe %p (%pNG), refcnt %d, NH %pNHv" ,
17091699 __func__ , nhe , nhe , nhe -> refcnt ,
17101700 nhe -> nhg .nexthop );
1701+ else
1702+ zlog_debug ("%s: nhe %p (%pNG) flags (0x%x), refcnt %d" , __func__ , nhe , nhe ,
1703+ nhe -> flags , nhe -> refcnt );
17111704 }
17121705
17131706 event_cancel (& nhe -> timer );
@@ -1725,14 +1718,13 @@ void zebra_nhg_hash_free(void *p)
17251718 struct nhg_hash_entry * nhe = p ;
17261719
17271720 if (IS_ZEBRA_DEBUG_NHG_DETAIL ) {
1728- /* Group or singleton? */
1729- if (nhe -> nhg .nexthop && nhe -> nhg .nexthop -> next )
1730- zlog_debug ("%s: nhe %p (%u), refcnt %d" , __func__ , nhe ,
1731- nhe -> id , nhe -> refcnt );
1732- else
1721+ if (ZEBRA_NHG_IS_SINGLETON (nhe ))
17331722 zlog_debug ("%s: nhe %p (%pNG), refcnt %d, NH %pNHv" ,
17341723 __func__ , nhe , nhe , nhe -> refcnt ,
17351724 nhe -> nhg .nexthop );
1725+ else
1726+ zlog_debug ("%s: nhe %p (%u), refcnt %d" , __func__ , nhe , nhe -> id ,
1727+ nhe -> refcnt );
17361728 }
17371729
17381730 event_cancel (& nhe -> timer );
@@ -3265,8 +3257,9 @@ int nexthop_active_update(struct route_node *rn, struct route_entry *re,
32653257 old_re -> nhe );
32663258
32673259 if (IS_ZEBRA_DEBUG_NHG_DETAIL )
3268- zlog_debug ("%s: re %p CHANGED: nhe %p (%pNG) => new_nhe %p (%pNG) rib_find_nhe returned %p (%pNG) refcnt: %d" ,
3269- __func__ , re , re -> nhe , re -> nhe , new_nhe , new_nhe , remove , remove ,
3260+ zlog_debug ("%s: re %p CHANGED: nhe %p (%pNG) flags (0x%x) => new_nhe %p (%pNG) flags (0x%x) rib_find_nhe returned %p (%pNG) flags (0x%x) refcnt: %d" ,
3261+ __func__ , re , re -> nhe , re -> nhe , re -> nhe -> flags , new_nhe ,
3262+ new_nhe , new_nhe -> flags , remove , remove , remove -> flags ,
32703263 remove ? remove -> refcnt : 0 );
32713264
32723265 /*
@@ -3452,8 +3445,8 @@ void zebra_nhg_install_kernel(struct nhg_hash_entry *nhe, uint8_t type)
34523445
34533446 if (zebra_nhg_set_valid_if_active (nhe )) {
34543447 if (IS_ZEBRA_DEBUG_NHG_DETAIL )
3455- zlog_debug ("%s: valid flag set for nh %pNG" , __func__ ,
3456- nhe );
3448+ zlog_debug ("%s: valid flag set for nh %pNG flags (0x%x) " , __func__ , nhe ,
3449+ nhe -> flags );
34573450 }
34583451
34593452 if ((type != ZEBRA_ROUTE_CONNECT && type != ZEBRA_ROUTE_LOCAL &&
@@ -3557,7 +3550,7 @@ void zebra_nhg_dplane_result(struct zebra_dplane_ctx *ctx)
35573550 nhe = zebra_nhg_lookup_id (id );
35583551
35593552 if (!nhe ) {
3560- if (IS_ZEBRA_DEBUG_NHG )
3553+ if (IS_ZEBRA_DEBUG_NHG_DETAIL )
35613554 zlog_debug ("%s operation performed on Nexthop ID (%u) in the kernel, that we no longer have in our table" ,
35623555 dplane_op2str (op ), id );
35633556
@@ -4083,17 +4076,16 @@ void zebra_interface_nhg_reinstall(struct interface *ifp)
40834076
40844077 if (zebra_nhg_set_valid_if_active (rb_node_dep -> nhe )) {
40854078 if (IS_ZEBRA_DEBUG_NHG_DETAIL )
4086- zlog_debug (
4087- "%s: Setting the valid flag for nhe %pNG, interface: %s" ,
4088- __func__ , rb_node_dep -> nhe , ifp -> name );
4079+ zlog_debug ("%s: Setting the valid flag for nhe %pNG flags (0x%x), interface: %s" ,
4080+ __func__ , rb_node_dep -> nhe , rb_node_dep -> nhe -> flags ,
4081+ ifp -> name );
40894082 }
40904083
40914084 /* Check for singleton NHG associated to interface */
4092- if (!nexthop_is_blackhole (nh ) &&
4093- zebra_nhg_depends_is_empty (rb_node_dep -> nhe )) {
4085+ if (!nexthop_is_blackhole (nh ) && ZEBRA_NHG_IS_SINGLETON (rb_node_dep -> nhe )) {
40944086 struct nhg_connected * rb_node_dependent ;
40954087
4096- if (IS_ZEBRA_DEBUG_NHG )
4088+ if (IS_ZEBRA_DEBUG_NHG_DETAIL )
40974089 zlog_debug (
40984090 "%s install nhe %pNG nh type %u flags 0x%x" ,
40994091 __func__ , rb_node_dep -> nhe , nh -> type ,
@@ -4122,10 +4114,11 @@ void zebra_interface_nhg_reinstall(struct interface *ifp)
41224114 SET_FLAG (nhop_dependent -> flags ,
41234115 NEXTHOP_FLAG_ACTIVE );
41244116
4125- if (IS_ZEBRA_DEBUG_NHG )
4126- zlog_debug ("%s dependent nhe %pNG Setting Reinstall flag" ,
4127- __func__ ,
4128- rb_node_dependent -> nhe );
4117+ if (IS_ZEBRA_DEBUG_NHG_DETAIL )
4118+ zlog_debug ("%s dependent nhe (%pNG) flags (0x%x) Setting Reinstall flag" ,
4119+ __func__ , rb_node_dependent -> nhe ,
4120+ rb_node_dependent -> nhe -> flags );
4121+
41294122 SET_FLAG (rb_node_dependent -> nhe -> flags ,
41304123 NEXTHOP_GROUP_REINSTALL );
41314124 }
0 commit comments