zebra: changes for code maintainability

these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
This commit is contained in:
sri-mohan1 2024-03-12 11:06:35 +05:30
parent d0afa12467
commit 19a0211b73
2 changed files with 18 additions and 21 deletions

View File

@ -592,19 +592,19 @@ int zfpm_netlink_encode_mac(struct fpm_mac_info_t *mac, char *in_buf,
RTM_DELNEIGH : RTM_NEWNEIGH; RTM_DELNEIGH : RTM_NEWNEIGH;
req->hdr.nlmsg_flags = NLM_F_REQUEST; req->hdr.nlmsg_flags = NLM_F_REQUEST;
if (req->hdr.nlmsg_type == RTM_NEWNEIGH) 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 */ /* Construct ndmsg */
req->ndm.ndm_family = AF_BRIDGE; req->ndm.ndm_family = AF_BRIDGE;
req->ndm.ndm_ifindex = mac->vxlan_if; req->ndm.ndm_ifindex = mac->vxlan_if;
req->ndm.ndm_state = NUD_REACHABLE; 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, if (CHECK_FLAG(mac->zebra_flags,
(ZEBRA_MAC_STICKY | ZEBRA_MAC_REMOTE_DEF_GW))) (ZEBRA_MAC_STICKY | ZEBRA_MAC_REMOTE_DEF_GW)))
req->ndm.ndm_state |= NUD_NOARP; SET_FLAG(req->ndm.ndm_state, NUD_NOARP);
else else
req->ndm.ndm_flags |= NTF_EXT_LEARNED; SET_FLAG(req->ndm.ndm_flags, NTF_EXT_LEARNED);
/* Add attributes */ /* Add attributes */
nl_attr_put(&req->hdr, in_buf_len, NDA_LLADDR, &mac->macaddr, 6); nl_attr_put(&req->hdr, in_buf_len, NDA_LLADDR, &mac->macaddr, 6);

View File

@ -111,13 +111,13 @@ static void zebra_l2_bond_lacp_bypass_eval(struct zebra_if *bond_zif)
{ {
struct listnode *node; struct listnode *node;
struct zebra_if *bond_mbr; 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; bool new_bypass = false;
if (bond_zif->bond_info.mbr_zifs) { if (bond_zif->bond_info.mbr_zifs) {
for (ALL_LIST_ELEMENTS_RO(bond_zif->bond_info.mbr_zifs, node, for (ALL_LIST_ELEMENTS_RO(bond_zif->bond_info.mbr_zifs, node,
bond_mbr)) { bond_mbr)) {
if (bond_mbr->flags & ZIF_FLAG_LACP_BYPASS) { if (CHECK_FLAG(bond_mbr->flags, ZIF_FLAG_LACP_BYPASS)) {
new_bypass = true; new_bypass = true;
break; 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"); bond_zif->ifp->name, new_bypass ? "on" : "off");
if (new_bypass) if (new_bypass)
bond_zif->flags |= ZIF_FLAG_LACP_BYPASS; SET_FLAG(bond_zif->flags, ZIF_FLAG_LACP_BYPASS);
else else
bond_zif->flags &= ~ZIF_FLAG_LACP_BYPASS; UNSET_FLAG(bond_zif->flags, ZIF_FLAG_LACP_BYPASS);
if (bond_zif->es_info.es) if (bond_zif->es_info.es)
zebra_evpn_es_bypass_update(bond_zif->es_info.es, bond_zif->ifp, 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 { } else {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT)
zlog_debug("bond mbr %s link to bond skipped", zlog_debug("bond mbr %s link to bond skipped", zif->ifp->name);
zif->ifp->name);
} }
} }
@ -186,8 +185,7 @@ void zebra_l2_unmap_slave_from_bond(struct zebra_if *zif)
if (!bond_slave->bond_if) { if (!bond_slave->bond_if) {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT)
zlog_debug("bond mbr %s unlink from bond skipped", zlog_debug("bond mbr %s unlink from bond skipped", zif->ifp->name);
zif->ifp->name);
return; return;
} }
@ -218,8 +216,7 @@ void zebra_l2if_update_bond(struct interface *ifp, bool add)
if (add) { if (add) {
if (!bond->mbr_zifs) { if (!bond->mbr_zifs) {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT)
zlog_debug("bond %s mbr list create", zlog_debug("bond %s mbr list create", ifp->name);
ifp->name);
bond->mbr_zifs = list_new(); bond->mbr_zifs = list_new();
} }
} else { } else {
@ -347,7 +344,7 @@ void zebra_l2_vxlanif_add_update(struct interface *ifp,
ctx.old_vtep_ip = zif->l2info.vxl.vtep_ip; ctx.old_vtep_ip = zif->l2info.vxl.vtep_ip;
if (!IPV4_ADDR_SAME(&ctx.old_vtep_ip, &vxlan_info->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; 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; ctx.old_vni = vxlan_info->vni_info.vni;
if (!IPV4_ADDR_SAME(&zif->l2info.vxl.vni_info.vni.mcast_grp, if (!IPV4_ADDR_SAME(&zif->l2info.vxl.vni_info.vni.mcast_grp,
&vxlan_info->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 = zif->l2info.vxl.vni_info.vni.mcast_grp =
vxlan_info->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 if (zif->zif_type == ZEBRA_IF_VXLAN
&& chgflags != ZEBRA_BRIDGE_NO_ACTION) { && 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; ctx.chgflags = ZEBRA_VXLIF_MASTER_MAC_CHANGE;
zebra_vxlan_if_update(ifp, &ctx); 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; ctx.chgflags = ZEBRA_VXLIF_MASTER_CHANGE;
zebra_vxlan_if_update(ifp, &ctx); 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; zif = ifp->info;
assert(zif); 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 (old_bypass != new_bypass) {
if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT) if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_EVENT)
zlog_debug("bond-mbr %s lacp bypass changed to %s", zlog_debug("bond-mbr %s lacp bypass changed to %s",
zif->ifp->name, new_bypass ? "on" : "off"); zif->ifp->name, new_bypass ? "on" : "off");
if (new_bypass) if (new_bypass)
zif->flags |= ZIF_FLAG_LACP_BYPASS; SET_FLAG(zif->flags, ZIF_FLAG_LACP_BYPASS);
else else
zif->flags &= ~ZIF_FLAG_LACP_BYPASS; UNSET_FLAG(zif->flags, ZIF_FLAG_LACP_BYPASS);
bond_mbr = &zif->bondslave_info; bond_mbr = &zif->bondslave_info;
if (bond_mbr->bond_if) { if (bond_mbr->bond_if) {