From 8ea01902d28e107183d10453da809ca502b07a09 Mon Sep 17 00:00:00 2001 From: Nigel Kukard Date: Wed, 30 Aug 2017 05:40:54 +0000 Subject: [PATCH] bgpd: The large community size is easier to read if its using the constant Signed-off-by: Nigel Kukard --- bgpd/bgp_attr.c | 16 ++++++++-------- bgpd/bgp_lcommunity.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index b03b408f7d..da5d1e8d9c 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -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 */ diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index f4393c1b2d..344a25dfa6 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -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++; -- 2.39.5