Permalink
Browse files

bgpd: encode VNI in ETI

This is not mandatory as per RFC 8365, but maybe it would help JunOS.
  • Loading branch information...
vincentbernat committed Apr 16, 2018
1 parent 53f9a83 commit 3a68266c333669663d265303d08847e276c6ecec
Showing with 16 additions and 13 deletions.
  1. +8 −8 bgpd/bgp_evpn.c
  2. +5 −2 bgpd/bgp_evpn.h
  3. +3 −3 bgpd/bgp_evpn_ui.c
@@ -1095,7 +1095,7 @@ update_routes_for_vni (struct bgp *bgp, struct bgpevpn *vpn)
/* Update and advertise the type-3 route (only one) followed by the
* locally learnt type-2 routes (MACIP) - for this VNI.
*/
build_evpn_type3_prefix (&p, vpn->originator_ip);
build_evpn_type3_prefix (&p, vpn->originator_ip, vpn->vni);
ret = update_evpn_route (bgp, vpn, &p);
if (ret)
return ret;
@@ -1122,7 +1122,7 @@ delete_routes_for_vni (struct bgp *bgp, struct bgpevpn *vpn)
if (ret)
return ret;

build_evpn_type3_prefix (&p, vpn->originator_ip);
build_evpn_type3_prefix (&p, vpn->originator_ip, vpn->vni);
ret = delete_evpn_route (bgp, vpn, &p);
if (ret)
return ret;
@@ -1150,7 +1150,7 @@ update_advertise_vni_routes (struct bgp *bgp, struct bgpevpn *vpn)
* attributes to create and advertise the type-3 route for this VNI
* in the global table.
*/
build_evpn_type3_prefix (&p, vpn->originator_ip);
build_evpn_type3_prefix (&p, vpn->originator_ip, vpn->vni);
rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p);
if (!rn) /* unexpected */
return 0;
@@ -1231,7 +1231,7 @@ delete_withdraw_vni_routes (struct bgp *bgp, struct bgpevpn *vpn)
return ret;

/* Remove type-3 route for this VNI from global table. */
build_evpn_type3_prefix (&p, vpn->originator_ip);
build_evpn_type3_prefix (&p, vpn->originator_ip, vpn->vni);
global_rn = bgp_afi_node_lookup (bgp->rib[afi][safi], afi, safi,
(struct prefix *)&p, &vpn->prd);
if (global_rn)
@@ -1335,7 +1335,7 @@ handle_tunnel_ip_change (struct bgp *bgp, struct bgpevpn *vpn,
/* Need to withdraw type-3 route as the originator IP is part
* of the key.
*/
build_evpn_type3_prefix (&p, vpn->originator_ip);
build_evpn_type3_prefix (&p, vpn->originator_ip, vpn->vni);
delete_evpn_route (bgp, vpn, &p);

/* Update the tunnel IP and re-advertise all routes for this VNI. */
@@ -2438,7 +2438,7 @@ bgp_evpn_local_macip_add (struct bgp *bgp, vni_t vni,
}

/* Create EVPN type-2 route and schedule for processing. */
build_evpn_type2_prefix (&p, mac, ip);
build_evpn_type2_prefix (&p, mac, ip, vpn->vni);
if (update_evpn_route (bgp, vpn, &p))
{
char buf[MACADDR_STRLEN];
@@ -2486,7 +2486,7 @@ bgp_evpn_local_macip_del (struct bgp *bgp, vni_t vni,
}

/* Remove EVPN type-2 route and schedule for processing. */
build_evpn_type2_prefix (&p, mac, ip);
build_evpn_type2_prefix (&p, mac, ip, vpn->vni);
delete_evpn_route (bgp, vpn, &p);

return 0;
@@ -2544,7 +2544,7 @@ bgp_evpn_local_vni_add (struct bgp *bgp, vni_t vni, struct in_addr originator_ip
SET_FLAG (vpn->flags, VNI_FLAG_LIVE);

/* Create EVPN type-3 route and schedule for processing. */
build_evpn_type3_prefix (&p, vpn->originator_ip);
build_evpn_type3_prefix (&p, vpn->originator_ip, vpn->vni);
if (update_evpn_route (bgp, vpn, &p))
{
zlog_err ("%u: Type3 route creation failure for VNI %u",
@@ -176,25 +176,28 @@ encode_mac_mobility_extcomm (int static_mac, u_int32_t seq,

static inline void
build_evpn_type2_prefix (struct prefix_evpn *p, struct ethaddr *mac,
struct ipaddr *ip)
struct ipaddr *ip, uint32_t eth_tag)
{
memset (p, 0, sizeof (struct prefix_evpn));
p->family = AF_ETHERNET;
p->prefixlen = EVPN_TYPE_2_ROUTE_PREFIXLEN;
p->prefix.route_type = BGP_EVPN_MAC_IP_ROUTE;
p->prefix.eth_tag = eth_tag;
memcpy(&p->prefix.mac.octet, mac->octet, ETHER_ADDR_LEN);
p->prefix.ip.ipa_type = IPADDR_NONE;
if (ip)
memcpy(&p->prefix.ip, ip, sizeof (*ip));
}

static inline void
build_evpn_type3_prefix (struct prefix_evpn *p, struct in_addr originator_ip)
build_evpn_type3_prefix (struct prefix_evpn *p, struct in_addr originator_ip,
uint32_t eth_tag)
{
memset (p, 0, sizeof (struct prefix_evpn));
p->family = AF_ETHERNET;
p->prefixlen = EVPN_TYPE_3_ROUTE_PREFIXLEN;
p->prefix.route_type = BGP_EVPN_IMET_ROUTE;
p->prefix.eth_tag = eth_tag;
p->prefix.ip.ipa_type = IPADDR_V4;
p->prefix.ip.ip.v4_addr = originator_ip;
}
@@ -798,7 +798,7 @@ bgp_evpn_show_route_vni_multicast (struct vty *vty, struct bgp *bgp,
}

/* See if route exists. */
build_evpn_type3_prefix (&p, orig_ip);
build_evpn_type3_prefix (&p, orig_ip, vni);
rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p);
if (!rn || !rn->info)
{
@@ -848,7 +848,7 @@ bgp_evpn_show_route_vni_mac (struct vty *vty, struct bgp *bgp,
}

/* See if route exists. */
build_evpn_type2_prefix (&p, mac, NULL);
build_evpn_type2_prefix (&p, mac, NULL, vni);
rn = bgp_node_lookup (vpn->route_table, (struct prefix *)&p);
if (!rn || !rn->info)
{
@@ -911,7 +911,7 @@ bgp_evpn_show_route_rd_mac (struct vty *vty, struct bgp *bgp,
safi = SAFI_EVPN;

/* See if route exists. */
build_evpn_type2_prefix (&p, mac, NULL);
build_evpn_type2_prefix (&p, mac, NULL, 0);
rn = bgp_afi_node_lookup (bgp->rib[afi][safi], afi, safi,
(struct prefix *)&p, prd);
if (!rn || !rn->info)

0 comments on commit 3a68266

Please sign in to comment.