Permalink
Browse files

bgpd: add PMSI_TUNNEL_ATTRIBUTE to EVPN IMET routes

Signed-off-by: Dario Wiesner <dario.wiesner@gmail.com>
  • Loading branch information...
dwiesner authored and vincentbernat committed Jan 4, 2018
1 parent 06f4728 commit 472f46bb39f104f2facafe707a644fc236c4669d
Showing with 21 additions and 0 deletions.
  1. +13 −0 bgpd/bgp_attr.c
  2. +4 −0 bgpd/bgp_attr.h
  3. +3 −0 bgpd/bgp_evpn.c
  4. +1 −0 bgpd/bgpd.h
@@ -72,6 +72,7 @@ static const struct message attr_str [] =
{ BGP_ATTR_AS4_PATH, "AS4_PATH" },
{ BGP_ATTR_AS4_AGGREGATOR, "AS4_AGGREGATOR" },
{ BGP_ATTR_AS_PATHLIMIT, "AS_PATHLIMIT" },
{ BGP_ATTR_PMSI_TUNNEL, "PMSI_TUNNEL_ATTRIBUTE" },
{ BGP_ATTR_ENCAP, "ENCAP" },
#if ENABLE_BGP_VNC
{ BGP_ATTR_VNC, "VNC" },
@@ -1143,6 +1144,7 @@ const u_int8_t attr_flags_values [] = {
[BGP_ATTR_EXT_COMMUNITIES] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_PATH] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_AGGREGATOR] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_PMSI_TUNNEL] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
};
static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1;

@@ -3237,6 +3239,17 @@ bgp_packet_attribute (struct bgp *bgp, struct peer *peer,
#endif
}

/* PMSI Tunnel */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL)) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_PMSI_TUNNEL);
stream_putc(s, 9); // Length
stream_putc(s, 0); // Flags
stream_putc(s, 6); // Tunnel type: Ingress Replication (6)
stream_put(s, &attr->label, 3); // MPLS Label / VXLAN VNI
stream_put_ipv4(s, attr->nexthop.s_addr); // Unicast tunnel endpoint IP address
}

/* Unknown transit attribute. */
if (attr->extra && attr->extra->transit)
stream_put (s, attr->extra->transit->val, attr->extra->transit->length);
@@ -21,6 +21,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#ifndef _QUAGGA_BGP_ATTR_H
#define _QUAGGA_BGP_ATTR_H

#include "mpls.h"

/* Simple bit mapping. */
#define BITMAP_NBBY 8

@@ -161,6 +163,8 @@ struct attr
/* has the route-map changed any attribute?
Used on the peer outbound side. */
u_int32_t rmap_change_flags;

mpls_label_t label;
};

/* rmap_change_flags definition */
@@ -782,6 +782,9 @@ update_evpn_route (struct bgp *bgp, struct bgpevpn *vpn,
/* Build path-attribute for this route. */
bgp_attr_default_set (&attr, BGP_ORIGIN_IGP);
attr.nexthop = vpn->originator_ip;
if (p->prefix.route_type == BGP_EVPN_IMET_ROUTE)
attr.flag |= ATTR_FLAG_BIT(BGP_ATTR_PMSI_TUNNEL);
vni2tag(vpn->vni, (uint8_t*)&attr.label);

/* Set up RT and ENCAP extended community. */
build_evpn_route_extcomm (vpn, &attr);
@@ -959,6 +959,7 @@ struct bgp_nlri
#define BGP_ATTR_AS4_PATH 17
#define BGP_ATTR_AS4_AGGREGATOR 18
#define BGP_ATTR_AS_PATHLIMIT 21
#define BGP_ATTR_PMSI_TUNNEL 22
#define BGP_ATTR_ENCAP 23
#if ENABLE_BGP_VNC
#define BGP_ATTR_VNC 255

0 comments on commit 472f46b

Please sign in to comment.