]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: handling router mac extended community
authorPhilippe Guibert <philippe.guibert@6wind.com>
Mon, 5 Sep 2016 11:20:41 +0000 (13:20 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 14 Feb 2017 12:58:58 +0000 (13:58 +0100)
For each received routermac extended community, the mac address is
copied into routermac extended community context. For each emission,
a check is done against routermac extended community, if L2VPN is
enabled. If enabled, the extended community is appended.

Signed-off-by: Philippe Gubiert <philippe.guibert@6wind.com>
bgpd/bgp_attr_evpn.c
bgpd/bgp_attr_evpn.h
bgpd/bgp_ecommunity.c
bgpd/bgp_route.c

index 76c0e51198c854842dfe9980065337e262870600..a85ba002dbac74bda9155f0b64864716e2812787 100644 (file)
@@ -27,7 +27,27 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "memory.h"
 #include "stream.h"
 
+#include "bgpd/bgpd.h"
+#include "bgpd/bgp_attr.h"
+#include "bgpd/bgp_route.h"
 #include "bgpd/bgp_attr_evpn.h"
+#include "bgpd/bgp_ecommunity.h"
+
+void bgp_add_routermac_ecom (struct attr* attr, char * routermac)
+{
+  struct ecommunity_val routermac_ecom;
+
+  if(attr->extra)
+    {
+      memset(&routermac_ecom, 0, sizeof(struct ecommunity_val));
+      routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN;
+      routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC;
+      memcpy(&routermac_ecom.val[2], routermac, MAC_LEN);
+      if(!attr->extra->ecommunity)
+        attr->extra->ecommunity = ecommunity_new ();
+      ecommunity_add_val(attr->extra->ecommunity, &routermac_ecom);
+    }
+}
 
 static uint8_t convertchartohexa (uint8_t *hexa, int *error)
 {
index 1e8ad3801cabe611941fe83d8f8eaf115ad0a49c..6a779aefbfcd18c3da106c897d039975d75328c2 100644 (file)
@@ -33,6 +33,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
 #define MAX_ET 0xffffffff
 u_long eth_tag_id;
+struct attr;
 
 struct eth_segment_id
 {
@@ -58,4 +59,6 @@ extern char *esi2str (struct eth_segment_id *id);
 extern char *mac2str (char *mac);
 extern char *ecom_mac2str(char *ecom_mac);
 
+extern void bgp_add_routermac_ecom (struct attr* attr, char * routermac);
+
 #endif /* _QUAGGA_BGP_ATTR_EVPN_H */
index 2ea62bbb6d4109df53f87a7814562ec414196135..a5949728c259e15728ef88a34073ba68a045ebcc 100644 (file)
@@ -213,7 +213,7 @@ ecommunity_intern (struct ecommunity *ecom)
   find->refcnt++;
 
   if (! find->str)
-    find->str = ecommunity_ecom2str (find, ECOMMUNITY_FORMAT_DISPLAY, 0);
+    find->str = ecommunity_ecom2str (find, ECOMMUNITY_FORMAT_DISPLAY, ECOMMUNITY_ROUTE_TARGET);
 
   return find;
 }
index f924476677e854be6c668bbd4e5d3ecf52cdf186..8d513fa1dc55588a46adf314cf9a409f96cd4b63 100644 (file)
@@ -4019,6 +4019,10 @@ bgp_static_update_safi (struct bgp *bgp, struct prefix *p,
           bet.vnid = p->u.prefix_evpn.eth_tag;
           bgp_encap_type_vxlan_to_tlv(&bet, &attr);
         }
+      if (bgp_static->router_mac)
+        {
+          bgp_add_routermac_ecom (&attr, bgp_static->router_mac);
+        }
     }
   /* Apply route-map. */
   if (bgp_static->rmap.name)