zebra: Use boolean for certain VxLAN-EVPN flags

Use boolean variables instead of unsigned int for certain VxLAN-EVPN
flags which are really used as boolean.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by:   Anuradha Karuppiah <anuradhak@cumulusnetworks.com>
Reviewed-by:   Chirag Shah <chirag@cumulusnetworks.com>

Ticket: CM-22288
Reviewed By: CCR-7832
Testing Done:
Along with a subsequent, related commit
This commit is contained in:
vivek 2018-09-10 10:13:20 -07:00 committed by Donald Sharp
parent fe697c6be5
commit a37f4598d7
5 changed files with 36 additions and 38 deletions

View File

@ -116,7 +116,7 @@ extern int kernel_del_vtep(vni_t vni, struct interface *ifp,
struct in_addr *vtep_ip); struct in_addr *vtep_ip);
extern int kernel_add_mac(struct interface *ifp, vlanid_t vid, extern int kernel_add_mac(struct interface *ifp, vlanid_t vid,
struct ethaddr *mac, struct in_addr vtep_ip, struct ethaddr *mac, struct in_addr vtep_ip,
uint8_t sticky); bool sticky);
extern int kernel_del_mac(struct interface *ifp, vlanid_t vid, extern int kernel_del_mac(struct interface *ifp, vlanid_t vid,
struct ethaddr *mac, struct in_addr vtep_ip); struct ethaddr *mac, struct in_addr vtep_ip);

View File

