summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_route.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2018-03-20 14:18:01 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2018-03-21 21:37:24 +0100
commit3103e8d22f772f101a5c0d85f5423bf1550cdbf7 (patch)
tree9fa6a5cc243072f451a10de57d59ee4446428941 /bgpd/bgp_route.c
parentMerge pull request #1941 from donaldsharp/cs1 (diff)
downloadfrr-3103e8d22f772f101a5c0d85f5423bf1550cdbf7.tar.xz
frr-3103e8d22f772f101a5c0d85f5423bf1550cdbf7.zip
bgpd: Fix peer withdrawal and route leaking for vpn's and vrf's
When a peer is removed the routes are withdrawn via bgp_process_main_one As such we need to put a bit of code in to handle this situation for the vpn/vrf route leaking code. I think this code path is also called for when a vrf's route is changed and I believe we will end up putting a bit more code here to handle the nexthop changes. I've also started trying to document the bgp_process_main_one function a bit better. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'bgpd/bgp_route.c')
-rw-r--r--bgpd/bgp_route.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 35732d1bf..5e122efe8 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -2095,6 +2095,25 @@ struct bgp_process_queue {
unsigned int queued;
};
+/*
+ * old_select = The old best path
+ * new_select = the new best path
+ *
+ * if (!old_select && new_select)
+ * We are sending new information on.
+ *
+ * if (old_select && new_select) {
+ * if (new_select != old_select)
+ * We have a new best path send a change
+ * else
+ * We've received a update with new attributes that needs
+ * to be passed on.
+ * }
+ *
+ * if (old_select && !new_select)
+ * We have no eligible route that we can announce or the rn
+ * is being removed.
+ */
static void bgp_process_main_one(struct bgp *bgp, struct bgp_node *rn,
afi_t afi, safi_t safi)
{
@@ -3664,10 +3683,12 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
struct bgp_node *rn = cnq->rn;
struct peer *peer = wq->spec.data;
struct bgp_info *ri;
+ struct bgp *bgp;
afi_t afi = bgp_node_table(rn)->afi;
safi_t safi = bgp_node_table(rn)->safi;
assert(rn && peer);
+ bgp = peer->bgp;
/* It is possible that we have multiple paths for a prefix from a peer
* if that peer is using AddPath.
@@ -3686,8 +3707,18 @@ static wq_item_status bgp_clear_route_node(struct work_queue *wq, void *data)
/* If this is an EVPN route, process for
* un-import. */
if (safi == SAFI_EVPN)
- bgp_evpn_unimport_route(peer->bgp, afi, safi,
+ bgp_evpn_unimport_route(bgp, afi, safi,
&rn->p, ri);
+ /* Handle withdraw for VRF route-leaking and L3VPN */
+ if (SAFI_UNICAST == safi
+ && (bgp->inst_type == BGP_INSTANCE_TYPE_VRF ||
+ bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT))
+ vpn_leak_from_vrf_withdraw(bgp_get_default(),
+ bgp, ri);
+ if (SAFI_MPLS_VPN == safi &&
+ bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT)
+ vpn_leak_to_vrf_withdraw(bgp, ri);
+
bgp_rib_remove(rn, ri, peer, afi, safi);
}
}