Skip to content

Commit

Permalink
*: conform with COMMUNITY.md formatting rules, via 'make indent'
Browse files Browse the repository at this point in the history
Signed-off-by: Lou Berger <lberger@labn.net>
  • Loading branch information
louberger committed Mar 6, 2018
1 parent 3380418 commit 996c931
Show file tree
Hide file tree
Showing 283 changed files with 6,790 additions and 6,809 deletions.
20 changes: 11 additions & 9 deletions bgpd/bgp_aspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)
if (!as->segments) {
if (make_json) {
json_object_string_add(as->json, "string", "Local");
json_object_object_add(as->json, "segments", jaspath_segments);
json_object_object_add(as->json, "segments",
jaspath_segments);
json_object_int_add(as->json, "length", 0);
}
as->str = XMALLOC(MTYPE_AS_STR, 1);
Expand Down Expand Up @@ -575,8 +576,9 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)
/* write out the ASNs, with their seperators, bar the last one*/
for (i = 0; i < seg->length; i++) {
if (make_json)
json_object_array_add(jseg_list,
json_object_new_int(seg->as[i]));
json_object_array_add(
jseg_list,
json_object_new_int(seg->as[i]));

len += snprintf(str_buf + len, str_size - len, "%u",
seg->as[i]);
Expand All @@ -588,8 +590,9 @@ static void aspath_make_str_count(struct aspath *as, bool make_json)

if (make_json) {
jseg = json_object_new_object();
json_object_string_add(jseg, "type",
aspath_segment_type_str[seg->type]);
json_object_string_add(
jseg, "type",
aspath_segment_type_str[seg->type]);
json_object_object_add(jseg, "list", jseg_list);
json_object_array_add(jaspath_segments, jseg);
}
Expand Down Expand Up @@ -904,7 +907,8 @@ size_t aspath_put(struct stream *s, struct aspath *as, int use32bit)
assegment_data_put(s, seg->as, AS_SEGMENT_MAX,
use32bit);
written += AS_SEGMENT_MAX;
bytes += ASSEGMENT_SIZE(AS_SEGMENT_MAX, use32bit);
bytes += ASSEGMENT_SIZE(AS_SEGMENT_MAX,
use32bit);
}

