From 19a0211b73f5373f9fe28fed4bdd942e4e1b29ee Mon Sep 17 00:00:00 2001 From: sri-mohan1 Date: Tue, 12 Mar 2024 11:06:35 +0530 Subject: [PATCH] zebra: changes for code maintainability these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 --- zebra/zebra_fpm_netlink.c | 8 ++++---- zebra/zebra_l2.c | 31 ++++++++++++++----------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index 1dd96347f302..95207ce75cb2 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -592,19 +592,19 @@ int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf, RTM_DELNEIGH : RTM_NEWNEIGH; req->hdr.nlmsg_flags = NLM_F_REQUEST; if (req->hdr.nlmsg_type == RTM_NEWNEIGH) - req->hdr.nlmsg_flags |= (NLM_F_CREATE | NLM_F_REPLACE); + SET_FLAG(req->hdr.nlmsg_flags, (NLM_F_CREATE | NLM_F_REPLACE)); /* Construct ndmsg */ req->ndm.ndm_family = AF_BRIDGE; req->ndm.ndm_ifindex = mac->vxlan_if; req->ndm.ndm_state = NUD_REACHABLE; - req->ndm.ndm_flags |= NTF_SELF | NTF_MASTER; + SET_FLAG(req->ndm.ndm_flags, (NTF_SELF | NTF_MASTER)); if (CHECK_FLAG(mac->zebra_flags, (ZEBRA_MAC_STICKY | ZEBRA_MAC_REMOTE_DEF_GW))) - req->ndm.ndm_state |= NUD_NOARP; + SET_FLAG(req->ndm.ndm_state, NUD_NOARP); else - req->ndm.ndm_flags |= NTF_EXT_LEARNED; + SET_FLAG(req->ndm.ndm_flags, NTF_EXT_LEARNED); /* Add attributes */ nl_attr_put(&req->hdr, in_buf_len, NDA_LLADDR, &mac->macaddr, 6); diff --git a/zebra/zebra_l2.c b/zebra/zebra_l2.c index 4f7a1cd4cead..0f591810b926 100644 --- a/zebra/zebra_l2.c +++ b/zebra/zebra_l2.c @@ -111,13 +111,13 @@ static void zebra_l2_bond_lacp_bypass_eval(struct zebra_if *bond_zif) { struct listnode *node; struct zebra_if *bond_mbr; - bool old_bypass = !!(bond_zif->flags & ZIF_FLAG_LACP_BYPASS); + bool old_bypass = !!CHECK_FLAG(bond_zif->flags, ZIF_FLAG_LACP_BYPASS); bool new_bypass = false; if (bond_zif->bond_info.mbr_zifs) { for (ALL_LIST_ELEMENTS_RO(bond_zif->bond_info.mbr_zifs, node, bond_mbr)) { - if (bond_mbr->flags & ZIF_FLAG_LACP_BYPASS) { + if (CHECK_FLAG(bond_mbr->flags, ZIF_FLAG_LACP_BYPASS)) { new_bypass = true; break; } @@ -132,9 +132,9 @@ static void zebra_l2_bond_lacp_bypass_eval(struct zebra_if *bond_zif) bond_zif->ifp->name, new_bypass ? "on" : "off"); if (new_bypass) - bond_zif->flags |= ZIF_FLAG_LACP_BYPASS; + SET_FLAG(bond_zif->flags, ZIF_FLAG_LACP_BYPASS); else - bond_zif->flags &= ~ZIF_FLAG_LACP_BYPASS; + UNSET_FLAG(bond_zif->flags, ZIF_FLAG_LACP_BYPASS); if (bond_zif->es_info.es) zebra_evpn_es_bypass_update(bond_zif->es_info.es, bond_zif->ifp, @@ -174,8 +174,7 @@ void zebra_l2_map_slave_to_bond(struct zebra_if *zif, vrf_id_t vrf_id) } } else { if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) - zlog_debug("bond mbr %s link to bond skipped", - zif->ifp->name); + zlog_debug("bond mbr %s link to bond skipped", zif->ifp->name); } } @@ -186,8 +185,7 @@ void zebra_l2_unmap_slave_from_bond(struct zebra_if *zif) if (!bond_slave->bond_if) { if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) - zlog_debug("bond mbr %s unlink from bond skipped", - zif->ifp->name); + zlog_debug("bond mbr %s unlink from bond skipped", zif->ifp->name); return; } @@ -218,8 +216,7 @@ void zebra_l2if_update_bond(struct interface *ifp, bool add) if (add) { if (!bond->mbr_zifs) { if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) - zlog_debug("bond %s mbr list create", - ifp->name); + zlog_debug("bond %s mbr list create", ifp->name); bond->mbr_zifs = list_new(); } } else { @@ -347,7 +344,7 @@ void zebra_l2_vxlanif_add_update(struct interface *ifp, ctx.old_vtep_ip = zif->l2info.vxl.vtep_ip; if (!IPV4_ADDR_SAME(&ctx.old_vtep_ip, &vxlan_info->vtep_ip)) { - chgflags |= ZEBRA_VXLIF_LOCAL_IP_CHANGE; + SET_FLAG(chgflags, ZEBRA_VXLIF_LOCAL_IP_CHANGE); zif->l2info.vxl.vtep_ip = vxlan_info->vtep_ip; } @@ -355,7 +352,7 @@ void zebra_l2_vxlanif_add_update(struct interface *ifp, ctx.old_vni = vxlan_info->vni_info.vni; if (!IPV4_ADDR_SAME(&zif->l2info.vxl.vni_info.vni.mcast_grp, &vxlan_info->vni_info.vni.mcast_grp)) { - chgflags |= ZEBRA_VXLIF_MCAST_GRP_CHANGE; + SET_FLAG(chgflags, ZEBRA_VXLIF_MCAST_GRP_CHANGE); zif->l2info.vxl.vni_info.vni.mcast_grp = vxlan_info->vni_info.vni.mcast_grp; } @@ -441,11 +438,11 @@ void zebra_l2if_update_bridge_slave(struct interface *ifp, if (zif->zif_type == ZEBRA_IF_VXLAN && chgflags != ZEBRA_BRIDGE_NO_ACTION) { - if (chgflags & ZEBRA_BRIDGE_MASTER_MAC_CHANGE) { + if (CHECK_FLAG(chgflags, ZEBRA_BRIDGE_MASTER_MAC_CHANGE)) { ctx.chgflags = ZEBRA_VXLIF_MASTER_MAC_CHANGE; zebra_vxlan_if_update(ifp, &ctx); } - if (chgflags & ZEBRA_BRIDGE_MASTER_UP) { + if (CHECK_FLAG(chgflags, ZEBRA_BRIDGE_MASTER_UP)) { ctx.chgflags = ZEBRA_VXLIF_MASTER_CHANGE; zebra_vxlan_if_update(ifp, &ctx); } @@ -494,16 +491,16 @@ void zebra_l2if_update_bond_slave(struct interface *ifp, ifindex_t bond_ifindex, zif = ifp->info; assert(zif); - old_bypass = !!(zif->flags & ZIF_FLAG_LACP_BYPASS); + old_bypass = !!CHECK_FLAG(zif->flags, ZIF_FLAG_LACP_BYPASS); if (old_bypass != new_bypass) { if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) zlog_debug("bond-mbr %s lacp bypass changed to %s", zif->ifp->name, new_bypass ? "on" : "off"); if (new_bypass) - zif->flags |= ZIF_FLAG_LACP_BYPASS; + SET_FLAG(zif->flags, ZIF_FLAG_LACP_BYPASS); else - zif->flags &= ~ZIF_FLAG_LACP_BYPASS; + UNSET_FLAG(zif->flags, ZIF_FLAG_LACP_BYPASS); bond_mbr = &zif->bondslave_info; if (bond_mbr->bond_if) {