bgpd: Convert to using ETH_ALEN

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-08-03 08:45:27 -04:00
parent 9bff805755
commit 28328ea953
11 changed files with 21 additions and 21 deletions

View File

@ -42,7 +42,7 @@ void bgp_add_routermac_ecom(struct attr *attr, struct ethaddr *routermac)
memset(&routermac_ecom, 0, sizeof(struct ecommunity_val)); memset(&routermac_ecom, 0, sizeof(struct ecommunity_val));
routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN; routermac_ecom.val[0] = ECOMMUNITY_ENCODE_EVPN;
routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC; routermac_ecom.val[1] = ECOMMUNITY_EVPN_SUBTYPE_ROUTERMAC;
memcpy(&routermac_ecom.val[2], routermac->octet, ETHER_ADDR_LEN); memcpy(&routermac_ecom.val[2], routermac->octet, ETH_ALEN);
if (!attr->ecommunity) if (!attr->ecommunity)
attr->ecommunity = ecommunity_new(); attr->ecommunity = ecommunity_new();
ecommunity_add_val(attr->ecommunity, &routermac_ecom); ecommunity_add_val(attr->ecommunity, &routermac_ecom);

View File

@ -351,7 +351,7 @@ static int bgp_zebra_send_remote_macip(struct bgp *bgp, struct bgpevpn *vpn,
s, add ? ZEBRA_REMOTE_MACIP_ADD : ZEBRA_REMOTE_MACIP_DEL, s, add ? ZEBRA_REMOTE_MACIP_ADD : ZEBRA_REMOTE_MACIP_DEL,
bgp->vrf_id); bgp->vrf_id);
stream_putl(s, vpn->vni); stream_putl(s, vpn->vni);
stream_put(s, &p->prefix.mac.octet, ETHER_ADDR_LEN); /* Mac Addr */ stream_put(s, &p->prefix.mac.octet, ETH_ALEN); /* Mac Addr */
/* IP address length and IP address, if any. */ /* IP address length and IP address, if any. */
if (IS_EVPN_PREFIX_IPADDR_NONE(p)) if (IS_EVPN_PREFIX_IPADDR_NONE(p))
stream_putl(s, 0); stream_putl(s, 0);
@ -1812,9 +1812,9 @@ static int process_type2_route(struct peer *peer, afi_t afi, safi_t safi,
macaddr_len = *pfx++; macaddr_len = *pfx++;
/* Get the MAC Addr */ /* Get the MAC Addr */
if (macaddr_len == (ETHER_ADDR_LEN * 8)) { if (macaddr_len == (ETH_ALEN * 8)) {
memcpy(&p.prefix.mac.octet, pfx, ETHER_ADDR_LEN); memcpy(&p.prefix.mac.octet, pfx, ETH_ALEN);
pfx += ETHER_ADDR_LEN; pfx += ETH_ALEN;
} else { } else {
zlog_err( zlog_err(
"%u:%s - Rx EVPN Type-2 NLRI with unsupported MAC address length %d", "%u:%s - Rx EVPN Type-2 NLRI with unsupported MAC address length %d",
@ -2186,7 +2186,7 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len)
} else if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) { } else if (p->prefix.route_type == BGP_EVPN_MAC_IP_ROUTE) {
if (IS_EVPN_PREFIX_IPADDR_NONE(p)) if (IS_EVPN_PREFIX_IPADDR_NONE(p))
snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]", snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]",
p->prefix.route_type, 8 * ETHER_ADDR_LEN, p->prefix.route_type, 8 * ETH_ALEN,
prefix_mac2str(&p->prefix.mac, buf1, prefix_mac2str(&p->prefix.mac, buf1,
sizeof(buf1))); sizeof(buf1)));
else { else {
@ -2195,7 +2195,7 @@ char *bgp_evpn_route2str(struct prefix_evpn *p, char *buf, int len)
family = IS_EVPN_PREFIX_IPADDR_V4(p) ? AF_INET family = IS_EVPN_PREFIX_IPADDR_V4(p) ? AF_INET
: AF_INET6; : AF_INET6;
snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]:[%d]:[%s]", snprintf(buf, len, "[%d]:[0]:[0]:[%d]:[%s]:[%d]:[%s]",
p->prefix.route_type, 8 * ETHER_ADDR_LEN, p->prefix.route_type, 8 * ETH_ALEN,
prefix_mac2str(&p->prefix.mac, buf1, prefix_mac2str(&p->prefix.mac, buf1,
sizeof(buf1)), sizeof(buf1)),
family == AF_INET ? IPV4_MAX_BITLEN family == AF_INET ? IPV4_MAX_BITLEN
@ -2237,7 +2237,7 @@ void bgp_evpn_encode_prefix(struct stream *s, struct prefix *p,
stream_put(s, prd->val, 8); /* RD */ stream_put(s, prd->val, 8); /* RD */
stream_put(s, 0, 10); /* ESI */ stream_put(s, 0, 10); /* ESI */
stream_putl(s, 0); /* Ethernet Tag ID */ stream_putl(s, 0); /* Ethernet Tag ID */
stream_putc(s, 8 * ETHER_ADDR_LEN); /* Mac Addr Len - bits */ stream_putc(s, 8 * ETH_ALEN); /* Mac Addr Len - bits */
stream_put(s, evp->prefix.mac.octet, 6); /* Mac Addr */ stream_put(s, evp->prefix.mac.octet, 6); /* Mac Addr */
stream_putc(s, 8 * ipa_len); /* IP address Length */ stream_putc(s, 8 * ipa_len); /* IP address Length */
if (ipa_len) if (ipa_len)

View File

@ -174,7 +174,7 @@ static inline void build_evpn_type2_prefix(struct prefix_evpn *p,
p->family = AF_ETHERNET; p->family = AF_ETHERNET;
p->prefixlen = EVPN_TYPE_2_ROUTE_PREFIXLEN; p->prefixlen = EVPN_TYPE_2_ROUTE_PREFIXLEN;
p->prefix.route_type = BGP_EVPN_MAC_IP_ROUTE; p->prefix.route_type = BGP_EVPN_MAC_IP_ROUTE;
memcpy(&p->prefix.mac.octet, mac->octet, ETHER_ADDR_LEN); memcpy(&p->prefix.mac.octet, mac->octet, ETH_ALEN);
p->prefix.ip.ipa_type = IPADDR_NONE; p->prefix.ip.ipa_type = IPADDR_NONE;
if (ip) if (ip)
memcpy(&p->prefix.ip, ip, sizeof(*ip)); memcpy(&p->prefix.ip, ip, sizeof(*ip));

View File

@ -98,7 +98,7 @@ void decode_rd_vnc_eth(u_char *pnt, struct rd_vnc_eth *rd_vnc_eth)
{ {
rd_vnc_eth->type = RD_TYPE_VNC_ETH; rd_vnc_eth->type = RD_TYPE_VNC_ETH;
rd_vnc_eth->local_nve_id = pnt[1]; rd_vnc_eth->local_nve_id = pnt[1];
memcpy(rd_vnc_eth->macaddr.octet, pnt + 2, ETHER_ADDR_LEN); memcpy(rd_vnc_eth->macaddr.octet, pnt + 2, ETH_ALEN);
} }
#endif #endif

View File

@ -4775,7 +4775,7 @@ int bgp_static_set_safi(afi_t afi, safi_t safi, struct vty *vty,
} }
if (routermac) { if (routermac) {
bgp_static->router_mac = bgp_static->router_mac =
XCALLOC(MTYPE_ATTR, ETHER_ADDR_LEN + 1); XCALLOC(MTYPE_ATTR, ETH_ALEN + 1);
prefix_str2mac(routermac, prefix_str2mac(routermac,
bgp_static->router_mac); bgp_static->router_mac);
} }

View File

@ -2125,7 +2125,7 @@ static int bgp_zebra_process_local_macip(int command, struct zclient *zclient,
memset(&ip, 0, sizeof(ip)); memset(&ip, 0, sizeof(ip));
s = zclient->ibuf; s = zclient->ibuf;
vni = stream_getl(s); vni = stream_getl(s);
stream_get(&mac.octet, s, ETHER_ADDR_LEN); stream_get(&mac.octet, s, ETH_ALEN);
ipa_len = stream_getl(s); ipa_len = stream_getl(s);
if (ipa_len != 0 && ipa_len != IPV4_MAX_BYTELEN if (ipa_len != 0 && ipa_len != IPV4_MAX_BYTELEN
&& ipa_len != IPV6_MAX_BYTELEN) { && ipa_len != IPV6_MAX_BYTELEN) {

View File

@ -1568,7 +1568,7 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
if (l2o) { if (l2o) {
if (!memcmp(l2o->macaddr.octet, rfapi_ethaddr0.octet, if (!memcmp(l2o->macaddr.octet, rfapi_ethaddr0.octet,
ETHER_ADDR_LEN)) { ETH_ALEN)) {
eth_is_0 = 1; eth_is_0 = 1;
} }
/* per t/c Paul/Lou 151022 */ /* per t/c Paul/Lou 151022 */
@ -3416,7 +3416,7 @@ DEFUN (debug_rfapi_query_vn_un_l2o,
/* construct option chain */ /* construct option chain */
memset(valbuf, 0, sizeof(valbuf)); memset(valbuf, 0, sizeof(valbuf));
memcpy(valbuf, &l2o_buf.macaddr.octet, ETHER_ADDR_LEN); memcpy(valbuf, &l2o_buf.macaddr.octet, ETH_ALEN);
valbuf[11] = (l2o_buf.logical_net_id >> 16) & 0xff; valbuf[11] = (l2o_buf.logical_net_id >> 16) & 0xff;
valbuf[12] = (l2o_buf.logical_net_id >> 8) & 0xff; valbuf[12] = (l2o_buf.logical_net_id >> 8) & 0xff;
valbuf[13] = l2o_buf.logical_net_id & 0xff; valbuf[13] = l2o_buf.logical_net_id & 0xff;

View File

@ -308,7 +308,7 @@ int rfapiGetL2o(struct attr *attr, struct rfapi_l2address_option *l2o)
if (pEncap->value[1] == 14) { if (pEncap->value[1] == 14) {
memcpy(l2o->macaddr.octet, memcpy(l2o->macaddr.octet,
pEncap->value + 2, pEncap->value + 2,
ETHER_ADDR_LEN); ETH_ALEN);
l2o->label = l2o->label =
((pEncap->value[10] ((pEncap->value[10]
>> 4) >> 4)
@ -1327,7 +1327,7 @@ rfapiRouteInfo2NextHopEntry(struct rfapi_ip_prefix *rprefix,
vo->type = RFAPI_VN_OPTION_TYPE_L2ADDR; vo->type = RFAPI_VN_OPTION_TYPE_L2ADDR;
memcpy(&vo->v.l2addr.macaddr, &rn->p.u.prefix_eth.octet, memcpy(&vo->v.l2addr.macaddr, &rn->p.u.prefix_eth.octet,
ETHER_ADDR_LEN); ETH_ALEN);
/* only low 3 bytes of this are significant */ /* only low 3 bytes of this are significant */
if (bi->attr) { if (bi->attr) {
(void)rfapiEcommunityGetLNI( (void)rfapiEcommunityGetLNI(

View File

@ -805,7 +805,7 @@ void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, struct prefix *p)
(void **)&mon_eth, &cursor)) { (void **)&mon_eth, &cursor)) {
if (!memcmp(mon_eth->macaddr.octet, if (!memcmp(mon_eth->macaddr.octet,
p->u.prefix_eth.octet, ETHER_ADDR_LEN)) { p->u.prefix_eth.octet, ETH_ALEN)) {
rfapiMonitorEthTimerRestart(mon_eth); rfapiMonitorEthTimerRestart(mon_eth);
} }
@ -1117,7 +1117,7 @@ static int mon_eth_cmp(void *a, void *b)
/* /*
* compare ethernet addresses * compare ethernet addresses
*/ */
for (i = 0; i < ETHER_ADDR_LEN; ++i) { for (i = 0; i < ETH_ALEN; ++i) {
if (m1->macaddr.octet[i] != m2->macaddr.octet[i]) if (m1->macaddr.octet[i] != m2->macaddr.octet[i])
return (m1->macaddr.octet[i] - m2->macaddr.octet[i]); return (m1->macaddr.octet[i] - m2->macaddr.octet[i]);
} }

View File

@ -687,7 +687,7 @@ static void rfapiRibBi2Ri(struct bgp_info *bi, struct rfapi_info *ri,
/* copy from RD already stored in bi, so we don't need it_node /* copy from RD already stored in bi, so we don't need it_node
*/ */
memcpy(&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val + 2, memcpy(&vo->v.l2addr.macaddr, bi->extra->vnc.import.rd.val + 2,
ETHER_ADDR_LEN); ETH_ALEN);
if (bi->attr) { if (bi->attr) {
(void)rfapiEcommunityGetLNI( (void)rfapiEcommunityGetLNI(

View File

@ -3092,7 +3092,7 @@ static int rfapiDeleteLocalPrefixesByRFD(struct rfapi_local_reg_delete_arg *cda,
if (memcmp(cda->l2o.o.macaddr.octet, if (memcmp(cda->l2o.o.macaddr.octet,
adb->u.s.prefix_eth.u adb->u.s.prefix_eth.u
.prefix_eth.octet, .prefix_eth.octet,
ETHER_ADDR_LEN)) { ETH_ALEN)) {
#if DEBUG_L2_EXTRA #if DEBUG_L2_EXTRA
vnc_zlog_debug_verbose( vnc_zlog_debug_verbose(
"%s: adb=%p, macaddr doesn't match, skipping", "%s: adb=%p, macaddr doesn't match, skipping",
@ -3211,7 +3211,7 @@ static int rfapiDeleteLocalPrefixesByRFD(struct rfapi_local_reg_delete_arg *cda,
adb->u.s.prefix_eth.u adb->u.s.prefix_eth.u
.prefix_eth .prefix_eth
.octet, .octet,
ETHER_ADDR_LEN)) { ETH_ALEN)) {
continue; continue;
} }