]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fixes and updates for VPNv6
authorvivek <vivek@cumulusnetworks.com>
Sat, 11 Jun 2016 18:36:42 +0000 (11:36 -0700)
committervivek <vivek@cumulusnetworks.com>
Sat, 11 Jun 2016 18:36:42 +0000 (11:36 -0700)
VPNv6 changes picked from upstream needed fixes and updates due to some
fundamental changes implemented by Cumulus (BGP update-groups, RFC 5549
and nexthop setting etc.) which aren't present upstream.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Updates: 945c8fe8ecd326bb86c6093b73dff4c8985

bgpd/bgp_attr.c
bgpd/bgp_packet.c
bgpd/bgp_route.c
bgpd/bgp_updgrp_packet.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h
vtysh/vtysh.c

index 433924b54498f29dbe8d2903a908b980b3a930e6..0d828dc7dcda60481b22f09e22199fc5c0964a44 100644 (file)
@@ -41,7 +41,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "bgpd/bgp_packet.h"
 #include "bgpd/bgp_ecommunity.h"
 #include "bgpd/bgp_updgrp.h"
-#include "bgp_encap_types.h"
+#include "bgpd/bgp_encap_types.h"
 
 /* Attribute strings for logging. */
 static const struct message attr_str [] = 
@@ -2457,6 +2457,7 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi,
     case AFI_IP:
       switch (safi)
        {
+       case SAFI_UNICAST:
        case SAFI_MULTICAST:
          bpacket_attr_vec_arr_set_vec (vecarr, BGP_ATTR_VEC_NH, s, attr);
          stream_putc (s, 4);
@@ -2469,7 +2470,6 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi,
          stream_putl (s, 0);
          stream_put (s, &attr->extra->mp_nexthop_global_in, 4);
          break;
-       case SAFI_UNICAST:      /* invalid for IPv4 */
        default:
          break;
        }
@@ -2496,19 +2496,19 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi,
          struct attr_extra *attre = attr->extra;
 
          assert (attr->extra);
-          if (attre->mp_nexthop_len == 16) {
+          if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL) {
             stream_putc (s, 24);
             stream_putl (s, 0);   /* RD = 0, per RFC */
             stream_putl (s, 0);
-            stream_put (s, &attre->mp_nexthop_global, 16);
-          } else if (attre->mp_nexthop_len == 32) {
+            stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN);
+          } else if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) {
             stream_putc (s, 48);
             stream_putl (s, 0);   /* RD = 0, per RFC */
             stream_putl (s, 0);
-            stream_put (s, &attre->mp_nexthop_global, 16);
+            stream_put (s, &attre->mp_nexthop_global, IPV6_MAX_BYTELEN);
             stream_putl (s, 0);   /* RD = 0, per RFC */
             stream_putl (s, 0);
-            stream_put (s, &attre->mp_nexthop_local, 16);
+            stream_put (s, &attre->mp_nexthop_local, IPV6_MAX_BYTELEN);
           }
         }
        break;
index 02f5e82d4cf28bd1cf9615a2bb114884af29d764..3f69a98889d449bf5b85359c9d79655aa7e7ecd9 100644 (file)
@@ -1167,7 +1167,8 @@ bgp_open_receive (struct peer *peer, bgp_size_t size)
         }
     }
   if (peer->afc_nego[AFI_IP6][SAFI_UNICAST] ||
-      peer->afc_nego[AFI_IP6][SAFI_MULTICAST])
+      peer->afc_nego[AFI_IP6][SAFI_MULTICAST] ||
+      peer->afc_nego[AFI_IP6][SAFI_MPLS_VPN])
     {
       if (IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_global))
         {
index 8b39f3a561b4bb9391cddb6b407cd00a4f690d00..3be971e13167ea758059d0aca44594e92c24d48f 100644 (file)
@@ -2997,56 +2997,6 @@ bgp_clear_route_all (struct peer *peer)
       bgp_clear_route (peer, afi, safi);
 }
 
