diff options
author | Philippe Guibert <philippe.guibert@6wind.com> | 2016-09-05 13:20:41 +0200 |
---|---|---|
committer | Philippe Guibert <philippe.guibert@6wind.com> | 2017-02-14 13:58:58 +0100 |
commit | dfa42ea338db2d3bec31d69544fb941bb1822594 (patch) | |
tree | dc0c11827e500b11f45144b3b12b4e649189d619 /bgpd | |
parent | bgpd: add EVPN RT5 gatewayIp address to bgp_static context (diff) | |
download | frr-dfa42ea338db2d3bec31d69544fb941bb1822594.tar.xz frr-dfa42ea338db2d3bec31d69544fb941bb1822594.zip |
bgpd: handling router mac extended community
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>
Diffstat (limited to 'bgpd')
-rw-r--r-- | bgpd/bgp_attr_evpn.c | 20 | ||||
-rw-r--r-- | bgpd/bgp_attr_evpn.h | 3 | ||||
-rw-r--r-- | bgpd/bgp_ecommunity.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_route.c | 4 |
4 files changed, 28 insertions, 1 deletions
diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c index 76c0e5119..a85ba002d 100644 --- a/bgpd/bgp_attr_evpn.c +++ b/bgpd/bgp_attr_evpn.c @@ -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) { diff --git a/bgpd/bgp_attr_evpn.h b/bgpd/bgp_attr_evpn.h index 1e8ad3801..6a779aefb 100644 --- a/bgpd/bgp_attr_evpn.h +++ b/bgpd/bgp_attr_evpn.h @@ -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 */ diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 2ea62bbb6..a5949728c 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -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; } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f92447667..8d513fa1d 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -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) |