summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Worley <sworley@nvidia.com>2022-02-15 18:21:18 -0500
committerStephen Worley <sworley@nvidia.com>2022-03-09 18:02:44 -0500
commit7140b00cb0c0f9e9f007f092890f04166a9a66f8 (patch)
treefe1a6c80ae26474ae22234ce09ef9f8c49ac8a2c
parent26a64ff9ca7b8afdd5ab9b9bc8a59f3ea9dbc53b (diff)
zebra: use SET/UNSET/CHECK/COND in protodown code
Use the SET/UNSET/CHECK/COND macros for flag bifields where appropriate throught the protodown code base. Signed-off-by: Stephen Worley <sworley@nvidia.com>
-rw-r--r--zebra/if_netlink.c26
-rw-r--r--zebra/interface.c27
-rw-r--r--zebra/zebra_evpn_mh.c9
3 files changed, 29 insertions, 33 deletions
diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c
index 0ed03ae750..e21ff533ec 100644
--- a/zebra/if_netlink.c
+++ b/zebra/if_netlink.c
@@ -852,11 +852,10 @@ static void netlink_proc_dplane_if_protodown(struct zebra_if *zif,
* If the reason we got from the kernel is ONLY frr though, don't
* set it.
*/
- if (protodown && rc_bitfield &&
- is_if_protodown_reason_only_frr(rc_bitfield) == false)
- zif->protodown_rc |= ZEBRA_PROTODOWN_EXTERNAL;
- else
- zif->protodown_rc &= ~ZEBRA_PROTODOWN_EXTERNAL;
+ COND_FLAG(zif->protodown_rc, ZEBRA_PROTODOWN_EXTERNAL,
+ protodown && rc_bitfield &&
+ !is_if_protodown_reason_only_frr(rc_bitfield));
+
old_protodown = !!ZEBRA_IF_IS_PROTODOWN(zif);
if (protodown == old_protodown)
@@ -866,17 +865,16 @@ static void netlink_proc_dplane_if_protodown(struct zebra_if *zif,
zlog_debug("interface %s dplane change, protdown %s",
zif->ifp->name, protodown ? "on" : "off");
- if (protodown)
- zif->flags |= ZIF_FLAG_PROTODOWN;
- else
- zif->flags &= ~ZIF_FLAG_PROTODOWN;
+ /* Set protodown, respectively */
+ COND_FLAG(zif->flags, ZIF_FLAG_PROTODOWN, protodown);
if (zebra_evpn_is_es_bond_member(zif->ifp)) {
/* Check it's not already being sent to the dplane first */
- if (protodown && (zif->flags & ZIF_FLAG_SET_PROTODOWN))
+ if (protodown && CHECK_FLAG(zif->flags, ZIF_FLAG_SET_PROTODOWN))
return;
- if (!protodown && (zif->flags & ZIF_FLAG_UNSET_PROTODOWN))
+ if (!protodown
+ && CHECK_FLAG(zif->flags, ZIF_FLAG_UNSET_PROTODOWN))
return;
if (IS_ZEBRA_DEBUG_EVPN_MH_ES || IS_ZEBRA_DEBUG_KERNEL)
@@ -885,9 +883,9 @@ static void netlink_proc_dplane_if_protodown(struct zebra_if *zif,
zif->ifp->name, old_protodown ? "on" : "off");
if (old_protodown)
- zif->flags |= ZIF_FLAG_SET_PROTODOWN;
+ SET_FLAG(zif->flags, ZIF_FLAG_SET_PROTODOWN);
else
- zif->flags |= ZIF_FLAG_UNSET_PROTODOWN;
+ SET_FLAG(zif->flags, ZIF_FLAG_UNSET_PROTODOWN);
dplane_intf_update(zif->ifp);
}
@@ -926,7 +924,7 @@ static void if_sweep_protodown(struct zebra_if *zif)
zif->protodown_rc);
/* Only clear our reason codes, leave external if it was set */
- zif->protodown_rc &= ~ZEBRA_PROTODOWN_ALL;
+ UNSET_FLAG(zif->protodown_rc, ZEBRA_PROTODOWN_ALL);
dplane_intf_update(zif->ifp);
}
diff --git a/zebra/interface.c b/zebra/interface.c
index 10cc665752..69d611e583 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -1246,8 +1246,8 @@ static bool if_ignore_set_protodown(const struct interface *ifp, bool new_down,
/* Current state as we know it */
old_down = !!(ZEBRA_IF_IS_PROTODOWN(zif));
- old_set_down = !!(zif->flags & ZIF_FLAG_SET_PROTODOWN);
- old_unset_down = !!(zif->flags & ZIF_FLAG_UNSET_PROTODOWN);
+ old_set_down = !!CHECK_FLAG(zif->flags, ZIF_FLAG_SET_PROTODOWN);
+ old_unset_down = !!CHECK_FLAG(zif->flags, ZIF_FLAG_UNSET_PROTODOWN);
if (new_protodown_rc == zif->protodown_rc) {
/* Early return if already down & reason bitfield matches */
@@ -1311,9 +1311,9 @@ int zebra_if_update_protodown_rc(struct interface *ifp, bool new_down,
zif->protodown_rc = new_protodown_rc;
if (new_down)
- zif->flags |= ZIF_FLAG_SET_PROTODOWN;
+ SET_FLAG(zif->flags, ZIF_FLAG_SET_PROTODOWN);
else
- zif->flags |= ZIF_FLAG_UNSET_PROTODOWN;
+ SET_FLAG(zif->flags, ZIF_FLAG_UNSET_PROTODOWN);
#ifdef HAVE_NETLINK
dplane_intf_update(ifp);
@@ -1450,15 +1450,12 @@ static void zebra_if_update_ctx(struct zebra_dplane_ctx *ctx,
}
/* Update our info */
- if (down)
- zif->flags |= ZIF_FLAG_PROTODOWN;
- else
- zif->flags &= ~ZIF_FLAG_PROTODOWN;
+ COND_FLAG(zif->flags, ZIF_FLAG_PROTODOWN, down);
done:
/* Clear our dplane flags */
- zif->flags &= ~ZIF_FLAG_SET_PROTODOWN;
- zif->flags &= ~ZIF_FLAG_UNSET_PROTODOWN;
+ UNSET_FLAG(zif->flags, ZIF_FLAG_SET_PROTODOWN);
+ UNSET_FLAG(zif->flags, ZIF_FLAG_UNSET_PROTODOWN);
}
/*
@@ -1859,19 +1856,19 @@ const char *zebra_protodown_rc_str(uint32_t protodown_rc, char *pd_buf,
strlcat(pd_buf, "(", pd_buf_len);
- if (protodown_rc & ZEBRA_PROTODOWN_EXTERNAL)
+ if (CHECK_FLAG(protodown_rc, ZEBRA_PROTODOWN_EXTERNAL))
strlcat(pd_buf, "external,", pd_buf_len);
- if (protodown_rc & ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY)
+ if (CHECK_FLAG(protodown_rc, ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY))
strlcat(pd_buf, "startup-delay,", pd_buf_len);
- if (protodown_rc & ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN)
+ if (CHECK_FLAG(protodown_rc, ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN))
strlcat(pd_buf, "uplinks-down,", pd_buf_len);
- if (protodown_rc & ZEBRA_PROTODOWN_VRRP)
+ if (CHECK_FLAG(protodown_rc, ZEBRA_PROTODOWN_VRRP))
strlcat(pd_buf, "vrrp,", pd_buf_len);
- if (protodown_rc & ZEBRA_PROTODOWN_SHARP)
+ if (CHECK_FLAG(protodown_rc, ZEBRA_PROTODOWN_SHARP))
strlcat(pd_buf, "sharp,", pd_buf_len);
len = strnlen(pd_buf, pd_buf_len);
diff --git a/zebra/zebra_evpn_mh.c b/zebra/zebra_evpn_mh.c
index 45eb51ae14..43eef69be2 100644
--- a/zebra/zebra_evpn_mh.c
+++ b/zebra/zebra_evpn_mh.c
@@ -3463,13 +3463,14 @@ void zebra_evpn_mh_json(json_object *json)
if (zmh_info->protodown_rc) {
json_array = json_object_new_array();
- if (zmh_info->protodown_rc & ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY)
+ if (CHECK_FLAG(zmh_info->protodown_rc,
+ ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY))
json_object_array_add(
json_array,
json_object_new_string("startupDelay"));
- if (zmh_info->protodown_rc & ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN)
- json_object_array_add(
- json_array,
+ if (CHECK_FLAG(zmh_info->protodown_rc,
+ ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN))
+ json_object_array_add(json_array,
json_object_new_string("uplinkDown"));
json_object_object_add(json, "protodownReasons", json_array);
}