bgpd: encode implicit next-hop-self in some vrf route leaking scenarios

Problem reported that when vrf route-leaking between an unnumbered
peer in one vrf to a numbered peer in another vrf, the nexthop
attribute was missing from the update, causing the session to fail.
determined that we needed to expand the  mechanism for verifying if
the route has been learned in the other vrf without an ipv4 nexthop.

Ticket: CM-25610
Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
This commit is contained in:
Don Slice 2019-07-17 13:19:08 -04:00
parent dfd15ebfa6
commit b96306f042

View File

@ -3215,6 +3215,8 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
/* Nexthop attribute. */ /* Nexthop attribute. */
if (afi == AFI_IP && safi == SAFI_UNICAST if (afi == AFI_IP && safi == SAFI_UNICAST
&& !peer_cap_enhe(peer, afi, safi)) { && !peer_cap_enhe(peer, afi, safi)) {
afi_t nh_afi = BGP_NEXTHOP_AFI_FROM_NHLEN(attr->mp_nexthop_len);
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) { if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
stream_putc(s, BGP_ATTR_FLAG_TRANS); stream_putc(s, BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_NEXT_HOP); stream_putc(s, BGP_ATTR_NEXT_HOP);
@ -3222,17 +3224,18 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
attr); attr);
stream_putc(s, 4); stream_putc(s, 4);
stream_put_ipv4(s, attr->nexthop.s_addr); stream_put_ipv4(s, attr->nexthop.s_addr);
} else if (peer_cap_enhe(from, afi, safi)) { } else if (peer_cap_enhe(from, afi, safi)
|| (nh_afi == AFI_IP6)) {
/* /*
* Likely this is the case when an IPv4 prefix was * Likely this is the case when an IPv4 prefix was
* received with * received with Extended Next-hop capability in this
* Extended Next-hop capability and now being advertised * or another vrf and is now being advertised to
* to * non-ENHE peers. Since peer_cap_enhe only checks
* non-ENHE peers. * peers in this vrf, also check the nh_afi to catch
* the case where the originator was in another vrf.
* Setting the mandatory (ipv4) next-hop attribute here * Setting the mandatory (ipv4) next-hop attribute here
* to enable * to enable implicit next-hop self with correct A-F
* implicit next-hop self with correct (ipv4 address * (ipv4 address family).
* family).
*/ */
stream_putc(s, BGP_ATTR_FLAG_TRANS); stream_putc(s, BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_NEXT_HOP); stream_putc(s, BGP_ATTR_NEXT_HOP);