@ -1959,7 +1959,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
char buf[ETHER_ADDR_STRLEN]; char buf[ETHER_ADDR_STRLEN];
char vid_buf[20]; char vid_buf[20];
char dst_buf[30]; char dst_buf[30];
uint8_t sticky = 0; bool sticky;
ndm = NLMSG_DATA(h); ndm = NLMSG_DATA(h);
@ -2030,7 +2030,7 @@ static int netlink_macfdb_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
sprintf(dst_buf, " dst %s", inet_ntoa(vtep_ip.u.prefix4)); sprintf(dst_buf, " dst %s", inet_ntoa(vtep_ip.u.prefix4));
} }
sticky = (ndm->ndm_state & NUD_NOARP) ? 1 : 0; sticky = !!(ndm->ndm_state & NUD_NOARP);
if (IS_ZEBRA_DEBUG_KERNEL) if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug("Rx %s family %s IF %s(%u)%s %sMAC %s%s", zlog_debug("Rx %s family %s IF %s(%u)%s %sMAC %s%s",
@ -2178,7 +2178,7 @@ int netlink_macfdb_read_for_bridge(struct zebra_ns *zns, struct interface *ifp,
static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid, static int netlink_macfdb_update(struct interface *ifp, vlanid_t vid,
struct ethaddr *mac, struct in_addr vtep_ip, struct ethaddr *mac, struct in_addr vtep_ip,
int cmd, uint8_t sticky) int cmd, bool sticky)
{ {
struct zebra_ns *zns; struct zebra_ns *zns;
struct { struct {
@ -2264,8 +2264,8 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
char buf[ETHER_ADDR_STRLEN]; char buf[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN];
int mac_present = 0; int mac_present = 0;
uint8_t ext_learned; bool is_ext;
uint8_t router_flag; bool is_router;
ndm = NLMSG_DATA(h); ndm = NLMSG_DATA(h);
@ -2355,8 +2355,8 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETH_ALEN); memcpy(&mac, RTA_DATA(tb[NDA_LLADDR]), ETH_ALEN);
} }
ext_learned = (ndm->ndm_flags & NTF_EXT_LEARNED) ? 1 : 0; is_ext = !!(ndm->ndm_flags & NTF_EXT_LEARNED);
router_flag = (ndm->ndm_flags & NTF_ROUTER) ? 1 : 0; is_router = !!(ndm->ndm_flags & NTF_ROUTER);
if (IS_ZEBRA_DEBUG_KERNEL) if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug( zlog_debug(
@ -2379,7 +2379,7 @@ static int netlink_ipneigh_change(struct nlmsghdr *h, int len, ns_id_t ns_id)
if (ndm->ndm_state & NUD_VALID) if (ndm->ndm_state & NUD_VALID)
return zebra_vxlan_handle_kernel_neigh_update( return zebra_vxlan_handle_kernel_neigh_update(
ifp, link_if, &ip, &mac, ndm->ndm_state, ifp, link_if, &ip, &mac, ndm->ndm_state,
ext_learned, router_flag); is_ext, is_router);
return zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip); return zebra_vxlan_handle_kernel_neigh_del(ifp, link_if, &ip);
} }
@ -2561,7 +2561,7 @@ static int netlink_neigh_update2(struct interface *ifp, struct ipaddr *ip,
} }
int kernel_add_mac(struct interface *ifp, vlanid_t vid, struct ethaddr *mac, int kernel_add_mac(struct interface *ifp, vlanid_t vid, struct ethaddr *mac,
struct in_addr vtep_ip, uint8_t sticky) struct in_addr vtep_ip, bool sticky)
{ {
return netlink_macfdb_update(ifp, vid, mac, vtep_ip, RTM_NEWNEIGH, return netlink_macfdb_update(ifp, vid, mac, vtep_ip, RTM_NEWNEIGH,
sticky); sticky);

View File

@ -453,7 +453,7 @@ int kernel_del_vtep(vni_t vni, struct interface *ifp, struct in_addr *vtep_ip)
} }
int kernel_add_mac(struct interface *ifp, vlanid_t vid, struct ethaddr *mac, int kernel_add_mac(struct interface *ifp, vlanid_t vid, struct ethaddr *mac,
struct in_addr vtep_ip, uint8_t sticky) struct in_addr vtep_ip, bool sticky)
{ {
return 0; return 0;
} }

View File

@ -1963,7 +1963,7 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,
struct interface *ifp, struct interface *ifp,
struct ipaddr *ip, struct ipaddr *ip,
struct ethaddr *macaddr, struct ethaddr *macaddr,
uint8_t router_flag) bool is_router)
{ {
char buf[ETHER_ADDR_STRLEN]; char buf[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN];
@ -2029,7 +2029,7 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,
} else { } else {
if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) { if (CHECK_FLAG(n->flags, ZEBRA_NEIGH_LOCAL)) {
/* If there is no MAC change, BGP isn't interested. */ /* If there is no MAC change, BGP isn't interested. */
if (router_flag != if (is_router !=
(CHECK_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG) (CHECK_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG)
? 1 : 0)) ? 1 : 0))
check_rbit = true; check_rbit = true;
@ -2121,7 +2121,7 @@ static int zvni_local_neigh_update(zebra_vni_t *zvni,
} }
/*Mark Router flag (R-bit) */ /*Mark Router flag (R-bit) */
if (router_flag) if (is_router)
SET_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG); SET_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG);
else else
UNSET_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG); UNSET_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG);
@ -2593,7 +2593,7 @@ static int zvni_mac_install(zebra_vni_t *zvni, zebra_mac_t *mac)
{ {
struct zebra_if *zif; struct zebra_if *zif;
struct zebra_l2info_vxlan *vxl; struct zebra_l2info_vxlan *vxl;
uint8_t sticky; bool sticky;
if (!(mac->flags & ZEBRA_MAC_REMOTE)) if (!(mac->flags & ZEBRA_MAC_REMOTE))
return 0; return 0;
@ -2603,8 +2603,8 @@ static int zvni_mac_install(zebra_vni_t *zvni, zebra_mac_t *mac)
return -1; return -1;
vxl = &zif->l2info.vxl; vxl = &zif->l2info.vxl;
sticky = CHECK_FLAG(mac->flags, sticky = !!CHECK_FLAG(mac->flags,
(ZEBRA_MAC_STICKY | ZEBRA_MAC_REMOTE_DEF_GW)) ? 1 : 0; (ZEBRA_MAC_STICKY | ZEBRA_MAC_REMOTE_DEF_GW));
return kernel_add_mac(zvni->vxlan_if, vxl->access_vlan, &mac->macaddr, return kernel_add_mac(zvni->vxlan_if, vxl->access_vlan, &mac->macaddr,
mac->fwd_info.r_vtep_ip, sticky); mac->fwd_info.r_vtep_ip, sticky);
@ -4058,9 +4058,9 @@ static void process_remote_macip_add(vni_t vni,
struct interface *ifp = NULL; struct interface *ifp = NULL;
struct zebra_if *zif = NULL; struct zebra_if *zif = NULL;
uint32_t tmp_seq; uint32_t tmp_seq;
uint8_t sticky = 0; bool sticky;
uint8_t remote_gw = 0; bool remote_gw;
uint8_t router_flag = 0; bool is_router;
/* Locate VNI hash entry - expected to exist. */ /* Locate VNI hash entry - expected to exist. */
zvni = zvni_lookup(vni); zvni = zvni_lookup(vni);
@ -4098,9 +4098,9 @@ static void process_remote_macip_add(vni_t vni,
zvni_vtep_install(zvni, &vtep_ip); zvni_vtep_install(zvni, &vtep_ip);
} }
sticky = CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY); sticky = !!CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_STICKY);
remote_gw = CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW); remote_gw = !!CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_GW);
router_flag = CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_ROUTER_FLAG); is_router = !!CHECK_FLAG(flags, ZEBRA_MACIP_TYPE_ROUTER_FLAG);
mac = zvni_mac_lookup(zvni, macaddr); mac = zvni_mac_lookup(zvni, macaddr);
@ -4124,9 +4124,8 @@ static void process_remote_macip_add(vni_t vni,
*/ */
if (!mac if (!mac
|| !CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE) || !CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE)
|| (CHECK_FLAG(mac->flags, ZEBRA_MAC_STICKY) ? 1 : 0) != sticky || sticky != !!CHECK_FLAG(mac->flags, ZEBRA_MAC_STICKY)
|| (CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE_DEF_GW) ? 1 : 0) || remote_gw != !!CHECK_FLAG(mac->flags, ZEBRA_MAC_REMOTE_DEF_GW)
!= remote_gw
|| !IPV4_ADDR_SAME(&mac->fwd_info.r_vtep_ip, &vtep_ip) || !IPV4_ADDR_SAME(&mac->fwd_info.r_vtep_ip, &vtep_ip)
|| seq != mac->rem_seq) || seq != mac->rem_seq)
update_mac = 1; update_mac = 1;
@ -4217,10 +4216,9 @@ static void process_remote_macip_add(vni_t vni,
n = zvni_neigh_lookup(zvni, ipaddr); n = zvni_neigh_lookup(zvni, ipaddr);
if (!n if (!n
|| !CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE) || !CHECK_FLAG(n->flags, ZEBRA_NEIGH_REMOTE)
|| is_router != !!CHECK_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG)
|| (memcmp(&n->emac, macaddr, sizeof(*macaddr)) != 0) || (memcmp(&n->emac, macaddr, sizeof(*macaddr)) != 0)
|| !IPV4_ADDR_SAME(&n->r_vtep_ip, &vtep_ip) || !IPV4_ADDR_SAME(&n->r_vtep_ip, &vtep_ip)
|| ((CHECK_FLAG(n->flags, ZEBRA_NEIGH_ROUTER_FLAG) ? 1 : 0)
!= router_flag)
|| seq != n->rem_seq) || seq != n->rem_seq)
update_neigh = 1; update_neigh = 1;
@ -5406,8 +5404,8 @@ int zebra_vxlan_handle_kernel_neigh_update(struct interface *ifp,
struct ipaddr *ip, struct ipaddr *ip,
struct ethaddr *macaddr, struct ethaddr *macaddr,
uint16_t state, uint16_t state,
uint8_t ext_learned, bool is_ext,
uint8_t router_flag) bool is_router)
{ {
char buf[ETHER_ADDR_STRLEN]; char buf[ETHER_ADDR_STRLEN];
char buf2[INET6_ADDRSTRLEN]; char buf2[INET6_ADDRSTRLEN];
@ -5433,14 +5431,14 @@ int zebra_vxlan_handle_kernel_neigh_update(struct interface *ifp,
"Add/Update neighbor %s MAC %s intf %s(%u) state 0x%x %s %s-> L2-VNI %u", "Add/Update neighbor %s MAC %s intf %s(%u) state 0x%x %s %s-> L2-VNI %u",
ipaddr2str(ip, buf2, sizeof(buf2)), ipaddr2str(ip, buf2, sizeof(buf2)),
prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name, prefix_mac2str(macaddr, buf, sizeof(buf)), ifp->name,
ifp->ifindex, state, ext_learned ? "ext-learned " : "", ifp->ifindex, state, is_ext ? "ext-learned " : "",
router_flag ? "router " : "", is_router ? "router " : "",
zvni->vni); zvni->vni);
/* Is this about a local neighbor or a remote one? */ /* Is this about a local neighbor or a remote one? */
if (!ext_learned) if (!is_ext)
return zvni_local_neigh_update(zvni, ifp, ip, macaddr, return zvni_local_neigh_update(zvni, ifp, ip, macaddr,
router_flag); is_router);
return zvni_remote_neigh_update(zvni, ifp, ip, macaddr, state); return zvni_remote_neigh_update(zvni, ifp, ip, macaddr, state);
} }
@ -5753,7 +5751,7 @@ int zebra_vxlan_local_mac_del(struct interface *ifp, struct interface *br_if,
int zebra_vxlan_local_mac_add_update(struct interface *ifp, int zebra_vxlan_local_mac_add_update(struct interface *ifp,
struct interface *br_if, struct interface *br_if,
struct ethaddr *macaddr, vlanid_t vid, struct ethaddr *macaddr, vlanid_t vid,
uint8_t sticky) bool sticky)
{ {
zebra_vni_t *zvni; zebra_vni_t *zvni;
zebra_mac_t *mac; zebra_mac_t *mac;

View File

@ -122,15 +122,15 @@ extern int zebra_vxlan_svi_down(struct interface *ifp,
struct interface *link_if); struct interface *link_if);
extern int zebra_vxlan_handle_kernel_neigh_update( extern int zebra_vxlan_handle_kernel_neigh_update(
struct interface *ifp, struct interface *link_if, struct ipaddr *ip, struct interface *ifp, struct interface *link_if, struct ipaddr *ip,
struct ethaddr *macaddr, uint16_t state, uint8_t ext_learned, struct ethaddr *macaddr, uint16_t state, bool is_ext,
uint8_t router_flag); bool is_router);
extern int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp, extern int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
struct interface *link_if, struct interface *link_if,
struct ipaddr *ip); struct ipaddr *ip);
extern int zebra_vxlan_local_mac_add_update(struct interface *ifp, extern int zebra_vxlan_local_mac_add_update(struct interface *ifp,
struct interface *br_if, struct interface *br_if,
struct ethaddr *mac, vlanid_t vid, struct ethaddr *mac, vlanid_t vid,
uint8_t sticky); bool sticky);
extern int zebra_vxlan_local_mac_del(struct interface *ifp, extern int zebra_vxlan_local_mac_del(struct interface *ifp,
struct interface *br_if, struct interface *br_if,
struct ethaddr *mac, vlanid_t vid); struct ethaddr *mac, vlanid_t vid);