Skip to content

Commit

Permalink
Merge pull request #8 in FRR/frr from ~ANURADHAK/frr:mh_dev_next to d…
Browse files Browse the repository at this point in the history
…ev_next

* commit '1596ed17b676b78616140654b1b935eae4f65067': (119 commits)
  bgpd: on VTEP de-activate path must be un-imported from the VRF
  zebra: fixup pending items
  zebra: increment the nhg proto score iterator
  zebra: fix refcnt/rib issues in NHG replace/delete
  zebra: warn if zapi NHG add has no nexthops
  zebra: handle proto NHG uninstall client disconnect
  zebra: inc/dec refcount on add/del NHG proto
  zebra: remove unneeded nhg repalce boilerplate
  bgpd: set NHG flags for evpn routes installed with NHG ID
  bgpd: add a config knob to enable use of L3 NHG for EVPN host routes
  Revert "bgpd: temporarily disable installion of L3 NHGs"
  zebra: fix fdb netlink update handler
  zebra: change the nhg format from hex to dec for easy match up with the dp
  zebra: skip NDA_DST attr if NHG is present
  bgpd: temporarily disable installion of L3 NHGs
  zebra: fixup problem with neigh "sync" flag setting
  zebra: add json output for zebra ES, ES-EVI and access vlan dumps
  lib, bgpd: move json_array_string_add to lib
  zebra: Prevent duplicate re-install
  lib,doc: add `onlink` flag to nexthop group config
  ...
  • Loading branch information
sworleys committed May 21, 2020
2 parents d5e1ee9 + 1596ed1 commit b2b0c78
Show file tree
Hide file tree
Showing 101 changed files with 20,968 additions and 7,855 deletions.
13 changes: 12 additions & 1 deletion bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,11 @@ bool attrhash_cmp(const void *p1, const void *p2)
&& IPV4_ADDR_SAME(&attr1->originator_id,
&attr2->originator_id)
&& overlay_index_same(attr1, attr2)
&& !memcmp(&attr1->esi, &attr2->esi, sizeof(esi_t))
&& attr1->es_flags == attr2->es_flags
&& attr1->mm_sync_seqnum == attr2->mm_sync_seqnum
&& attr1->df_pref == attr2->df_pref
&& attr1->df_alg == attr2->df_alg
&& attr1->nh_ifindex == attr2->nh_ifindex
&& attr1->nh_lla_ifindex == attr2->nh_lla_ifindex
&& attr1->distance == attr2->distance
Expand Down Expand Up @@ -2199,6 +2204,7 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
struct attr *const attr = args->attr;
const bgp_size_t length = args->length;
uint8_t sticky = 0;
bool proxy = false;

if (length == 0) {
attr->ecommunity = NULL;
Expand All @@ -2221,6 +2227,9 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)

attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_EXT_COMMUNITIES);

/* Extract DF election preference and mobility sequence number */
attr->df_pref = bgp_attr_df_pref_from_ec(attr, &attr->df_alg);

/* Extract MAC mobility sequence number, if any. */
attr->mm_seqnum = bgp_attr_mac_mobility_seqnum(attr, &sticky);
attr->sticky = sticky;
Expand All @@ -2236,7 +2245,9 @@ bgp_attr_ext_communities(struct bgp_attr_parser_args *args)
attr->router_flag = 1;

/* Check EVPN Neighbor advertisement flags, R-bit */
bgp_attr_evpn_na_flag(attr, &attr->router_flag);
bgp_attr_evpn_na_flag(attr, &attr->router_flag, &proxy);
if (proxy)
attr->es_flags |= ATTR_ES_PROXY_ADVERT;

