]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd rfapi: Shift rfapi receive hooks for vpn and encap safis into
authorG. Paul Ziemba <paulz@labn.net>
Mon, 16 Jan 2017 19:09:12 +0000 (11:09 -0800)
committerLou Berger <lberger@labn.net>
Tue, 24 Jan 2017 18:42:43 +0000 (13:42 -0500)
     bgp_update/bgp_withdraw (Issue #91)

Signed-off-by: G. Paul Ziemba <paulz@labn.net>
bgpd/bgp_encap.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_route.c
bgpd/rfapi/rfapi.c
bgpd/rfapi/rfapi_import.c

index 75a348e3fe86a24aad60679fbf828c14beccd3f7..3fe8988b9cd43d979335f831bd3c7137be57d1c1 100644 (file)
@@ -188,15 +188,7 @@ bgp_nlri_parse_encap(
       if (attr) {
        bgp_update (peer, &p, 0, attr, afi, SAFI_ENCAP,
                    ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL, 0);
-#if ENABLE_BGP_VNC
-       rfapiProcessUpdate(peer, NULL, &p, &prd, attr, afi, SAFI_ENCAP,
-                           ZEBRA_ROUTE_BGP,  BGP_ROUTE_NORMAL, NULL);
-#endif
       } else {
-#if ENABLE_BGP_VNC
-       rfapiProcessWithdraw(peer, NULL, &p, &prd, attr, afi, SAFI_ENCAP,
-                             ZEBRA_ROUTE_BGP, 0);
-#endif
        bgp_withdraw (peer, &p, 0, attr, afi, SAFI_ENCAP,
                      ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, NULL);
       }
index bfbddb6c30c6778717776780f8543436dd1a2030..a789c6f192ebae4a62ebe579654c253208be4412 100644 (file)
@@ -173,9 +173,6 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr,
   safi_t safi;
   int addpath_encoded;
   u_int32_t addpath_id;
-#if ENABLE_BGP_VNC
-  u_int32_t label = 0;
-#endif
 
   /* Check peer status. */
   if (peer->status != Established)
@@ -251,10 +248,6 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr,
           return -1;
         }
       
-#if ENABLE_BGP_VNC
-      label = decode_label (pnt);
-#endif
-
       /* Copyr label to prefix. */
       tagpnt = pnt;
 
@@ -294,23 +287,14 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr,
 
       if (attr)
         {
-       bgp_update (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
-                   ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0);
-#if ENABLE_BGP_VNC
-          rfapiProcessUpdate(peer, NULL, &p, &prd, attr, packet->afi, 
-                             SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL,
-                             &label);
-#endif
+          bgp_update (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
+                      ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt, 0);
         }
       else
         {
-#if ENABLE_BGP_VNC
-          rfapiProcessWithdraw(peer, NULL, &p, &prd, attr, packet->afi, 
-                               SAFI_MPLS_VPN, ZEBRA_ROUTE_BGP, 0);
-#endif
-       bgp_withdraw (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
-                     ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt);
-    }
+          bgp_withdraw (peer, &p, addpath_id, attr, packet->afi, SAFI_MPLS_VPN,
+                        ZEBRA_ROUTE_BGP, BGP_ROUTE_NORMAL, &prd, tagpnt);
+        }
     }
   /* Packet length consistency check. */
   if (pnt != lim)
@@ -657,7 +641,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u
                       struct rd_as rd_as;
                       struct rd_ip rd_ip = {0};
 #if ENABLE_BGP_VNC
-                      struct rd_vnc_eth rd_vnc_eth;
+                      struct rd_vnc_eth rd_vnc_eth = {0};
 #endif
                       u_char *pnt;
 
@@ -867,7 +851,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd,
                      struct rd_as rd_as;
                      struct rd_ip rd_ip = {0};
 #if ENABLE_BGP_VNC
-                      struct rd_vnc_eth rd_vnc_eth;
+                      struct rd_vnc_eth rd_vnc_eth = {0};
 #endif
                      u_char *pnt;
 
index 5fdda66258a65ea305ab97034786844d321a466a..0e9c71c1eee348cfbed636c5c7d0617da9b940f0 100644 (file)
@@ -2680,6 +2680,21 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
       bgp_process (bgp, rn, afi, safi);
       bgp_unlock_node (rn);
 
+#if ENABLE_BGP_VNC
+  if (SAFI_MPLS_VPN == safi)
+    {
+      uint32_t    label = decode_label(tag);
+
+      rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+        &label);
+    }
+  if (SAFI_ENCAP == safi)
+    {
+      rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+        NULL);
+    }
+#endif
+
       return 0;
     } // End of implicit withdraw
 
@@ -2774,6 +2789,21 @@ bgp_update (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
   /* Process change. */
   bgp_process (bgp, rn, afi, safi);
 
+#if ENABLE_BGP_VNC
+  if (SAFI_MPLS_VPN == safi)
+    {
+      uint32_t    label = decode_label(tag);
+
+      rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+        &label);
+    }
+  if (SAFI_ENCAP == safi)
+    {
+      rfapiProcessUpdate(peer, NULL, p, prd, attr, afi, safi, type, sub_type,
+        NULL);
+    }
+#endif
+
   return 0;
 
   /* This BGP update is filtered.  Log the reason then update BGP
@@ -2813,6 +2843,13 @@ bgp_withdraw (struct peer *peer, struct prefix *p, u_int32_t addpath_id,
   struct bgp_node *rn;
   struct bgp_info *ri;
 
+#if ENABLE_BGP_VNC
+  if ((SAFI_MPLS_VPN == safi) || (SAFI_ENCAP == safi))
+    {
+      rfapiProcessWithdraw(peer, NULL, p, prd, NULL, afi, safi, type, 0);
+    }
+#endif
+
   bgp = peer->bgp;
 
   /* Lookup node. */
index 6353f7dacf62a15588d72e83cb27bc634a4ddc88..25fb7aaf657ef900ccb1f00c4b734502b5d28ca4 100644 (file)
@@ -417,9 +417,10 @@ del_vnc_route (
     {
 
       vnc_zlog_debug_verbose
-        ("%s: trying bi=%p, bi->peer=%p, bi->type=%d, bi->sub_type=%d, bi->extra->vnc.export.rfapi_handle=%p",
+        ("%s: trying bi=%p, bi->peer=%p, bi->type=%d, bi->sub_type=%d, bi->extra->vnc.export.rfapi_handle=%p, local_pref=%u",
          __func__, bi, bi->peer, bi->type, bi->sub_type,
-         (bi->extra ? bi->extra->vnc.export.rfapi_handle : NULL));
+         (bi->extra ? bi->extra->vnc.export.rfapi_handle : NULL),
+        ((bi->attr && CHECK_FLAG(bi->attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))? bi->attr->local_pref: 0));
 
       if (bi->peer == peer &&
           bi->type == type &&
index e6fdb7180e0cbb9e8a3430c52d040c90f7b5853b..590691a6b749348f3591f50f577a7e7edd4def95 100644 (file)
@@ -3724,6 +3724,12 @@ rfapiBgpInfoFilteredImportVPN (
       if (rn->info)
         original_had_routes = 1;
 
+      if (VNC_DEBUG(VERBOSE))
+        {
+          vnc_zlog_debug_verbose ("%s: showing IT node on entry", __func__);
+          rfapiShowItNode (NULL, rn);   /* debug */
+        }
+
       /*
        * Look for same route (will have same RD and peer)
        */