From 6137a77dce5edd49283acab572d7763644273830 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 6 Sep 2018 09:16:30 -0400 Subject: [PATCH] bgpd: Extend RFC 5549 metaphor a bit more Currently we only support RFC 5549 in bgp via using the `neighbor swp1 interface remote-as ...` command. This causes the extended capability data to be traded as part of the open message. Additionally at that point in time we notify zebra to turn on the RA code for that interface so that the zebra trick of turning the v6 nexthop into a 169.254.0.1 nexthop and adding a neighbor entry works. This code change does 2 things: 1) Modify bgp to pass the extended capability if we are attempting to establish a v4/unicast session over a v6 peer. In the past we limited this to just the LL based peer. 2) Modify the nexthop tracking code to notice when it receives nexthop data about the global v6 peer to turn on RA code on those interfaces we will be using. This will allow the v4 route with a v6 nexthop received in zebra to auto translate this correctly. Signed-off-by: Donald Sharp --- bgpd/bgp_nht.c | 18 ++++++++++++++++++ bgpd/bgp_open.c | 1 - 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 3d2a4ee0dd..3ef7604b17 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -401,6 +401,8 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id) bnc->change_flags |= BGP_NEXTHOP_CHANGED; if (nhr.nexthop_num) { + struct peer *peer = bnc->nht_info; + /* notify bgp fsm if nbr ip goes from invalid->valid */ if (!bnc->nexthop_num) UNSET_FLAG(bnc->flags, BGP_NEXTHOP_PEER_NOTIFIED); @@ -416,6 +418,22 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id) nexthop = nexthop_from_zapi_nexthop(&nhr.nexthops[i]); + /* + * Turn on RA for the v6 nexthops + * we receive from bgp. This is to allow us + * to work with v4 routing over v6 nexthops + */ + if (peer && + CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE) + && nhr.prefix.family == AF_INET6) { + struct interface *ifp; + + ifp = if_lookup_by_index(nexthop->ifindex, + nexthop->vrf_id); + zclient_send_interface_radv_req( + zclient, nexthop->vrf_id, ifp, true, + BGP_UNNUM_DEFAULT_RA_INTERVAL); + } /* There is at least one label-switched path */ if (nexthop->nh_label && nexthop->nh_label->num_labels) { diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 62b412af0c..cf5901df5a 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -1331,7 +1331,6 @@ void bgp_open_capability(struct stream *s, struct peer *peer) */ if (CHECK_FLAG(peer->flags, PEER_FLAG_CAPABILITY_ENHE) && peer->su.sa.sa_family == AF_INET6 - && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr) && afi == AFI_IP && (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST)) { -- 2.39.5