/* Extract the Rmac, if any */
if (bgp_attr_rmac(attr, &attr->rmac)) {
Expand Down
38 changes: 38 additions & 0 deletions bgpd/bgp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,30 @@ struct attr {
/* NA router flag (R-bit) support in EVPN */
uint8_t router_flag;

/* ES info */
uint8_t es_flags;
/* Path is not "locally-active" on the advertising VTEP. This is
* translated into an ARP-ND ECOM.
*/
#define ATTR_ES_PROXY_ADVERT (1 << 0)
/* Destination ES is present locally. This flag is set on local
* paths and sync paths
*/
#define ATTR_ES_IS_LOCAL (1 << 1)
/* There are one or more non-best paths from ES peers. Note that
* this flag is only set on the local MAC-IP paths in the VNI
* route table (not set in the global routing table). And only
* non-proxy advertisements from an ES peer can result in this
* flag being set.
*/
#define ATTR_ES_PEER_ACTIVE (1 << 2)
/* There are one or more non-best proxy paths from ES peers */
#define ATTR_ES_PEER_PROXY (1 << 3)
/* An ES peer has router bit set - only applicable if
* ATTR_ES_PEER_ACTIVE is set
*/
#define ATTR_ES_PEER_ROUTER (1 << 4)

/* route tag */
route_tag_t tag;

Expand All @@ -241,6 +265,13 @@ struct attr {

/* EVPN MAC Mobility sequence number, if any. */
uint32_t mm_seqnum;
/* highest MM sequence number rxed in a MAC-IP route from an
* ES peer (this includes both proxy and non-proxy MAC-IP
* advertisements from ES peers).
* This is only applicable to local paths in the VNI routing
* table and derived from other imported/non-best paths.
*/
uint32_t mm_sync_seqnum;

/* EVPN local router-mac */
struct ethaddr rmac;
Expand All @@ -253,6 +284,13 @@ struct attr {

/* Link bandwidth value, if any. */
uint32_t link_bw;

/* EVPN ES */
esi_t esi;

/* EVPN DF preference and algorithm for DF election on local ESs */
uint16_t df_pref;
uint8_t df_alg;
};

/* rmap_change_flags definition */
Expand Down
90 changes: 51 additions & 39 deletions bgpd/bgp_attr_evpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "log.h"
#include "memory.h"
#include "stream.h"
#include "vxlan.h"

#include "bgpd/bgpd.h"
#include "bgpd/bgp_attr.h"
Expand Down Expand Up @@ -54,47 +55,27 @@ void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac)
* format accepted: AA:BB:CC:DD:EE:FF:GG:HH:II:JJ
* if id is null, check only is done
*/
bool str2esi(const char *str, struct eth_segment_id *id)
bool str2esi(const char *str, esi_t *id)
{
unsigned int a[ESI_LEN];
unsigned int a[ESI_BYTES];
int i;

if (!str)
return false;
if (sscanf(str, "%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x:%2x", a + 0, a + 1,
a + 2, a + 3, a + 4, a + 5, a + 6, a + 7, a + 8, a + 9)
!= ESI_LEN) {
!= ESI_BYTES) {
/* error in incoming str length */
return false;
}
/* valid mac address */
if (!id)
return true;
for (i = 0; i < ESI_LEN; ++i)
for (i = 0; i < ESI_BYTES; ++i)
id->val[i] = a[i] & 0xff;
return true;
}

char *esi2str(struct eth_segment_id *id)
{
char *ptr;
uint8_t *val;

if (!id)
return NULL;

val = id->val;
ptr = XMALLOC(MTYPE_TMP,
(ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char));

snprintf(ptr, (ESI_LEN * 2 + ESI_LEN - 1 + 1),
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", val[0],
val[1], val[2], val[3], val[4], val[5], val[6], val[7], val[8],
val[9]);

return ptr;
}

char *ecom_mac2str(char *ecom_mac)
{
char *en;
Expand Down Expand Up @@ -165,6 +146,43 @@ uint8_t bgp_attr_default_gw(struct attr *attr)
return 0;
}

/*
* Fetch and return the DF preference and algorithm from
* DF election extended community, if present, else 0.
*/
uint16_t bgp_attr_df_pref_from_ec(struct attr *attr, uint8_t *alg)
{
struct ecommunity *ecom;
int i;
uint16_t df_pref = 0;

*alg = EVPN_MH_DF_ALG_SERVICE_CARVING;
ecom = attr->ecommunity;
if (!ecom || !ecom->size)
return 0;

for (i = 0; i < ecom->size; i++) {
uint8_t *pnt;
uint8_t type, sub_type;

pnt = (ecom->val + (i * ECOMMUNITY_SIZE));
type = *pnt++;
sub_type = *pnt++;
if (!(type == ECOMMUNITY_ENCODE_EVPN
&& sub_type == ECOMMUNITY_EVPN_SUBTYPE_DF_ELECTION))
continue;

*alg = (*pnt++) & ECOMMUNITY_EVPN_SUBTYPE_DF_ALG_BITS;

pnt += 3;
pnt = ptr_get_be16(pnt, &df_pref);
(void)pnt; /* consume value */
break;
}

return df_pref;
}

/*
* Fetch and return the sequence number from MAC Mobility extended
* community, if present, else 0.
Expand Down Expand Up @@ -215,7 +233,8 @@ uint32_t bgp_attr_mac_mobility_seqnum(struct attr *attr, uint8_t *sticky)
/*
* return true if attr contains router flag extended community
*/
void bgp_attr_evpn_na_flag(struct attr *attr, uint8_t *router_flag)
void bgp_attr_evpn_na_flag(struct attr *attr,
uint8_t *router_flag, bool *proxy)
{
struct ecommunity *ecom;
int i;
Expand All @@ -237,10 +256,14 @@ void bgp_attr_evpn_na_flag(struct attr *attr, uint8_t *router_flag)
if (type == ECOMMUNITY_ENCODE_EVPN &&
sub_type == ECOMMUNITY_EVPN_SUBTYPE_ND) {
val = *pnt++;
if (val & ECOMMUNITY_EVPN_SUBTYPE_ND_ROUTER_FLAG) {

if (val & ECOMMUNITY_EVPN_SUBTYPE_ND_ROUTER_FLAG)
*router_flag = 1;
break;
}

if (val & ECOMMUNITY_EVPN_SUBTYPE_PROXY_FLAG)
*proxy = true;

break;
}
}
}
Expand Down Expand Up @@ -292,14 +315,3 @@ extern bool is_zero_gw_ip(const union gw_addr *gw_ip, const afi_t afi)

return false;
}

