Skip to content

Commit

Permalink
rfapi: pickup recent changes
Browse files Browse the repository at this point in the history
       expose bgp_rfapi_get_group_by_lni_label for use by rfp
       add EVPN Ethernet Tag (VID) RT
       ensure as is init'ed
       fix spelling of information
  • Loading branch information
louberger committed Dec 19, 2016
1 parent 6696566 commit ddf0364
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 44 deletions.
2 changes: 1 addition & 1 deletion bgpd/rfapi/bgp_rfapi_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -3778,7 +3778,7 @@ static struct cmd_node bgp_vnc_l2_group_node = {
1
};

static struct rfapi_l2_group_cfg *
struct rfapi_l2_group_cfg *
bgp_rfapi_get_group_by_lni_label (
struct bgp *bgp,
uint32_t logical_net_id,
Expand Down
6 changes: 6 additions & 0 deletions bgpd/rfapi/bgp_rfapi_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ bgp_rfapi_show_summary (struct bgp *bgp, struct vty *vty);
extern struct rfapi_cfg *
bgp_rfapi_get_config (struct bgp *bgp);

extern struct rfapi_l2_group_cfg *
bgp_rfapi_get_group_by_lni_label (
struct bgp *bgp,
uint32_t logical_net_id,
uint32_t label);

extern struct ecommunity *
bgp_rfapi_get_ecommunity_by_lni_label (
struct bgp *bgp,
Expand Down
28 changes: 27 additions & 1 deletion bgpd/rfapi/rfapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2842,13 +2842,39 @@ rfapi_register (
* If mac address is set, add an RT based on the registered LNI
*/
memset ((char *) &ecom_value, 0, sizeof (ecom_value));
ecom_value.val[1] = 0x02;
ecom_value.val[1] = ECOMMUNITY_ROUTE_TARGET;
ecom_value.val[5] = (l2o->logical_net_id >> 16) & 0xff;
ecom_value.val[6] = (l2o->logical_net_id >> 8) & 0xff;
ecom_value.val[7] = (l2o->logical_net_id >> 0) & 0xff;
rtlist = ecommunity_new();
ecommunity_add_val (rtlist, &ecom_value);
}
if (l2o->tag_id)
{
as_t as = bgp->as;
uint16_t val = l2o->tag_id;
memset ((char *) &ecom_value, 0, sizeof (ecom_value));
ecom_value.val[1] = ECOMMUNITY_ROUTE_TARGET;
if (as > BGP_AS_MAX)
{
ecom_value.val[0] = ECOMMUNITY_ENCODE_AS4;
ecom_value.val[2] = (as >>24) & 0xff;
ecom_value.val[3] = (as >>16) & 0xff;
ecom_value.val[4] = (as >>8) & 0xff;
ecom_value.val[5] = as & 0xff;
}
else
{
ecom_value.val[0] = ECOMMUNITY_ENCODE_AS;
ecom_value.val[2] = (as >>8) & 0xff;
ecom_value.val[3] = as & 0xff;
}
ecom_value.val[6] = (val >> 8) & 0xff;
ecom_value.val[7] = val & 0xff;
if (rtlist == NULL)
rtlist = ecommunity_new();
ecommunity_add_val (rtlist, &ecom_value);
}
}

/*
Expand Down
1 change: 1 addition & 0 deletions bgpd/rfapi/rfapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct rfapi_l2address_option
uint32_t logical_net_id; /* ~= EVPN Ethernet Segment Id,
must not be zero for mac regis. */
uint8_t local_nve_id;
uint16_t tag_id; /* EVPN Ethernet Tag ID, 0 = none */
};

typedef enum
Expand Down
45 changes: 45 additions & 0 deletions bgpd/rfapi/rfapi_import.c
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,49 @@ rfapiEcommunityGetLNI (struct ecommunity *ecom, uint32_t * lni)
return ENOENT;
}

int
rfapiEcommunityGetEthernetTag (struct ecommunity *ecom, uint16_t * tag_id)
{
struct bgp *bgp = bgp_get_default ();
*tag_id = 0; /* default to untagged */
if (ecom)
{
int i;
for (i = 0; i < ecom->size; ++i)
{
as_t as = 0;
int encode = 0;
uint8_t *p = ecom->val + (i * ECOMMUNITY_SIZE);

/* High-order octet of type. */
encode = *p++;

if (*p++ == ECOMMUNITY_ROUTE_TARGET) {
if (encode == ECOMMUNITY_ENCODE_AS4)
{
as = (*p++ << 24);
as |= (*p++ << 16);
as |= (*p++ << 8);
as |= (*p++);
}
else if (encode == ECOMMUNITY_ENCODE_AS)
{
as = (*p++ << 8);
as |= (*p++);
p += 2; /* skip next two, tag/vid always in lowest bytes */
}
if (as == bgp->as)
{
*tag_id = *p++ << 8;
*tag_id |= (*p++);
return 0;
}
}
}
}
return ENOENT;
}

static int
rfapiVpnBiNhEqualsPt (struct bgp_info *bi, struct rfapi_ip_addr *hpt)
{
Expand Down Expand Up @@ -1377,6 +1420,8 @@ rfapiRouteInfo2NextHopEntry (
{
(void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity,
&vo->v.l2addr.logical_net_id);
(void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity,
&vo->v.l2addr.tag_id);
}

/* local_nve_id comes from lower byte of RD type */
Expand Down
3 changes: 3 additions & 0 deletions bgpd/rfapi/rfapi_import.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ extern int rfapiEcommunityGetLNI (
struct ecommunity *ecom,
uint32_t *lni);

extern int rfapiEcommunityGetEthernetTag (
struct ecommunity *ecom,
uint16_t * tag_id);

/* enable for debugging; disable for performance */
#if 0
Expand Down
2 changes: 2 additions & 0 deletions bgpd/rfapi/rfapi_rib.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,8 @@ rfapiRibBi2Ri(
{
(void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity,
&vo->v.l2addr.logical_net_id);
(void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity,
&vo->v.l2addr.tag_id);
}

/* local_nve_id comes from RD */
Expand Down
Loading

0 comments on commit ddf0364

Please sign in to comment.