]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: The large community size is easier to read if its using the constant
authorNigel Kukard <nkukard@lbsd.net>
Wed, 30 Aug 2017 05:40:54 +0000 (05:40 +0000)
committerNigel Kukard <nkukard@lbsd.net>
Thu, 31 Aug 2017 23:39:53 +0000 (23:39 +0000)
Signed-off-by: Nigel Kukard <nkukard@lbsd.net>
bgpd/bgp_attr.c
bgpd/bgp_lcommunity.c

index b03b408f7d63bc89cf2a16fc4a4e639af6d3ba1a..da5d1e8d9c7da214ce8ed6ec4e7fe7d86d77a8b7 100644 (file)
@@ -3058,20 +3058,20 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
        if (CHECK_FLAG(peer->af_flags[afi][safi],
                       PEER_FLAG_SEND_LARGE_COMMUNITY)
            && (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) {
-               if (attr->lcommunity->size * 12 > 255) {
+               if (attr->lcommunity->size * LCOMMUNITY_SIZE > 255) {
                        stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
                                               | BGP_ATTR_FLAG_TRANS
                                               | BGP_ATTR_FLAG_EXTLEN);
                        stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
-                       stream_putw(s, attr->lcommunity->size * 12);
+                       stream_putw(s, attr->lcommunity->size * LCOMMUNITY_SIZE);
                } else {
                        stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
                                               | BGP_ATTR_FLAG_TRANS);
                        stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
-                       stream_putc(s, attr->lcommunity->size * 12);
+                       stream_putc(s, attr->lcommunity->size * LCOMMUNITY_SIZE);
                }
                stream_put(s, attr->lcommunity->val,
-                          attr->lcommunity->size * 12);
+                          attr->lcommunity->size * LCOMMUNITY_SIZE);
        }
 
        /* Route Reflector. */
@@ -3422,21 +3422,21 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
 
        /* Large Community attribute. */
        if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES)) {
-               if (attr->lcommunity->size * 12 > 255) {
+               if (attr->lcommunity->size * LCOMMUNITY_SIZE > 255) {
                        stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
                                               | BGP_ATTR_FLAG_TRANS
                                               | BGP_ATTR_FLAG_EXTLEN);
                        stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
-                       stream_putw(s, attr->lcommunity->size * 12);
+                       stream_putw(s, attr->lcommunity->size * LCOMMUNITY_SIZE);
                } else {
                        stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
                                               | BGP_ATTR_FLAG_TRANS);
                        stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
-                       stream_putc(s, attr->lcommunity->size * 12);
+                       stream_putc(s, attr->lcommunity->size * LCOMMUNITY_SIZE);
                }
 
                stream_put(s, attr->lcommunity->val,
-                          attr->lcommunity->size * 12);
+                          attr->lcommunity->size * LCOMMUNITY_SIZE);
        }
 
        /* Add a MP_NLRI attribute to dump the IPv6 next hop */
index f4393c1b2d7ad3801bd4024649a9bc71fd961f5f..344a25dfa6320c1a730a5f91e45e96feba440db4 100644 (file)
@@ -447,7 +447,7 @@ char *lcommunity_lcom2str(struct lcommunity *lcom, int format)
                if (!first)
                        str_buf[str_pnt++] = ' ';
 
-               pnt = lcom->val + (i * 12);
+               pnt = lcom->val + (i * LCOMMUNITY_SIZE);
 
                globaladmin = (*pnt++ << 24);
                globaladmin |= (*pnt++ << 16);
@@ -489,7 +489,7 @@ int lcommunity_match(const struct lcommunity *lcom1,
 
        /* Every community on com2 needs to be on com1 for this to match */
        while (i < lcom1->size && j < lcom2->size) {
-               if (memcmp(lcom1->val + (i * 12), lcom2->val + (j * 12),
+               if (memcmp(lcom1->val + (i * LCOMMUNITY_SIZE), lcom2->val + (j * LCOMMUNITY_SIZE),
                           LCOMMUNITY_SIZE)
                    == 0)
                        j++;