/* write the final segment, probably is also the first
Expand Down Expand Up @@ -2032,9 +2036,7 @@ int aspath_cmp(const void *arg1, const void *arg2)
/* AS path hash initialize. */
void aspath_init(void)
{
ashash = hash_create_size(32768,
aspath_key_make,
aspath_cmp,
ashash = hash_create_size(32768, aspath_key_make, aspath_cmp,
"BGP AS Path");
}

Expand Down
159 changes: 82 additions & 77 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,14 @@ static const struct message attr_str[] = {
{BGP_ATTR_PREFIX_SID, "PREFIX_SID"},
{0}};

static const struct message attr_flag_str[] =
{
{BGP_ATTR_FLAG_OPTIONAL, "Optional"},
{BGP_ATTR_FLAG_TRANS, "Transitive"},
{BGP_ATTR_FLAG_PARTIAL, "Partial"},
/* bgp_attr_flags_diagnose() relies on this bit being last in
this list */
{BGP_ATTR_FLAG_EXTLEN, "Extended Length"},
{0}};
static const struct message attr_flag_str[] = {
{BGP_ATTR_FLAG_OPTIONAL, "Optional"},
{BGP_ATTR_FLAG_TRANS, "Transitive"},
{BGP_ATTR_FLAG_PARTIAL, "Partial"},
/* bgp_attr_flags_diagnose() relies on this bit being last in
this list */
{BGP_ATTR_FLAG_EXTLEN, "Extended Length"},
{0}};

static struct hash *cluster_hash;

Expand Down Expand Up @@ -185,8 +184,7 @@ void cluster_unintern(struct cluster_list *cluster)

static void cluster_init(void)
{
cluster_hash = hash_create(cluster_hash_key_make,
cluster_hash_cmp,
cluster_hash = hash_create(cluster_hash_key_make, cluster_hash_cmp,
"BGP Cluster");
}

Expand Down Expand Up @@ -363,12 +361,10 @@ static int encap_hash_cmp(const void *p1, const void *p2)

static void encap_init(void)
{
encap_hash = hash_create(encap_hash_key_make,
encap_hash_cmp,
encap_hash = hash_create(encap_hash_key_make, encap_hash_cmp,
"BGP Encap Hash");
#if ENABLE_BGP_VNC
vnc_hash = hash_create(encap_hash_key_make,
encap_hash_cmp,
vnc_hash = hash_create(encap_hash_key_make, encap_hash_cmp,
"BGP VNC Hash");
#endif
}
Expand Down Expand Up @@ -454,8 +450,7 @@ static int transit_hash_cmp(const void *p1, const void *p2)

static void transit_init(void)
{
transit_hash = hash_create(transit_hash_key_make,
transit_hash_cmp,
transit_hash = hash_create(transit_hash_key_make, transit_hash_cmp,
"BGP Transit Hash");
}

Expand Down Expand Up @@ -496,7 +491,8 @@ unsigned int attrhash_key_make(void *p)
#define MIX3(a, b, c) key = jhash_3words((a), (b), (c), key)

MIX3(attr->origin, attr->nexthop.s_addr, attr->med);
MIX3(attr->local_pref, attr->aggregator_as, attr->aggregator_addr.s_addr);
MIX3(attr->local_pref, attr->aggregator_as,
attr->aggregator_addr.s_addr);
MIX3(attr->weight, attr->mp_nexthop_global_in.s_addr,
attr->originator_id.s_addr);
MIX3(attr->tag, attr->label, attr->label_index);
Expand Down Expand Up @@ -571,9 +567,8 @@ int attrhash_cmp(const void *p1, const void *p2)

static void attrhash_init(void)
{
attrhash = hash_create(attrhash_key_make,
attrhash_cmp,
"BGP Attributes");
attrhash =
hash_create(attrhash_key_make, attrhash_cmp, "BGP Attributes");
}

/*
Expand Down Expand Up @@ -747,8 +742,8 @@ struct attr *bgp_attr_aggregate_intern(struct bgp *bgp, u_char origin,
/* If we are not shutting down ourselves and we are
* aggregating a route that contains the GSHUT community we
* need to remove that community when creating the aggregate */
if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN) &&
community_include(community, gshut)) {
if (!bgp_flag_check(bgp, BGP_FLAG_GRACEFUL_SHUTDOWN)
&& community_include(community, gshut)) {
community_del_val(community, &gshut);
}

Expand Down Expand Up @@ -840,7 +835,6 @@ void bgp_attr_undup(struct attr *new, struct attr *old)

if (new->lcommunity != old->lcommunity)
lcommunity_free(&new->lcommunity);

}

/* Free bgp attribute and aspath. */
Expand Down Expand Up @@ -1661,14 +1655,14 @@ int bgp_mp_reach_parse(struct bgp_attr_parser_args *args,
case BGP_ATTR_NHLEN_VPNV4:
stream_getl(s); /* RD high */
stream_getl(s); /* RD low */
/*
* NOTE: intentional fall through
* - for consistency in rx processing
*
* The following comment is to signal GCC this intention
* and supress the warning
*/
/* FALLTHRU */
/*
* NOTE: intentional fall through
* - for consistency in rx processing
*
* The following comment is to signal GCC this intention
* and supress the warning
*/
/* FALLTHRU */
case BGP_ATTR_NHLEN_IPV4:
stream_get(&attr->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN);
/* Probably needed for RFC 2283 */
Expand Down Expand Up @@ -1960,8 +1954,7 @@ static int bgp_attr_encap(uint8_t type, struct peer *peer, /* IN */
/* alloc and copy sub-tlv */
/* TBD make sure these are freed when attributes are released */
tlv = XCALLOC(MTYPE_ENCAP_TLV,
sizeof(struct bgp_attr_encap_subtlv)
+ sublength);
sizeof(struct bgp_attr_encap_subtlv) + sublength);
tlv->type = subtype;
tlv->length = sublength;
stream_get(tlv->value, peer->curr, sublength);
Expand Down Expand Up @@ -2715,8 +2708,8 @@ void bgp_packet_mpattr_prefix(struct stream *s, afi_t afi, safi_t safi,
stream_put(s, &p->u.prefix, PSIZE(p->prefixlen));
} else if (afi == AFI_L2VPN && safi == SAFI_EVPN) {
/* EVPN prefix - contents depend on type */
bgp_evpn_encode_prefix(s, p, prd, label, num_labels,
attr, addpath_encode, addpath_tx_id);
bgp_evpn_encode_prefix(s, p, prd, label, num_labels, attr,
addpath_encode, addpath_tx_id);
} else if (safi == SAFI_LABELED_UNICAST) {
/* Prefix write with label. */
stream_put_labeled_prefix(s, p, label);
Expand Down Expand Up @@ -2799,8 +2792,9 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,

if (attrlenfield > 0xff) {
/* 2-octet length field */
stream_putc(s, BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, attrtype);
stream_putw(s, attrlenfield & 0xffff);
} else {
Expand Down Expand Up @@ -2867,9 +2861,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,

mpattrlen_pos = bgp_packet_mpattr_start(s, peer, afi, safi,
vecarr, attr);
bgp_packet_mpattr_prefix(s, afi, safi, p, prd,
label, num_labels,
addpath_encode, addpath_tx_id, attr);
bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label,
num_labels, addpath_encode,
addpath_tx_id, attr);
bgp_packet_mpattr_end(s, mpattrlen_pos);
}

Expand Down Expand Up @@ -3039,14 +3033,15 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
if (CHECK_FLAG(peer->af_flags[afi][safi], PEER_FLAG_SEND_COMMUNITY)
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES))) {
if (attr->community->size * 4 > 255) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putw(s, attr->community->size * 4);
} else {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putc(s, attr->community->size * 4);
}
Expand All @@ -3060,14 +3055,15 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
PEER_FLAG_SEND_LARGE_COMMUNITY)
&& (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_LARGE_COMMUNITIES))) {
if (lcom_length(attr->lcommunity) > 255) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
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, lcom_length(attr->lcommunity));
} else {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putc(s, lcom_length(attr->lcommunity));
}
Expand Down Expand Up @@ -3119,14 +3115,16 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
if (peer->sort == BGP_PEER_IBGP
|| peer->sort == BGP_PEER_CONFED) {
if (attr->ecommunity->size * 8 > 255) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
stream_putw(s, attr->ecommunity->size * 8);
} else {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_EXT_COMMUNITIES);
stream_putc(s, attr->ecommunity->size * 8);
}
Expand Down Expand Up @@ -3192,8 +3190,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
label_index = attr->label_index;

