]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: changes for code maintainability
authorsri-mohan1 <sri.mohan@samsung.com>
Wed, 9 Oct 2024 08:49:55 +0000 (14:19 +0530)
committersri-mohan1 <sri.mohan@samsung.com>
Thu, 10 Oct 2024 17:53:20 +0000 (23:23 +0530)
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
bgpd/bgp_nexthop.c
bgpd/bgp_packet.c

index 98eb9565bf20f8ad87b39bd9853da9c4eaf7f09a..564ad118ebc3861ed7806973ba7a786ad3ca67d1 100644 (file)
@@ -528,14 +528,12 @@ 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)
-                                  && ((attr->mp_nexthop_len
-                                       == BGP_ATTR_NHLEN_IPV4)
-                                      || (attr->mp_nexthop_len
-                                          == BGP_ATTR_NHLEN_VPNV4))) {
+                       } else if ((attr->mp_nexthop_len) &&
+                                  ((attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) ||
+                                   (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV4))) {
                                tmp_addr.p.u.prefix4 =
                                        attr->mp_nexthop_global_in;
                                tmp_addr.p.prefixlen = IPV4_MAX_BITLEN;
@@ -564,11 +562,11 @@ 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)
-                           || (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV4))) {
+                          ((attr->mp_nexthop_len == BGP_ATTR_NHLEN_IPV4) ||
+                           (attr->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV4))) {
                        tmp_tip.addr = attr->mp_nexthop_global_in;
                }
 
index 62be7ffbf73344b901d22a785e1d77079a7f0195..646ab1d95f62fb49a2e7304478d356d0ed873186 100644 (file)
@@ -2935,35 +2935,31 @@ static int bgp_route_refresh_receive(struct peer_connection *connection,
                                        if (bgp_debug_neighbor_events(peer)) {
                                                char buf[INET6_BUFSIZ];
 
-                                               zlog_debug(
-                                                       "%pBP rcvd %s %s seq %u %s/%d ge %d le %d%s",
-                                                       peer,
-                                                       (common & ORF_COMMON_PART_REMOVE
-                                                                ? "Remove"
-                                                                : "Add"),
-                                                       (common & ORF_COMMON_PART_DENY
-                                                                ? "deny"
-                                                                : "permit"),
-                                                       orfp.seq,
-                                                       inet_ntop(
-                                                               orfp.p.family,
-                                                               &orfp.p.u.prefix,
-                                                               buf,
-                                                               INET6_BUFSIZ),
-                                                       orfp.p.prefixlen,
-                                                       orfp.ge, orfp.le,
-                                                       ok ? "" : " MALFORMED");
+                                               zlog_debug("%pBP rcvd %s %s seq %u %s/%d ge %d le %d%s",
+                                                          peer,
+                                                          (CHECK_FLAG(common, ORF_COMMON_PART_REMOVE)
+                                                                   ? "Remove"
+                                                                   : "Add"),
+                                                          (CHECK_FLAG(common, ORF_COMMON_PART_DENY)
+                                                                   ? "deny"
+                                                                   : "permit"),
+                                                          orfp.seq,
+                                                          inet_ntop(orfp.p.family, &orfp.p.u.prefix,
+                                                                    buf, INET6_BUFSIZ),
+                                                          orfp.p.prefixlen, orfp.ge, orfp.le,
+                                                          ok ? "" : " MALFORMED");
                                        }
 
                                        if (ok)
-                                               ret = prefix_bgp_orf_set(
-                                                       name, afi, &orfp,
-                                                       (common & ORF_COMMON_PART_DENY
-                                                                ? 0
-                                                                : 1),
-                                                       (common & ORF_COMMON_PART_REMOVE
-                                                                ? 0
-                                                                : 1));
+                                               ret = prefix_bgp_orf_set(name, afi, &orfp,
+                                                                        (CHECK_FLAG(common,
+                                                                                    ORF_COMMON_PART_DENY)
+                                                                                 ? 0
+                                                                                 : 1),
+                                                                        (CHECK_FLAG(common,
+                                                                                    ORF_COMMON_PART_REMOVE)
+                                                                                 ? 0
+                                                                                 : 1));
 
                                        if (!ok || (ok && ret != CMD_SUCCESS)) {
                                                zlog_info(
@@ -3190,17 +3186,11 @@ static void bgp_dynamic_capability_addpath(uint8_t *pnt, int action,
 
                        if (bgp_debug_neighbor_events(peer))
                                zlog_debug("%s OPEN has %s capability for afi/safi: %s/%s%s%s",
-                                          peer->host,
-                                          lookup_msg(capcode_str, hdr->code,
-                                                     NULL),
-                                          iana_afi2str(pkt_afi),
-                                          iana_safi2str(pkt_safi),
-                                          (bac.flags & BGP_ADDPATH_RX)
-                                                  ? ", receive"
-                                                  : "",
-                                          (bac.flags & BGP_ADDPATH_TX)
-                                                  ? ", transmit"
-                                                  : "");
+                                          peer->host, lookup_msg(capcode_str, hdr->code, NULL),
+                                          iana_afi2str(pkt_afi), iana_safi2str(pkt_safi),
+                                          CHECK_FLAG(bac.flags, BGP_ADDPATH_RX) ? ", receive" : "",
+                                          CHECK_FLAG(bac.flags, BGP_ADDPATH_TX) ? ", transmit"
+                                                                                : "");
 
                        if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi,
                                                      &safi)) {