summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_mplsvpn.c
diff options
context:
space:
mode:
authorG. Paul Ziemba <paulz@labn.net>2018-06-24 21:39:03 +0200
committerG. Paul Ziemba <paulz@labn.net>2018-06-24 22:04:05 +0200
commitf46d45c17f61116689f3a3a331e903752a7bc846 (patch)
tree7634109fc6baadd47755164ed534aa6b0a053de6 /bgpd/bgp_mplsvpn.c
parentMerge pull request #2520 from donaldsharp/privs_smivs (diff)
downloadfrr-f46d45c17f61116689f3a3a331e903752a7bc846.tar.xz
frr-f46d45c17f61116689f3a3a331e903752a7bc846.zip
bgpd: don't nexthop-track twice-leaked routes that came from zebra
Issue 2381: interface based routes not marked "up" when they originate in zebra, redistributed to bgp vrf, then imported to vpn and then imported by another vrf. Routes that are redistributed into BGP from zebra should not get nexthop tracking (the assumption is that the originating protocol is responsible to export or withdraw the route according to its own notion of nexthop status). The vpn-vrf route-leaking code checks the source route sub_type to decide whether to use nexthop tracking on the resulting leaked route. A route that is redistributed from zebra into bgp will have sub_type==BGP_ROUTE_REDISTRIBUTE. If it is leaked to the vpn RIB, the resulting vpn RIB route will have sub_type==BGP_ROUTE_IMPORTED. If THAT vpn route is leaked to another vrf, the original code will examine only the leak-source route sub_type and, since it is not BGP_ROUTE_REDISTRIBUTE, will wrongly try to use nexthop tracking on the new route in the final vrf. This change modifies the leak function to track back up the parent links to the ultimate parent of the leak source route and look at that route's sub_type instead. Signed-off-by: G. Paul Ziemba <paulz@labn.net>
Diffstat (limited to '')
-rw-r--r--bgpd/bgp_mplsvpn.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 28e8ceb15..3a854be53 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -466,6 +466,7 @@ leak_update(
{
struct prefix *p = &bn->p;
struct bgp_info *bi;
+ struct bgp_info *bi_ultimate;
struct bgp_info *new;
char buf_prefix[PREFIX_STRLEN];
@@ -477,6 +478,26 @@ leak_update(
}
/*
+ * Routes that are redistributed into BGP from zebra do not get
+ * nexthop tracking. However, if those routes are subsequently
+ * imported to other RIBs within BGP, the leaked routes do not
+ * carry the original BGP_ROUTE_REDISTRIBUTE sub_type. Therefore,
+ * in order to determine if the route we are currently leaking
+ * should have nexthop tracking, we must find the ultimate
+ * parent so we can check its sub_type.
+ *
+ * As of now, source_bi may at most be a second-generation route
+ * (only one hop back to ultimate parent for vrf-vpn-vrf scheme).
+ * Using a loop here supports more complex intra-bgp import-export
+ * schemes that could be implemented in the future.
+ *
+ */
+ for (bi_ultimate = source_bi;
+ bi_ultimate->extra && bi_ultimate->extra->parent;
+ bi_ultimate = bi_ultimate->extra->parent)
+ ;
+
+ /*
* match parent
*/
for (bi = bn->info; bi; bi = bi->next) {
@@ -528,7 +549,7 @@ leak_update(
bgp_nexthop = bi->extra->bgp_orig;
/* No nexthop tracking for redistributed routes */
- if (source_bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
+ if (bi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE)
nh_valid = 1;
else
/*
@@ -591,7 +612,7 @@ leak_update(
* their originating protocols will do the tracking and
* withdraw those routes if the nexthops become unreachable
*/
- if (source_bi->sub_type == BGP_ROUTE_REDISTRIBUTE)
+ if (bi_ultimate->sub_type == BGP_ROUTE_REDISTRIBUTE)
nh_valid = 1;
else
/*