From 67d072055f2a7395158ced26882c1e6feccb4756 Mon Sep 17 00:00:00 2001 From: sri-mohan1 Date: Sat, 19 Oct 2024 14:53:05 +0530 Subject: [PATCH] bgpd: changes for code maintainability these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 --- bgpd/bgp_routemap.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 8dd48575e509..10428797a313 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -480,7 +480,7 @@ route_match_script(void *rule, const struct prefix *prefix, void *object) path->attr->med = newattr.med; - if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)) + if (CHECK_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF))) locpref = path->attr->local_pref; if (locpref != newattr.local_pref) { SET_FLAG(path->attr->flag, @@ -713,15 +713,15 @@ route_match_prefix_list_flowspec(afi_t afi, struct prefix_list *plist, afi); if (ret < 0) return RMAP_NOMATCH; - if (api.match_bitmask & PREFIX_DST_PRESENT || - api.match_bitmask_iprule & PREFIX_DST_PRESENT) { + if (CHECK_FLAG(api.match_bitmask, PREFIX_DST_PRESENT) || + CHECK_FLAG(api.match_bitmask_iprule, PREFIX_DST_PRESENT)) { if (family2afi((&api.dst_prefix)->family) != afi) return RMAP_NOMATCH; return prefix_list_apply(plist, &api.dst_prefix) == PREFIX_DENY ? RMAP_NOMATCH : RMAP_MATCH; - } else if (api.match_bitmask & PREFIX_SRC_PRESENT || - api.match_bitmask_iprule & PREFIX_SRC_PRESENT) { + } else if (CHECK_FLAG(api.match_bitmask, PREFIX_SRC_PRESENT) || + CHECK_FLAG(api.match_bitmask_iprule, PREFIX_SRC_PRESENT)) { if (family2afi((&api.src_prefix)->family) != afi) return RMAP_NOMATCH; return (prefix_list_apply(plist, &api.src_prefix) == PREFIX_DENY @@ -2071,7 +2071,7 @@ route_set_ip_nexthop(void *rule, const struct prefix *prefix, void *object) sockunion_family(peer->su_remote) == AF_INET) { path->attr->nexthop.s_addr = sockunion2ip(peer->su_remote); - path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP); + SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)); } else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) { /* The next hop value will be set as part of * packet rewrite. Set the flags here to indicate @@ -2084,7 +2084,7 @@ route_set_ip_nexthop(void *rule, const struct prefix *prefix, void *object) } } else { /* Set next hop value. */ - path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP); + SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)); path->attr->nexthop = *rins->address; SET_FLAG(path->attr->rmap_change_flags, BATTR_RMAP_IPV4_NHOP_CHANGED); @@ -2218,7 +2218,7 @@ route_set_local_pref(void *rule, const struct prefix *prefix, void *object) if (path->attr->local_pref) locpref = path->attr->local_pref; - path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF); + SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_LOCAL_PREF)); path->attr->local_pref = route_value_adjust(rv, locpref, path); return RMAP_OKAY; @@ -2293,7 +2293,7 @@ route_set_metric(void *rule, const struct prefix *prefix, void *object) rv = rule; path = object; - if (path->attr->flag & ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC)) + if (CHECK_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_MULTI_EXIT_DISC))) med = path->attr->med; bgp_attr_set_med(path->attr, route_value_adjust(rv, med, path)); @@ -3493,7 +3493,7 @@ route_set_atomic_aggregate(void *rule, const struct prefix *pfx, void *object) struct bgp_path_info *path; path = object; - path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE); + SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ATOMIC_AGGREGATE)); return RMAP_OKAY; } @@ -3571,7 +3571,7 @@ route_set_aggregator_as(void *rule, const struct prefix *prefix, void *object) path->attr->aggregator_as = aggregator->as; path->attr->aggregator_addr = aggregator->address; - path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR); + SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_AGGREGATOR)); return RMAP_OKAY; } @@ -3651,7 +3651,7 @@ route_set_label_index(void *rule, const struct prefix *prefix, void *object) label_index = rv->value; if (label_index) { path->attr->label_index = label_index; - path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID); + SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID)); } return RMAP_OKAY; @@ -4318,7 +4318,7 @@ route_set_originator_id(void *rule, const struct prefix *prefix, void *object) address = rule; path = object; - path->attr->flag |= ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID); + SET_FLAG(path->attr->flag, ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)); path->attr->originator_id = *address; return RMAP_OKAY;