]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Allow views to 'pretend' resolve nexthops
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 1 Feb 2017 15:31:40 +0000 (10:31 -0500)
committerDavid Lamparter <equinox@opensourcerouting.org>
Tue, 7 Feb 2017 15:56:16 +0000 (16:56 +0100)
Views are supposed to be independent tables that have no connection to
routing tables.  Since View's are 'independent' there is no way to do
'real' nexthop resolution since connected routes and interfaces are
associated with a particular table (or really vrf).  So when we have a
bgp instance assume that nexthops specified are actually valid, since we
are propagating what our neighbors are telling us.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
[cherry-picked from master 6fa1ab2eecb39b35256739f7083196d6f556f639]
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
bgpd/bgp_nht.c

index 1ca0483678bdc1961fe69e4ad255c9ae7e0766e2..4c4fbc09b53550ed6eb9299a82edabcdf2ff9146 100644 (file)
@@ -69,6 +69,14 @@ bgp_find_nexthop (struct bgp_info *path, int connected)
   if (!bnc)
     return 0;
 
+  /*
+   * We are cheating here.  Views have no associated underlying
+   * ability to detect nexthops.  So when we have a view
+   * just tell everyone the nexthop is valid
+   */
+  if (path->peer && path->peer->bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+    return 1;
+
   if (connected && !(CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)))
     return 0;
 
@@ -196,7 +204,6 @@ bgp_find_or_add_nexthop (struct bgp *bgp, afi_t afi, struct bgp_info *ri,
 
   bnc = rn->info;
   bgp_unlock_node (rn);
-
   if (is_bgp_static_route)
     {
       SET_FLAG(bnc->flags, BGP_STATIC_ROUTE);
@@ -239,10 +246,13 @@ bgp_find_or_add_nexthop (struct bgp *bgp, afi_t afi, struct bgp_info *ri,
       UNSET_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED);
       UNSET_FLAG(bnc->flags, BGP_NEXTHOP_VALID);
     }
-
-  if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED))
+  if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+    {
+      bnc->flags |= BGP_NEXTHOP_REGISTERED;
+      bnc->flags |= BGP_NEXTHOP_VALID;
+    }
+  else if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED))
     register_zebra_rnh(bnc, is_bgp_static_route);
-
   if (ri && ri->nexthop != bnc)
     {
       /* Unlink from existing nexthop cache, if any. This will also free
@@ -260,7 +270,15 @@ bgp_find_or_add_nexthop (struct bgp *bgp, afi_t afi, struct bgp_info *ri,
   else if (peer)
     bnc->nht_info = (void *)peer; /* NHT peer reference */
 
-  return (bgp_isvalid_nexthop(bnc));
+  /*
+   * We are cheating here.  Views have no associated underlying
+   * ability to detect nexthops.  So when we have a view
+   * just tell everyone the nexthop is valid
+   */
+  if (bgp->inst_type == BGP_INSTANCE_TYPE_VIEW)
+    return 1;
+  else
+    return (bgp_isvalid_nexthop(bnc));
 }
 
 void