if (label_index != BGP_INVALID_LABEL_INDEX) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_PREFIX_SID);
stream_putc(s, 10);
stream_putc(s, BGP_PREFIX_SID_LABEL_INDEX);
Expand Down Expand Up @@ -3221,8 +3220,9 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
*/
aspath = aspath_delete_confed_seq(aspath);

stream_putc(s, BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s,
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_AS4_PATH);
aspath_sizep = stream_get_endp(s);
stream_putw(s, 0);
Expand Down Expand Up @@ -3264,8 +3264,10 @@ bgp_size_t bgp_packet_attribute(struct bgp *bgp, struct peer *peer,
stream_putc(s, 9); // Length
stream_putc(s, 0); // Flags
stream_putc(s, 6); // Tunnel type: Ingress Replication (6)
stream_put(s, &(attr->label), BGP_LABEL_BYTES); // MPLS Label / VXLAN VNI
stream_put_ipv4(s, attr->nexthop.s_addr); // Unicast tunnel endpoint IP address
stream_put(s, &(attr->label),
BGP_LABEL_BYTES); // MPLS Label / VXLAN VNI
stream_put_ipv4(s, attr->nexthop.s_addr); // Unicast tunnel
// endpoint IP address
}

/* Unknown transit attribute. */
Expand Down Expand Up @@ -3311,8 +3313,7 @@ void bgp_packet_mpunreach_prefix(struct stream *s, struct prefix *p, afi_t afi,
num_labels = 1;
}

return bgp_packet_mpattr_prefix(s, afi, safi, p, prd,
label, num_labels,
return bgp_packet_mpattr_prefix(s, afi, safi, p, prd, label, num_labels,
addpath_encode, addpath_tx_id, attr);
}

Expand Down Expand Up @@ -3422,14 +3423,15 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
/* Community attribute. */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_COMMUNITIES)) {
if (attr->community->size * 4 > 255) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putw(s, attr->community->size * 4);
} else {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_COMMUNITIES);
stream_putc(s, attr->community->size * 4);
}
Expand All @@ -3439,19 +3441,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 (lcom_length(attr->lcommunity) > 255) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS
| BGP_ATTR_FLAG_EXTLEN);
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, lcom_length(attr->lcommunity));
} else {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_LARGE_COMMUNITIES);
stream_putc(s, lcom_length(attr->lcommunity));
}

stream_put(s, attr->lcommunity->val, lcom_length(attr->lcommunity));
stream_put(s, attr->lcommunity->val,
lcom_length(attr->lcommunity));
}

/* Add a MP_NLRI attribute to dump the IPv6 next hop */
Expand Down Expand Up @@ -3490,8 +3494,9 @@ void bgp_dump_routes_attr(struct stream *s, struct attr *attr,
/* Prefix SID */
if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_PREFIX_SID)) {
if (attr->label_index != BGP_INVALID_LABEL_INDEX) {
stream_putc(s, BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s,
BGP_ATTR_FLAG_OPTIONAL
| BGP_ATTR_FLAG_TRANS);
stream_putc(s, BGP_ATTR_PREFIX_SID);
stream_putc(s, 10);
stream_putc(s, BGP_PREFIX_SID_LABEL_INDEX);
Expand Down
Loading

0 comments on commit 996c931

Please sign in to comment.