summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_evpn.c
diff options
context:
space:
mode:
authorPhilippe Guibert <philippe.guibert@6wind.com>2016-09-05 14:19:40 +0200
committerPhilippe Guibert <philippe.guibert@6wind.com>2017-02-14 13:58:58 +0100
commitb18825ebc779cd85f9acc40293bb448a09af4cd2 (patch)
tree932579b21d4cf2e864259764c471961d406cac07 /bgpd/bgp_evpn.c
parentbgpd: evpn RT-5 bgp update carries nexthop attribute (diff)
downloadfrr-b18825ebc779cd85f9acc40293bb448a09af4cd2.tar.xz
frr-b18825ebc779cd85f9acc40293bb448a09af4cd2.zip
bgpd: evpn NLRI route type 5 forging
This patch introduces the ability to make route type 5 message when EVPN is enabled. Picked up paramters are collected from the bgp extra attribute structure and are the ESI, the ethernet tag information. In addition to this, nexthop attribute is collected too. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'bgpd/bgp_evpn.c')
-rw-r--r--bgpd/bgp_evpn.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index fd785b9a6..a9db7d236 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -187,3 +187,54 @@ bgp_nlri_parse_evpn (struct peer *peer, struct attr *attr,
return 0;
}
+
+void
+bgp_packet_mpattr_route_type_5 (struct stream *s,
+ struct prefix *p, struct prefix_rd *prd,
+ u_char *label, struct attr *attr)
+{
+ int len;
+ char temp[16];
+ struct evpn_addr *p_evpn_p;
+
+ memset(&temp, 0, 16);
+ if(p->family != AF_ETHERNET)
+ return;
+ p_evpn_p = &(p->u.prefix_evpn);
+ if (p_evpn_p->flags & IP_PREFIX_V4)
+ len = 8; /* ipv4 */
+ else
+ len = 32; /* ipv6 */
+ stream_putc (s, EVPN_IP_PREFIX);
+ stream_putc (s, 8 /* RD */ + 10 /* ESI */ + 4 /* EthTag */ + 1 + len + 3 /* label */);
+ stream_put (s, prd->val, 8);
+ if(attr && attr->extra)
+ stream_put (s, &(attr->extra->evpn_overlay.eth_s_id), 10);
+ else
+ stream_put (s, &temp, 10);
+ stream_putl (s, p_evpn_p->eth_tag);
+ stream_putc (s, p_evpn_p->ip_prefix_length);
+ if (p_evpn_p->flags & IP_PREFIX_V4)
+ stream_put_ipv4(s, p_evpn_p->ip.v4_addr.s_addr);
+ else
+ stream_put(s, &p_evpn_p->ip.v6_addr, 16);
+ if(attr && attr->extra)
+ {
+ if (p_evpn_p->flags & IP_PREFIX_V4)
+ stream_put_ipv4(s, attr->extra->evpn_overlay.gw_ip.ipv4.s_addr);
+ else
+ stream_put(s, &(attr->extra->evpn_overlay.gw_ip.ipv6), 16);
+ }
+ else
+ {
+ if (p_evpn_p->flags & IP_PREFIX_V4)
+ stream_put_ipv4(s, 0);
+ else
+ stream_put(s, &temp, 16);
+ }
+ if(label)
+ stream_put (s, label, 3);
+ else
+ stream_put3 (s, 0);
+ return;
+}