diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2016-10-27 08:02:36 +0200 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2017-02-14 13:58:59 +0100 |
| commit | 3da6fcd55711c5226fc2a29738ad886155d94bc5 (patch) | |
| tree | ef43da8f20e90d76922bd04f7389fd98b2b712ed /bgpd/bgp_attr_evpn.c | |
| parent | 4c63a661e367cdbb16edbdaff50a804428027dcc (diff) | |
bgpd: enhance network command for evpn route type 5
A new vty command available under evpn address family. This command
takes following format:
(af-evpn)# [no] network <A.B.C.D/M|X:X::X:X/M> rd ASN:nn_or_IP-address:nn ethtag WORD
label WORD esi WORD gwip A.B.C.D routermac WORD
[route-map WORD]
Among new parameters, ethtag stands for the ethernet tag indentifier.
ESI stands for the ethernet segment identifier, and must be entered in
following format: 00:11:22:33:44:55:66:77:88:99.
gwip stands for the gateway IP address contained in RT5 message. A
check is done on that value since if gwip is ipv4, then ip prefix must
be ipv4. The same for ipv6.
RouterMAc is the gateway mac address sent as extended community
attribute.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_attr_evpn.c')
| -rw-r--r-- | bgpd/bgp_attr_evpn.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c index a85ba002db..6f5a5ffc49 100644 --- a/bgpd/bgp_attr_evpn.c +++ b/bgpd/bgp_attr_evpn.c @@ -32,6 +32,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_route.h" #include "bgpd/bgp_attr_evpn.h" #include "bgpd/bgp_ecommunity.h" +#include "bgpd/bgp_evpn.h" void bgp_add_routermac_ecom (struct attr* attr, char * routermac) { @@ -281,3 +282,44 @@ char *ecom_mac2str(char *ecom_mac) en+=2; return mac2str(en); } + +/* dst prefix must be AF_INET or AF_INET6 prefix, to forge EVPN prefix */ +extern int bgp_build_evpn_prefix (int evpn_type, uint32_t eth_tag, struct prefix *dst) +{ +#if defined(HAVE_EVPN) + struct evpn_addr *p_evpn_p; + struct prefix p2; + struct prefix *src = &p2; + + if (!dst || dst->family == 0) + return -1; + /* store initial prefix in src */ + prefix_copy (src, dst); + memset (dst, 0, sizeof (struct prefix)); + p_evpn_p = &(dst->u.prefix_evpn); + dst->family = AF_ETHERNET; + p_evpn_p->route_type = evpn_type; + if (evpn_type == EVPN_IP_PREFIX) + { + p_evpn_p->eth_tag = eth_tag; + p_evpn_p->ip_prefix_length = p2.prefixlen; + if (src->family == AF_INET) + { + p_evpn_p->flags = IP_PREFIX_V4; + memcpy (&p_evpn_p->ip.v4_addr, &src->u.prefix4, sizeof(struct in_addr)); + dst->prefixlen = (u_char)PREFIX_LEN_ROUTE_TYPE_5_IPV4; + } + else + { + p_evpn_p->flags = IP_PREFIX_V6; + memcpy (&p_evpn_p->ip.v6_addr, &src->u.prefix6, sizeof(struct in6_addr)); + dst->prefixlen = (u_char)PREFIX_LEN_ROUTE_TYPE_5_IPV6; + } + } + else + return -1; + return 0; +#else + return -1; +#endif /* !(HAVE_EVPN) */ +} |
