Skip to content

Commit

Permalink
pim6d: Fix PIMV6 BSM packet processing
Browse files Browse the repository at this point in the history
PR 12008
  • Loading branch information
mobash-rasool committed Oct 3, 2022
1 parent f3811f3 commit 83056e5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
8 changes: 8 additions & 0 deletions pimd/pim_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,12 @@ bool pim_nht_bsr_rpf_check(struct pim_instance *pim, pim_addr bsr_addr,
if (!nbr)
continue;

#if PIM_IPV == 4
return znh->ifindex == src_ifp->ifindex &&
(!pim_addr_cmp(znh->nexthop_addr, src_ip));
#else
return znh->ifindex == src_ifp->ifindex;
#endif
}
return false;
}
Expand Down Expand Up @@ -384,8 +388,12 @@ bool pim_nht_bsr_rpf_check(struct pim_instance *pim, pim_addr bsr_addr,
if (!nbr)
continue;

#if PIM_IPV == 4
return nh->ifindex == src_ifp->ifindex &&
(!pim_addr_cmp(nhaddr, src_ip));
#else
return nh->ifindex == src_ifp->ifindex;
#endif
}
return false;
}
Expand Down
38 changes: 17 additions & 21 deletions pimd/pim_zlookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,48 +264,44 @@ static int zclient_read_nexthop(struct pim_instance *pim,
#endif
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6:
stream_get(&nh_ip6, s, sizeof(nh_ip6));
nh_ifi = stream_getl(s);

#if PIM_IPV == 6
nexthop_tab[num_ifindex].nexthop_addr = nh_ip6;
nexthop_tab[num_ifindex].ifindex = nh_ifi;
++num_ifindex;
#else
/* RFC 5549 v4-over-v6 nexthop handling */

/*
* If we are sending v6 secondary assume we receive v6
* secondary
*/
struct interface *ifp = if_lookup_by_index(
nexthop_tab[num_ifindex].ifindex,
nexthop_vrf_id);
struct interface *ifp =
if_lookup_by_index(nh_ifi, nexthop_vrf_id);

if (!ifp)
break;

struct pim_neighbor *nbr;
struct prefix p;

if (pim->send_v6_secondary) {
struct prefix p;

p.family = AF_INET6;
p.prefixlen = IPV6_MAX_BITLEN;
p.u.prefix6 = nh_ip6;
p.family = AF_INET6;
p.prefixlen = IPV6_MAX_BITLEN;
p.u.prefix6 = nh_ip6;

#if PIM_IPV == 4
/* RFC 5549 v4-over-v6 nexthop handling */
/*
* If we are sending v6 secondary assume we receive v6
* secondary
*/
if (pim->send_v6_secondary) {
nbr = pim_neighbor_find_by_secondary(ifp, &p);
} else
nbr = pim_neighbor_find_if(ifp);

#else
nbr = pim_neighbor_find_by_secondary(ifp, &p);
#endif
if (!nbr)
break;

nexthop_tab[num_ifindex].nexthop_addr =
nbr->source_addr;
nexthop_tab[num_ifindex].ifindex = nh_ifi;
++num_ifindex;
#endif
break;
default:
/* do nothing */
Expand Down
2 changes: 0 additions & 2 deletions zebra/zapi_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ static int zserv_encode_nexthop(struct stream *s, struct nexthop *nexthop)
stream_putl(s, nexthop->ifindex);
break;
case NEXTHOP_TYPE_IPV6:
stream_put(s, &nexthop->gate.ipv6, 16);
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
stream_put(s, &nexthop->gate.ipv6, 16);
stream_putl(s, nexthop->ifindex);
Expand Down

0 comments on commit 83056e5

Please sign in to comment.