extern bool is_zero_esi(const struct eth_segment_id *esi)
{
int i;

for (i = 0; i < ESI_LEN; i++)
if (esi->val[i])
return false;

return true;
}
25 changes: 4 additions & 21 deletions bgpd/bgp_attr_evpn.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,20 @@
#ifndef _QUAGGA_BGP_ATTR_EVPN_H
#define _QUAGGA_BGP_ATTR_EVPN_H

/* value of first byte of ESI */
#define ESI_TYPE_ARBITRARY 0 /* */
#define ESI_TYPE_LACP 1 /* <> */
#define ESI_TYPE_BRIDGE 2 /* <Root bridge Mac-6B>:<Root Br Priority-2B>:00 */
#define ESI_TYPE_MAC 3 /* <Syst Mac Add-6B>:<Local Discriminator Value-3B> */
#define ESI_TYPE_ROUTER 4 /* <RouterId-4B>:<Local Discriminator Value-4B> */
#define ESI_TYPE_AS 5 /* <AS-4B>:<Local Discriminator Value-4B> */

#define MAX_ESI {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}
#define ESI_LEN 10

#define MAX_ET 0xffffffff

struct attr;

/* EVPN ESI */
struct eth_segment_id {
uint8_t val[ESI_LEN];
};

union gw_addr {
struct in_addr ipv4;
struct in6_addr ipv6;
};

struct bgp_route_evpn {
struct eth_segment_id eth_s_id;
union gw_addr gw_ip;
};

extern bool str2esi(const char *str, struct eth_segment_id *id);
extern char *esi2str(struct eth_segment_id *id);
extern bool str2esi(const char *str, esi_t *id);
extern char *ecom_mac2str(char *ecom_mac);

extern void bgp_add_routermac_ecom(struct attr *attr,
Expand All @@ -64,9 +46,10 @@ extern uint32_t bgp_attr_mac_mobility_seqnum(struct attr *attr,
uint8_t *sticky);
extern uint8_t bgp_attr_default_gw(struct attr *attr);

extern void bgp_attr_evpn_na_flag(struct attr *attr, uint8_t *router_flag);
extern void bgp_attr_evpn_na_flag(struct attr *attr, uint8_t *router_flag,
bool *proxy);
extern uint16_t bgp_attr_df_pref_from_ec(struct attr *attr, uint8_t *alg);

extern bool is_zero_gw_ip(const union gw_addr *gw_ip, afi_t afi);

extern bool is_zero_esi(const struct eth_segment_id *esi);
#endif /* _QUAGGA_BGP_ATTR_EVPN_H */
Loading

0 comments on commit b2b0c78

Please sign in to comment.