Skip to content

Commit

Permalink
Revert "*: reindent pt. 2"
Browse files Browse the repository at this point in the history
This reverts commit c14777c.

clang 5 is not widely available enough for people to indent with.  This
is particularly problematic when rebasing/adjusting branches.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
  • Loading branch information
eqvinox committed Jul 22, 2017
1 parent dceb5f8 commit 9d303b3
Show file tree
Hide file tree
Showing 140 changed files with 1,570 additions and 1,925 deletions.
20 changes: 8 additions & 12 deletions bgpd/bgp_aspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,8 @@ size_t aspath_put(struct stream *s, struct aspath *as, int use32bit)
* The general assumption here is that many things tested will
* never happen. And, in real live, up to now, they have not.
*/
while (seg
&& (ASSEGMENT_LEN(seg, use32bit)
<= STREAM_WRITEABLE(s))) {
while (seg && (ASSEGMENT_LEN(seg, use32bit)
<= STREAM_WRITEABLE(s))) {
struct assegment *next = seg->next;
int written = 0;
int asns_packed = 0;
Expand Down Expand Up @@ -1585,14 +1584,12 @@ int aspath_cmp_left(const struct aspath *aspath1, const struct aspath *aspath2)
return 1;

/* find first non-confed segments for each */
while (seg1
&& ((seg1->type == AS_CONFED_SEQUENCE)
|| (seg1->type == AS_CONFED_SET)))
while (seg1 && ((seg1->type == AS_CONFED_SEQUENCE)
|| (seg1->type == AS_CONFED_SET)))
seg1 = seg1->next;

while (seg2
&& ((seg2->type == AS_CONFED_SEQUENCE)
|| (seg2->type == AS_CONFED_SET)))
while (seg2 && ((seg2->type == AS_CONFED_SEQUENCE)
|| (seg2->type == AS_CONFED_SET)))
seg2 = seg2->next;

/* Check as1's */
Expand Down Expand Up @@ -2069,8 +2066,7 @@ static void aspath_show_all_iterator(struct hash_backet *backet,
`show [ip] bgp paths' command. */
void aspath_print_all_vty(struct vty *vty)
{
hash_iterate(ashash,
(void (*)(struct hash_backet *,
void *))aspath_show_all_iterator,
hash_iterate(ashash, (void (*)(struct hash_backet *,
void *))aspath_show_all_iterator,
vty);
}
153 changes: 83 additions & 70 deletions bgpd/bgp_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,15 @@ 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 @@ -679,10 +680,9 @@ static void attr_show_all_iterator(struct hash_backet *backet, struct vty *vty)

void attr_show_all(struct vty *vty)
{
hash_iterate(
attrhash,
(void (*)(struct hash_backet *, void *))attr_show_all_iterator,
vty);
hash_iterate(attrhash, (void (*)(struct hash_backet *,
void *))attr_show_all_iterator,
vty);
}

static void *bgp_attr_hash_alloc(void *p)
Expand Down Expand Up @@ -1055,7 +1055,7 @@ bgp_attr_malformed(struct bgp_attr_parser_args *args, u_char subcode,
static void
bgp_attr_flags_diagnose(struct bgp_attr_parser_args *args,
u_int8_t desired_flags /* how RFC says it must be */
)
)
{
u_char seen = 0, i;
u_char real_flags = args->flags;
Expand Down Expand Up @@ -1087,26 +1087,30 @@ bgp_attr_flags_diagnose(struct bgp_attr_parser_args *args,
* as will PARTIAL for optional+transitive attributes.
*/
const u_int8_t attr_flags_values[] = {
[BGP_ATTR_ORIGIN] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS_PATH] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_NEXT_HOP] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_MULTI_EXIT_DISC] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_LOCAL_PREF] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_ATOMIC_AGGREGATE] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AGGREGATOR] = BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_COMMUNITIES] = BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_ORIGINATOR_ID] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_CLUSTER_LIST] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_MP_REACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_MP_UNREACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_EXT_COMMUNITIES] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_PATH] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_AGGREGATOR] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_LARGE_COMMUNITIES] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_PREFIX_SID] = BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_ORIGIN] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS_PATH] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_NEXT_HOP] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_MULTI_EXIT_DISC] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_LOCAL_PREF] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_ATOMIC_AGGREGATE] = BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AGGREGATOR] =
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_COMMUNITIES] =
BGP_ATTR_FLAG_TRANS | BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_ORIGINATOR_ID] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_CLUSTER_LIST] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_MP_REACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_MP_UNREACH_NLRI] = BGP_ATTR_FLAG_OPTIONAL,
[BGP_ATTR_EXT_COMMUNITIES] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_PATH] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_AS4_AGGREGATOR] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_LARGE_COMMUNITIES] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
[BGP_ATTR_PREFIX_SID] =
BGP_ATTR_FLAG_OPTIONAL | BGP_ATTR_FLAG_TRANS,
};
static const size_t attr_flags_values_max = array_size(attr_flags_values) - 1;

Expand Down Expand Up @@ -2751,10 +2755,9 @@ static void bgp_packet_mpattr_tea(struct bgp *bgp, struct peer *peer,
struct bgp_attr_encap_subtlv *st;
const char *attrname;

if (!attr
|| (attrtype == BGP_ATTR_ENCAP
&& (!attr->encap_tunneltype
|| attr->encap_tunneltype == BGP_ENCAP_TYPE_MPLS)))
if (!attr || (attrtype == BGP_ATTR_ENCAP
&& (!attr->encap_tunneltype
|| attr->encap_tunneltype == BGP_ENCAP_TYPE_MPLS)))
return;

switch (attrtype) {
Expand Down Expand Up @@ -2801,8 +2804,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 @@ -3040,14 +3044,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 @@ -3061,14 +3066,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 (attr->lcommunity->size * 12 > 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, attr->lcommunity->size * 12);
} 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, attr->lcommunity->size * 12);
}
Expand Down Expand Up @@ -3120,14 +3126,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 @@ -3193,8 +3201,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 @@ -3222,8 +3231,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 @@ -3408,14 +3418,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 @@ -3425,14 +3436,15 @@ 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) {
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, attr->lcommunity->size * 12);
} 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, attr->lcommunity->size * 12);
}
Expand Down Expand Up @@ -3477,8 +3489,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
2 changes: 1 addition & 1 deletion bgpd/bgp_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ typedef enum {
BGP_ATTR_PARSE_WITHDRAW = -2,

/* only used internally, send notify + convert to BGP_ATTR_PARSE_ERROR
*/
*/
BGP_ATTR_PARSE_ERROR_NOTIFYPLS = -3,
} bgp_attr_parse_ret_t;

Expand Down
5 changes: 2 additions & 3 deletions bgpd/bgp_bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,8 @@ static void bgp_bfd_update_type(struct peer *peer)
if ((multihop
&& !CHECK_FLAG(bfd_info->flags,
BFD_FLAG_BFD_TYPE_MULTIHOP))
|| (!multihop
&& CHECK_FLAG(bfd_info->flags,
BFD_FLAG_BFD_TYPE_MULTIHOP))) {
|| (!multihop && CHECK_FLAG(bfd_info->flags,
BFD_FLAG_BFD_TYPE_MULTIHOP))) {
bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_DEREGISTER);
bgp_bfd_peer_sendmsg(peer, ZEBRA_BFD_DEST_REGISTER);
}
Expand Down
4 changes: 1 addition & 3 deletions bgpd/bgp_btoa.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@

/* privileges */
static zebra_capabilities_t _caps_p[] = {
ZCAP_BIND,
ZCAP_NET_RAW,
ZCAP_NET_ADMIN,
ZCAP_BIND, ZCAP_NET_RAW, ZCAP_NET_ADMIN,
};

struct zebra_privs_t bgpd_privs = {
Expand Down
15 changes: 7 additions & 8 deletions bgpd/bgp_damp.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,10 @@ static void bgp_damp_parameter_set(int hlife, int reuse, int sup, int maxsup)
/* Initialize params per bgp_damp_config. */
damp->reuse_index_size = REUSE_ARRAY_SIZE;

damp->ceiling = (int)(damp->reuse_limit
* (pow(2, (double)damp->max_suppress_time
/ damp->half_life)));
damp->ceiling =
(int)(damp->reuse_limit * (pow(2,
(double)damp->max_suppress_time
/ damp->half_life)));

/* Decay-array computations */
damp->decay_array_size =
Expand Down Expand Up @@ -413,11 +414,9 @@ static void bgp_damp_parameter_set(int hlife, int reuse, int sup, int maxsup)
for (i = 0; i < damp->reuse_index_size; i++) {
damp->reuse_index[i] =
(int)(((double)damp->half_life / DELTA_REUSE)
* log10(1.0
/ (damp->reuse_limit
* (1.0
+ ((double)i
/ damp->scale_factor))))
* log10(1.0 / (damp->reuse_limit
* (1.0 + ((double)i
/ damp->scale_factor))))
/ log10(0.5));
}
}
Expand Down
5 changes: 3 additions & 2 deletions bgpd/bgp_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,9 @@ static void bgp_dump_routes_index_table(struct bgp *bgp)

/* Populate fake peer at index 0, for locally originated routes */
/* Peer type (IPv4) */
stream_putc(obuf, TABLE_DUMP_V2_PEER_INDEX_TABLE_AS4
+ TABLE_DUMP_V2_PEER_INDEX_TABLE_IP);
stream_putc(obuf,
TABLE_DUMP_V2_PEER_INDEX_TABLE_AS4
+ TABLE_DUMP_V2_PEER_INDEX_TABLE_IP);
/* Peer BGP ID (0.0.0.0) */
stream_putl(obuf, 0);
/* Peer IP address (0.0.0.0) */
Expand Down
Loading

0 comments on commit 9d303b3

Please sign in to comment.