-/*
- * Finish freeing things when exiting
- */
-static void
-bgp_drain_workqueue_immediate (struct work_queue *wq)
-{
-  if (!wq)
-    return;
-
-  if (!wq->thread)
-    {
-      /*
-       * no thread implies no queued items
-       */
-      assert(!wq->items->count);
-      return;
-    }
-
-   while (wq->items->count)
-     {
-       if (wq->thread)
-         thread_cancel(wq->thread);
-       work_queue_run(wq->thread);
-     }
-}
-
-/*
- * Special function to process clear node queue when bgpd is exiting
- * and the thread scheduler is no longer running.
- */
-void
-bgp_peer_clear_node_queue_drain_immediate(struct peer *peer)
-{
-  if (!peer)
-    return;
-
-  bgp_drain_workqueue_immediate(peer->clear_node_queue);
-}
-
-/*
- * The work queues are not specific to a BGP instance, but the
- * items in them refer to BGP instances, so this should be called
- * before each BGP instance is deleted.
- */
-void
-bgp_process_queues_drain_immediate(void)
-{
-  bgp_drain_workqueue_immediate(bm->process_main_queue);
-}
-
 void
 bgp_clear_adj_in (struct peer *peer, afi_t afi, safi_t safi)
 {
index 63f88e932e02009138e5c799387af2b7023ee7bb..3cb3ddcdea256061eb420079fdd1a2e8f4e9f5be 100644 (file)
@@ -676,18 +676,10 @@ subgroup_update_packet (struct update_subgroup *subgrp)
       /* If packet is empty, set attribute. */
       if (stream_empty (s))
        {
-         struct prefix_rd *prd = NULL;
-         u_char *tag = NULL;
          struct peer *from = NULL;
 
-         if (rn->prn)
-           prd = (struct prefix_rd *) &rn->prn->p;
          if (binfo)
-            {
-              from = binfo->peer;
-              if (binfo->extra)
-                tag = binfo->extra->tag;
-            }
+            from = binfo->peer;
 
          /* 1: Write the BGP message header - 16 bytes marker, 2 bytes length,
           * one byte message type.
@@ -710,12 +702,13 @@ subgroup_update_packet (struct update_subgroup *subgrp)
          /* 5: Encode all the attributes, except MP_REACH_NLRI attr. */
          total_attr_len = bgp_packet_attribute (NULL, peer, s,
                                                 adv->baa->attr, &vecarr,
-                                                &rn->p, afi, safi,
-                                                from, prd, tag, 0, 0);
+                                                NULL, afi, safi,
+                                                from, NULL, NULL, 0, 0);
 
           space_remaining = STREAM_CONCAT_REMAIN (s, snlri, STREAM_SIZE(s)) -
                             BGP_MAX_PACKET_SIZE_OVERFLOW;
-          space_needed = BGP_NLRI_LENGTH + PSIZE (rn->p.prefixlen);
+          space_needed = BGP_NLRI_LENGTH +
+                         bgp_packet_mpattr_prefix_size (afi, safi, &rn->p);
 
           /* If the attributes alone do not leave any room for NLRI then
            * return */
@@ -879,8 +872,8 @@ subgroup_withdraw_packet (struct update_subgroup *subgrp)
 
       space_remaining = STREAM_REMAIN (s) -
                         BGP_MAX_PACKET_SIZE_OVERFLOW;
-      space_needed = (BGP_NLRI_LENGTH + BGP_TOTAL_ATTR_LEN +
-                      PSIZE (rn->p.prefixlen));
+      space_needed = BGP_NLRI_LENGTH + BGP_TOTAL_ATTR_LEN +
+                     bgp_packet_mpattr_prefix_size (afi, safi, &rn->p);
 
       if (space_remaining < space_needed)
        break;
index 5ff8c25f19a05164cb8869d96605c7162fc1fd70..49f217068b6d527eab1db5d09b2616ec7cfb939f 100644 (file)
@@ -74,9 +74,7 @@ bgp_node_afi (struct vty *vty)
 safi_t
 bgp_node_safi (struct vty *vty)
 {
-  if (vty->node == BGP_VPNV4_NODE)
-    return SAFI_MPLS_VPN;
-  if (vty->node == BGP_VPNV6_NODE)
+  if (vty->node == BGP_VPNV4_NODE || vty->node == BGP_VPNV6_NODE)
     return SAFI_MPLS_VPN;
   if (vty->node == BGP_IPV4M_NODE || vty->node == BGP_IPV6M_NODE)
     return SAFI_MULTICAST;
index 647ee8a354e7f93096e5e12a1bf1a8e692abee5c..10c580c777e5e9f2124d16b0a4f17d6a2d480ba7 100644 (file)
@@ -3044,8 +3044,6 @@ bgp_delete (struct bgp *bgp)
   afi_t afi;
   int i;
 
-  SET_FLAG(bgp->flags, BGP_FLAG_DELETING);
-
   THREAD_OFF (bgp->t_startup);
 
   if (BGP_DEBUG (zebra, ZEBRA))
index 40bfc7d1eaca61bb6b1628d144f49727cc96b667..c834f11232b61cf803ab6e883f8a42f203e4c223 100644 (file)
@@ -68,6 +68,7 @@ enum bgp_af_index
   BGP_AF_IPV4_VPN,
   BGP_AF_IPV6_UNICAST,
   BGP_AF_IPV6_MULTICAST,
+  BGP_AF_IPV6_VPN,
   BGP_AF_MAX
 };
 
@@ -281,7 +282,6 @@ struct bgp
 #define BGP_FLAG_MULTIPATH_RELAX_AS_SET   (1 << 17)
 #define BGP_FLAG_FORCE_STATIC_PROCESS     (1 << 18)
 #define BGP_FLAG_SHOW_HOSTNAME            (1 << 19)
-#define BGP_FLAG_DELETING                 (1 << 20)
 
   /* BGP Per AF flags */
   u_int16_t af_flags[AFI_MAX][SAFI_MAX];
@@ -1362,6 +1362,9 @@ afindex (afi_t afi, safi_t safi)
        case SAFI_MULTICAST:
          return BGP_AF_IPV6_MULTICAST;
          break;
+       case SAFI_MPLS_VPN:
+         return BGP_AF_IPV6_VPN;
+         break;
        default:
          return BGP_AF_MAX;
          break;
@@ -1403,7 +1406,8 @@ peer_group_af_configured (struct peer_group *group)
       || peer->afc[AFI_IP][SAFI_MULTICAST]
       || peer->afc[AFI_IP][SAFI_MPLS_VPN]
       || peer->afc[AFI_IP6][SAFI_UNICAST]
-      || peer->afc[AFI_IP6][SAFI_MULTICAST])
+      || peer->afc[AFI_IP6][SAFI_MULTICAST]
+      || peer->afc[AFI_IP6][SAFI_MPLS_VPN])
     return 1;
   return 0;
 }
index 4d862ed19d60697b55ec9b7c39a7d292b2a6162c..2cc379e0f31f3e91cda5014e01f79c2075bce23c 100644 (file)
@@ -575,7 +575,7 @@ vtysh_mark_file (const char *filename)
        {
          if ((prev_node == BGP_VPNV4_NODE || prev_node == BGP_IPV4_NODE
               || prev_node == BGP_IPV6_NODE || prev_node == BGP_IPV4M_NODE
-              || prev_node == BGP_IPV6M_NODE)
+              || prev_node == BGP_IPV6M_NODE || prev_node == BGP_VPNV6_NODE)
              && (tried == 1))
            {
              fprintf(stdout, "exit-address-family\n");