[quagga-dev 16450] [PATCH 17/23] bgpd: support for max_mpath vrf field configuration

Philippe Guibert philippe.guibert at 6wind.com
Fri Dec 2 16:30:06 GMT 2016


This commit enhances the ability to configure from capnproto the maximum
path field per vrf. The ability to configure multipath for an afi/safi
is also made possible.

Signed-off-by: Philippe Guibert <philippe.guibert at 6wind.com>
---
 bgpd/bgp.bcapnp.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 bgpd/bgp.bcapnp.h |  1 +
 bgpd/bgp.capnp    |  1 +
 bgpd/bgpd.ndef.i  | 21 +++++++++++++++++++
 4 files changed, 80 insertions(+), 4 deletions(-)

diff --git a/bgpd/bgp.bcapnp.c b/bgpd/bgp.bcapnp.c
index 2bf038128cd1..135a54f34dc6 100644
--- a/bgpd/bgp.bcapnp.c
+++ b/bgpd/bgp.bcapnp.c
@@ -415,6 +415,16 @@ void qcapn_BGPAfiSafi_read(struct bgp *s, capn_ptr p, afi_t afi, safi_t safi)
       if (tmp) s->af_flags[afi][safi] |=  BGP_CONFIG_DAMPENING;
       else     s->af_flags[afi][safi] &= ~BGP_CONFIG_DAMPENING;
     }
+    { bool tmp;
+      tmp = !!(capn_read8(p, 0) & (1 << 1));
+      if (tmp) s->af_flags[afi][safi] |=  BGP_CONFIG_ASPATH_MULTIPATH_RELAX;
+      else     s->af_flags[afi][safi] &= ~BGP_CONFIG_ASPATH_MULTIPATH_RELAX;
+    }
+    { bool tmp;
+      tmp = !!(capn_read8(p, 0) & (1 << 2));
+      if (tmp) s->af_flags[afi][safi] |=  BGP_CONFIG_MULTIPATH;
+      else     s->af_flags[afi][safi] &= ~BGP_CONFIG_MULTIPATH;
+    }
 }
 
 
@@ -423,6 +433,8 @@ void qcapn_BGPAfiSafi_write(const struct bgp *s, capn_ptr p, afi_t afi, safi_t s
 {
     capn_resolve(&p);
     capn_write1(p, 0, !!(s->af_flags[afi][safi] & BGP_CONFIG_DAMPENING));
+    capn_write1(p, 1, !!(s->af_flags[afi][safi] & BGP_CONFIG_ASPATH_MULTIPATH_RELAX));
+    capn_write1(p, 2, !!(s->af_flags[afi][safi] & BGP_CONFIG_MULTIPATH));
 }
 
 
@@ -435,13 +447,51 @@ void qcapn_BGPAfiSafi_set(struct bgp *s, capn_ptr p, afi_t afi, safi_t safi)
       flags = !!(capn_read8(p, 0) & (1 << 0));
       if (flags) bgp_af_flag_set(s, BGP_CONFIG_DAMPENING, afi, safi);
         else bgp_af_flag_unset(s, BGP_CONFIG_DAMPENING, afi, safi);
+      flags = !!(capn_read8(p, 0) & (1 << 1));
+      if (flags)
+      {
+        bgp_af_flag_set(s, BGP_CONFIG_ASPATH_MULTIPATH_RELAX, afi, safi);
+      }
+      else
+      {
+        bgp_af_flag_unset(s, BGP_CONFIG_ASPATH_MULTIPATH_RELAX, afi, safi);
+      }
+    }
+    {
+      u_int16_t flags;
+      flags = !!(capn_read8(p, 0) & (1 << 2));
+      if (flags)
+      {
+        uint8_t max = capn_read8(p, 3);
+        bgp_af_flag_set(s, BGP_CONFIG_MULTIPATH, afi, safi);
+        bgp_maximum_paths_set (s, AFI_IP, SAFI_MPLS_VPN,
+                               BGP_PEER_EBGP, max);
+        bgp_maximum_paths_set (s, AFI_IP, SAFI_MPLS_VPN,
+                               BGP_PEER_IBGP, max);
+        bgp_maximum_paths_set (s, AFI_IP, SAFI_UNICAST,
+                               BGP_PEER_EBGP, max);
+        bgp_maximum_paths_set (s, AFI_IP, SAFI_UNICAST,
+                               BGP_PEER_IBGP, max);
+      }
+      else
+      {
+        bgp_af_flag_unset(s, BGP_CONFIG_MULTIPATH, afi, safi);
+        bgp_maximum_paths_unset (s, AFI_IP, SAFI_MPLS_VPN,
+                                 BGP_PEER_EBGP);
+        bgp_maximum_paths_unset (s, AFI_IP, SAFI_MPLS_VPN,
+                                 BGP_PEER_IBGP);
+        bgp_maximum_paths_unset (s, AFI_IP, SAFI_UNICAST,
+                                 BGP_PEER_EBGP);
+        bgp_maximum_paths_unset (s, AFI_IP, SAFI_UNICAST,
+                                 BGP_PEER_IBGP);
+      }
     }
 }
 
 
 capn_ptr qcapn_new_BGPAfiSafi(struct capn_segment *s)
 {
-    return capn_new_struct(s, 8, 0);
+    return capn_new_struct(s, 16, 0);
 }
 
 
