Skip to content

Commit ef8d966

Browse files
zebra: Use NHG SINGLETON macros where appropriate
To make life a bit easy, using the NHG SINGLETON macros where applicable Signed-off-by: Rajasekar Raja <[email protected]>
1 parent 5f4edeb commit ef8d966

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

zebra/zebra_nhg.c

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ 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,
@@ -831,8 +831,7 @@ static bool zebra_nhe_find(struct nhg_hash_entry **nhe, /* return value */
831831
nh = backup_nhe->nhg.nexthop;
832832

833833
/* Singleton recursive NH */
834-
if (nh->next == NULL &&
835-
CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE)) {
834+
if (ZEBRA_NHG_IS_SINGLETON(backup_nhe) && CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE)) {
836835
if (IS_ZEBRA_DEBUG_NHG_DETAIL)
837836
zlog_debug("%s: backup depend NH %pNHv (R)",
838837
__func__, nh);
@@ -1696,14 +1695,13 @@ static void zebra_nhg_free_members(struct nhg_hash_entry *nhe)
16961695
void zebra_nhg_free(struct nhg_hash_entry *nhe)
16971696
{
16981697
if (IS_ZEBRA_DEBUG_NHG_DETAIL) {
1699-
/* Group or singleton? */
1700-
if (nhe->nhg.nexthop && nhe->nhg.nexthop->next)
1701-
zlog_debug("%s: nhe %p (%pNG) flags (0x%x), refcnt %d", __func__, nhe, nhe,
1702-
nhe->flags, nhe->refcnt);
1703-
else
1698+
if (ZEBRA_NHG_IS_SINGLETON(nhe))
17041699
zlog_debug("%s: nhe %p (%pNG), refcnt %d, NH %pNHv",
17051700
__func__, nhe, nhe, nhe->refcnt,
17061701
nhe->nhg.nexthop);
1702+
else
1703+
zlog_debug("%s: nhe %p (%pNG) flags (0x%x), refcnt %d", __func__, nhe, nhe,
1704+
nhe->flags, nhe->refcnt);
17071705
}
17081706

17091707
event_cancel(&nhe->timer);
@@ -1721,14 +1719,13 @@ void zebra_nhg_hash_free(void *p)
17211719
struct nhg_hash_entry *nhe = p;
17221720

17231721
if (IS_ZEBRA_DEBUG_NHG_DETAIL) {
1724-
/* Group or singleton? */
1725-
if (nhe->nhg.nexthop && nhe->nhg.nexthop->next)
1726-
zlog_debug("%s: nhe %p (%u), refcnt %d", __func__, nhe,
1727-
nhe->id, nhe->refcnt);
1728-
else
1722+
if (ZEBRA_NHG_IS_SINGLETON(nhe))
17291723
zlog_debug("%s: nhe %p (%pNG), refcnt %d, NH %pNHv",
17301724
__func__, nhe, nhe, nhe->refcnt,
17311725
nhe->nhg.nexthop);
1726+
else
1727+
zlog_debug("%s: nhe %p (%u), refcnt %d", __func__, nhe, nhe->id,
1728+
nhe->refcnt);
17321729
}
17331730

17341731
event_cancel(&nhe->timer);
@@ -4086,8 +4083,7 @@ void zebra_interface_nhg_reinstall(struct interface *ifp)
40864083
}
40874084

40884085
/* Check for singleton NHG associated to interface */
4089-
if (!nexthop_is_blackhole(nh) &&
4090-
zebra_nhg_depends_is_empty(rb_node_dep->nhe)) {
4086+
if (!nexthop_is_blackhole(nh) && ZEBRA_NHG_IS_SINGLETON(rb_node_dep->nhe)) {
40914087
struct nhg_connected *rb_node_dependent;
40924088

40934089
if (IS_ZEBRA_DEBUG_NHG_DETAIL)

0 commit comments

Comments
 (0)