From ff8b7eb87028c8f52a598794c3f5a360c922bd4f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 3 Aug 2017 08:43:56 -0400 Subject: [PATCH] zebra: Switch to using ETH_ALEN Signed-off-by: Donald Sharp --- zebra/rt_netlink.c | 8 ++++---- zebra/zebra_vxlan.c | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 9b31e467c..cf78a197c 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1704,7 +1704,7 @@ static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h, return 0; } - if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETHER_ADDR_LEN) { + if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) { zlog_warn( "%s family %s IF %s(%u) brIF %u - LLADDR is not MAC, len %ld", nl_msg_type_to_str(h->nlmsg_type), @@ -1714,7 +1714,7 @@ static int netlink_macfdb_change(struct sockaddr_nl *snl, struct nlmsghdr *h, return 0; } - memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETHER_ADDR_LEN); + memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETH_ALEN); if ((NDA_VLAN <= NDA_MAX) && tb[NDA_VLAN]) { vid_present = 1; @@ -2033,7 +2033,7 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h, if (h->nlmsg_type == RTM_NEWNEIGH) { if (tb[NDA_LLADDR]) { - if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETHER_ADDR_LEN) { + if (RTA_PAYLOAD(tb[NDA_LLADDR]) != ETH_ALEN) { zlog_warn( "%s family %s IF %s(%u) - LLADDR is not MAC, len %ld", nl_msg_type_to_str(h->nlmsg_type), @@ -2044,7 +2044,7 @@ static int netlink_ipneigh_change(struct sockaddr_nl *snl, struct nlmsghdr *h, } mac_present = 1; - memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETHER_ADDR_LEN); + memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETH_ALEN); } ext_learned = (ndm->ndm_flags & NTF_EXT_LEARNED) ? 1 : 0; diff --git a/zebra/zebra_vxlan.c b/zebra/zebra_vxlan.c index e89f05374..7d265af30 100644 --- a/zebra/zebra_vxlan.c +++ b/zebra/zebra_vxlan.c @@ -469,7 +469,7 @@ static int zvni_macip_send_msg_to_client(struct zebra_vrf *zvrf, vni_t vni, zserv_create_header(s, cmd, zvrf_id(zvrf)); stream_putl(s, vni); - stream_put(s, macaddr->octet, ETHER_ADDR_LEN); + stream_put(s, macaddr->octet, ETH_ALEN); if (ip) { ipa_len = 0; if (IS_IPADDR_V4(ip)) @@ -778,7 +778,7 @@ static unsigned int mac_hash_keymake(void *p) zebra_mac_t *pmac = p; const void *pnt = (void *)pmac->macaddr.octet; - return jhash(pnt, ETHER_ADDR_LEN, 0xa5a5a55a); + return jhash(pnt, ETH_ALEN, 0xa5a5a55a); } /* @@ -796,7 +796,7 @@ static int mac_cmp(const void *p1, const void *p2) return 0; return (memcmp(pmac1->macaddr.octet, pmac2->macaddr.octet, - ETHER_ADDR_LEN) + ETH_ALEN) == 0); } @@ -823,7 +823,7 @@ static zebra_mac_t *zvni_mac_add(zebra_vni_t *zvni, struct ethaddr *macaddr) zebra_mac_t *mac = NULL; memset(&tmp_mac, 0, sizeof(zebra_mac_t)); - memcpy(&tmp_mac.macaddr, macaddr, ETHER_ADDR_LEN); + memcpy(&tmp_mac.macaddr, macaddr, ETH_ALEN); mac = hash_get(zvni->mac_table, &tmp_mac, zvni_mac_alloc); assert(mac); @@ -931,7 +931,7 @@ static zebra_mac_t *zvni_mac_lookup(zebra_vni_t *zvni, struct ethaddr *mac) zebra_mac_t *pmac; memset(&tmp, 0, sizeof(tmp)); - memcpy(&tmp.macaddr, mac, ETHER_ADDR_LEN); + memcpy(&tmp.macaddr, mac, ETH_ALEN); pmac = hash_lookup(zvni->mac_table, &tmp); return pmac; @@ -1967,7 +1967,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp, if (n) { if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) { if (memcmp(n->emac.octet, macaddr->octet, - ETHER_ADDR_LEN) + ETH_ALEN) == 0) { if (n->ifindex == ifp->ifindex) /* we're not interested in whatever has @@ -2013,7 +2013,7 @@ int zebra_vxlan_local_neigh_add_update(struct interface *ifp, /* Set "local" forwarding info. */ SET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL); - memcpy(&n->emac, macaddr, ETHER_ADDR_LEN); + memcpy(&n->emac, macaddr, ETH_ALEN); n->ifindex = ifp->ifindex; /* Inform BGP if required. */ @@ -2053,14 +2053,14 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, int sock, u_short length, n = NULL; memset(&ip, 0, sizeof(ip)); vni = (vni_t)stream_getl(s); - stream_get(&macaddr.octet, s, ETHER_ADDR_LEN); + stream_get(&macaddr.octet, s, ETH_ALEN); ipa_len = stream_getl(s); if (ipa_len) { ip.ipa_type = (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4 : IPADDR_V6; stream_get(&ip.ip.addr, s, ipa_len); } - l += 4 + ETHER_ADDR_LEN + 4 + ipa_len; + l += 4 + ETH_ALEN + 4 + ipa_len; vtep_ip.s_addr = stream_get_ipv4(s); l += IPV4_MAX_BYTELEN; @@ -2139,7 +2139,7 @@ int zebra_vxlan_remote_macip_del(struct zserv *client, int sock, u_short length, */ if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE) && (memcmp(n->emac.octet, macaddr.octet, - ETHER_ADDR_LEN) + ETH_ALEN) == 0)) { zvni_neigh_uninstall(zvni, n); zvni_neigh_del(zvni, n); @@ -2196,14 +2196,14 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, int sock, u_short length, n = NULL; memset(&ip, 0, sizeof(ip)); vni = (vni_t)stream_getl(s); - stream_get(&macaddr.octet, s, ETHER_ADDR_LEN); + stream_get(&macaddr.octet, s, ETH_ALEN); ipa_len = stream_getl(s); if (ipa_len) { ip.ipa_type = (ipa_len == IPV4_MAX_BYTELEN) ? IPADDR_V4 : IPADDR_V6; stream_get(&ip.ip.addr, s, ipa_len); } - l += 4 + ETHER_ADDR_LEN + 4 + ipa_len; + l += 4 + ETH_ALEN + 4 + ipa_len; vtep_ip.s_addr = stream_get_ipv4(s); l += IPV4_MAX_BYTELEN; @@ -2354,7 +2354,7 @@ int zebra_vxlan_remote_macip_add(struct zserv *client, int sock, u_short length, /* Set "remote" forwarding info. */ UNSET_FLAG(n->flags, ZEBRA_NEIGH_LOCAL); /* TODO: Handle MAC change. */ - memcpy(&n->emac, &macaddr, ETHER_ADDR_LEN); + memcpy(&n->emac, &macaddr, ETH_ALEN); n->r_vtep_ip = vtep_ip; SET_FLAG(n->flags, ZEBRA_NEIGH_REMOTE); -- 2.39.2