Skip to content

Commit

Permalink
bgpd: changes for code maintainability
Browse files Browse the repository at this point in the history
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <[email protected]>
  • Loading branch information
sri-mohan1 committed Oct 9, 2024
1 parent 47cdfbd commit c32cc12
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions bgpd/bgp_mplsvpn_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,8 +1411,8 @@ static struct bgp_path_info *bgpL3vpnRte_lookup(struct variable *v, oid name[],
break;
}
prefix.prefixlen = (uint8_t)name[i++];
*policy |= name[i++] << 8;
*policy |= name[i++];
SET_FLAG(*policy, name[i++] << 8);
SET_FLAG(*policy, name[i++]);
nexthop_type = name[i++];
switch (nexthop_type) {
case INETADDRESSTYPEUNKNOWN:
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_nexthop.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
tmp_addr.p.prefixlen = p->prefixlen;
} else {
/* Here we need to find out which nexthop to be used*/
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP))) {
tmp_addr.p.u.prefix4 = attr->nexthop;
tmp_addr.p.prefixlen = IPV4_MAX_BITLEN;
} else if ((attr->mp_nexthop_len)
Expand Down Expand Up @@ -564,7 +564,7 @@ bool bgp_nexthop_self(struct bgp *bgp, afi_t afi, uint8_t type,
memset(&tmp_tip, 0, sizeof(tmp_tip));
tmp_tip.addr = attr->nexthop;

if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP)) {
if (CHECK_FLAG(attr->flag, ATTR_FLAG_BIT(BGP_ATTR_NEXT_HOP))) {
tmp_tip.addr = attr->nexthop;
} else if ((attr->mp_nexthop_len) &&
((attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4)
Expand Down
16 changes: 8 additions & 8 deletions bgpd/bgp_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2938,10 +2938,10 @@ static int bgp_route_refresh_receive(struct peer_connection *connection,
zlog_debug(
"%pBP rcvd %s %s seq %u %s/%d ge %d le %d%s",
peer,
(common & ORF_COMMON_PART_REMOVE
(CHECK_FLAG(common, ORF_COMMON_PART_REMOVE)
? "Remove"
: "Add"),
(common & ORF_COMMON_PART_DENY
(CHECK_FLAG(common, ORF_COMMON_PART_DENY)
? "deny"
: "permit"),
orfp.seq,
Expand All @@ -2958,10 +2958,10 @@ static int bgp_route_refresh_receive(struct peer_connection *connection,
if (ok)
ret = prefix_bgp_orf_set(
name, afi, &orfp,
(common & ORF_COMMON_PART_DENY
(CHECK_FLAG(common, ORF_COMMON_PART_DENY)
? 0
: 1),
(common & ORF_COMMON_PART_REMOVE
(CHECK_FLAG(common, ORF_COMMON_PART_REMOVE)
? 0
: 1));

Expand Down Expand Up @@ -3195,10 +3195,10 @@ static void bgp_dynamic_capability_addpath(uint8_t *pnt, int action,
NULL),
iana_afi2str(pkt_afi),
iana_safi2str(pkt_safi),
(bac.flags & BGP_ADDPATH_RX)
CHECK_FLAG(bac.flags, BGP_ADDPATH_RX)
? ", receive"
: "",
(bac.flags & BGP_ADDPATH_TX)
CHECK_FLAG(bac.flags, BGP_ADDPATH_TX)
? ", transmit"
: "");

Expand Down Expand Up @@ -3578,8 +3578,8 @@ static void bgp_dynamic_capability_llgr(uint8_t *pnt, int action,
uint8_t *stale_time_ptr = data + 4;

stale_time = stale_time_ptr[0] << 16;
stale_time |= stale_time_ptr[1] << 8;
stale_time |= stale_time_ptr[2];
SET_FLAG(stale_time, stale_time_ptr[1] << 8);
SET_FLAG(stale_time, stale_time_ptr[2]);

if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi,
&safi)) {
Expand Down

0 comments on commit c32cc12

Please sign in to comment.