summaryrefslogtreecommitdiff
path: root/zebra/zebra_nhg.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_nhg.c')
-rw-r--r--zebra/zebra_nhg.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index face0ef3bc..46d5164127 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -453,8 +453,13 @@ static void *zebra_nhg_hash_alloc(void *arg)
/* Mark duplicate nexthops in a group at creation time. */
nexthop_group_mark_duplicates(&(nhe->nhg));
- /* Add the ifp now if it's not a group or recursive and has ifindex */
- if (nhe->nhg.nexthop && nhe->nhg.nexthop->ifindex) {
+ /*
+ * Add the ifp now if it's not a group or recursive and has ifindex.
+ *
+ * A proto-owned ID is always a group.
+ */
+ if (!PROTO_OWNED(nhe) && nhe->nhg.nexthop && !nhe->nhg.nexthop->next
+ && !nhe->nhg.nexthop->resolved && nhe->nhg.nexthop->ifindex) {
struct interface *ifp = NULL;
ifp = if_lookup_by_index(nhe->nhg.nexthop->ifindex,
@@ -2048,11 +2053,13 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,
return 1;
}
- if (top &&
- ((top->family == AF_INET && top->prefixlen == 32
- && nexthop->gate.ipv4.s_addr == top->u.prefix4.s_addr)
- || (top->family == AF_INET6 && top->prefixlen == 128
- && memcmp(&nexthop->gate.ipv6, &top->u.prefix6, 16) == 0))) {
+ if (top
+ && ((top->family == AF_INET && top->prefixlen == IPV4_MAX_BITLEN
+ && nexthop->gate.ipv4.s_addr == top->u.prefix4.s_addr)
+ || (top->family == AF_INET6 && top->prefixlen == IPV6_MAX_BITLEN
+ && memcmp(&nexthop->gate.ipv6, &top->u.prefix6,
+ IPV6_MAX_BYTELEN)
+ == 0))) {
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
" :%s: Attempting to install a max prefixlength route through itself",
@@ -2118,12 +2125,12 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,
switch (afi) {
case AFI_IP:
p.family = AF_INET;
- p.prefixlen = IPV4_MAX_PREFIXLEN;
+ p.prefixlen = IPV4_MAX_BITLEN;
p.u.prefix4 = *ipv4;
break;
case AFI_IP6:
p.family = AF_INET6;
- p.prefixlen = IPV6_MAX_PREFIXLEN;
+ p.prefixlen = IPV6_MAX_BITLEN;
p.u.prefix6 = nexthop->gate.ipv6;
break;
default:
@@ -2150,8 +2157,10 @@ static int nexthop_active(struct nexthop *nexthop, struct nhg_hash_entry *nhe,
* host route.
*/
if (prefix_same(&rn->p, top))
- if (((afi == AFI_IP) && (rn->p.prefixlen != 32))
- || ((afi == AFI_IP6) && (rn->p.prefixlen != 128))) {
+ if (((afi == AFI_IP)
+ && (rn->p.prefixlen != IPV4_MAX_BITLEN))
+ || ((afi == AFI_IP6)
+ && (rn->p.prefixlen != IPV6_MAX_BITLEN))) {
if (IS_ZEBRA_DEBUG_RIB_DETAILED)
zlog_debug(
" %s: Matched against ourself and prefix length is not max bit length",