@@ -936,7 +986,7 @@ void qcapn_BGPVRF_read(struct bgp_vrf *s, capn_ptr p)
     memcpy(&s->outbound_rd.val, &tmp, 8);
     s->outbound_rd.family = AF_UNSPEC;
     s->outbound_rd.prefixlen = 64;
-    
+    s->max_mpath = capn_read32(p, 8);
     {
         capn_ptr tmp_p = capn_getp(p, 0, 1);
         capn_list64 listptr = { .p = capn_getp(tmp_p, 0, 1) };
@@ -969,7 +1019,7 @@ void qcapn_BGPVRF_write(const struct bgp_vrf *s, capn_ptr p)
     memcpy(&tmp,&(s->outbound_rd.val), 8);
     capn_resolve(&p);
     capn_write64(p, 0, tmp);
-    
+    capn_write32(p, 8, s->max_mpath);
     {
         capn_ptr tempptr = capn_new_struct(p.seg, 0, 1);
         size_t size = s->rt_import ? s->rt_import->size : 0;
@@ -997,6 +1047,9 @@ void qcapn_BGPVRF_set(struct bgp_vrf *s, capn_ptr p)
 {
     capn_resolve(&p);
     {
+      s->max_mpath = capn_read32(p, 8);
+    }
+    {
       /* MISSING: outbound_rd */
     }
     {
@@ -1048,7 +1101,7 @@ struct prefix_rd qcapn_BGPVRF_get_outbound_rd(capn_ptr p)
 
 capn_ptr qcapn_new_BGPVRF(struct capn_segment *s)
 {
-    return capn_new_struct(s, 8, 2);
+    return capn_new_struct(s, 12, 2);
 }
 
 
diff --git a/bgpd/bgp.bcapnp.h b/bgpd/bgp.bcapnp.h
index 3b8ce361f6b2..eb0cba4a43c7 100644
--- a/bgpd/bgp.bcapnp.h
+++ b/bgpd/bgp.bcapnp.h
@@ -7,6 +7,7 @@
 
 #include "zebra.h"
 #include "bgpd.h"
+#include "bgp_mpath.h"
 afi_t qcapn_AfiSafiKey_get_afi(capn_ptr p);
 safi_t qcapn_AfiSafiKey_get_safi(capn_ptr p);
 capn_ptr qcapn_new_AfiSafiKey(struct capn_segment *s);
diff --git a/bgpd/bgp.capnp b/bgpd/bgp.capnp
index 27a917ff62cd..fcee0c975962 100644
--- a/bgpd/bgp.capnp
+++ b/bgpd/bgp.capnp
@@ -163,6 +163,7 @@ struct BGPVRF $ctype("struct bgp_vrf") $cgen
 	outboundRd		 @0 :UInt64 $cgetfield;
 	rtImport		 @1 :ExtCommunityList;
 	rtExport		 @2 :ExtCommunityList;
+	max_mpath		 @3 :UInt32 $cgetfield;
 }
 
 struct BGPVRFRoute $ctype("struct bgp_api_route") $cgen
diff --git a/bgpd/bgpd.ndef.i b/bgpd/bgpd.ndef.i
index c235b557479f..c7be77b98688 100644
--- a/bgpd/bgpd.ndef.i
+++ b/bgpd/bgpd.ndef.i
@@ -246,6 +246,24 @@ _qzc_set_bgp_1(struct bgp *p,
     qcapn_BGP_set(p, req->data);
 }
 
+static void
+_qzc_set_bgp_2(struct bgp *p,
+        struct QZCSetReq *req,
+        struct capn_segment *seg)
+{
+    afi_t afi;
+    safi_t safi;
+
+    afi = qcapn_AfiSafiKey_get_afi (req->ctxdata);
+    safi = qcapn_AfiSafiKey_get_safi (req->ctxdata);
+
+    if (req->datatype != 0xfd0316f1800ae916)
+        /* error */
+        return;
+
+    qcapn_BGPAfiSafi_set(p, req->data, afi, safi);
+}
+
 /* [3fafaa5ff15d4317] bgp <> bgp */
 static void
 _qzc_get_bgp(void *entity, struct QZCGetReq *req, struct QZCGetRep *rep,
@@ -296,6 +314,9 @@ _qzc_set_bgp(void *entity,
     case 1:
         _qzc_set_bgp_1(p, req, seg);
         return;
+    case 2:
+        _qzc_set_bgp_2(p, req, seg);
+        return;
     default:
         return;
     }
-- 
2.1.4





More information about the Quagga-dev mailing list