diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2012-04-12 17:31:06 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2012-04-12 17:31:06 +0000 |
commit | ab8c7358124cfd2734adf977bef218d3288e91ca (patch) | |
tree | 7c8fbb1bc47d8aa8e29b7110b63e4d44ceee6b66 /usr.sbin/bgpd | |
parent | 40c6e0ec0ce6a3914416403de293e253c5d94546 (diff) |
The ebgp flags is just a truth value and it is better to not == 1 compares.
OK henning@ sthen@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_decide.c | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_update.c | 12 |
5 files changed, 23 insertions, 23 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 16bf1e97f91..c674ec32a4a 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.268 2012/03/27 18:22:07 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.269 2012/04/12 17:31:05 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -284,7 +284,7 @@ struct peer_config { u_int8_t template; u_int8_t remote_masklen; u_int8_t cloned; - u_int8_t ebgp; /* 1 = ebgp, 0 = ibgp */ + u_int8_t ebgp; /* 0 = ibgp else ebgp */ u_int8_t distance; /* 1 = direct, >1 = multihop */ u_int8_t passive; u_int8_t down; diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index 6939faaaee6..a06cb98df62 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.260 2011/09/17 16:29:44 claudio Exp $ */ +/* $OpenBSD: parse.y,v 1.261 2012/04/12 17:31:05 claudio Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -3359,11 +3359,11 @@ neighbor_consistent(struct peer *p) /* set default values if they where undefined */ p->conf.ebgp = (p->conf.remote_as != conf->as); if (p->conf.announce_type == ANNOUNCE_UNDEF) - p->conf.announce_type = p->conf.ebgp == 0 ? - ANNOUNCE_ALL : ANNOUNCE_SELF; + p->conf.announce_type = p->conf.ebgp ? + ANNOUNCE_SELF : ANNOUNCE_ALL; if (p->conf.enforce_as == ENFORCE_AS_UNDEF) - p->conf.enforce_as = p->conf.ebgp == 0 ? - ENFORCE_AS_OFF : ENFORCE_AS_ON; + p->conf.enforce_as = p->conf.ebgp ? + ENFORCE_AS_ON : ENFORCE_AS_OFF; /* EBGP neighbors are not allowed in route reflector clusters */ if (p->conf.reflector_client && p->conf.ebgp) { diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index d92e7339b2f..d943d3f0ef7 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.313 2012/04/07 17:25:51 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.314 2012/04/12 17:31:05 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2030,10 +2030,10 @@ rde_reflector(struct rde_peer *peer, struct rde_aspath *asp) return; } } else if (conf->flags & BGPD_FLAG_REFLECTOR) { - if (peer->conf.ebgp == 0) - id = htonl(peer->remote_bgpid); - else + if (peer->conf.ebgp) id = conf->bgpid; + else + id = htonl(peer->remote_bgpid); if (attr_optadd(asp, ATTR_OPTIONAL, ATTR_ORIGINATOR_ID, &id, sizeof(u_int32_t)) == -1) fatalx("attr_optadd failed but impossible"); @@ -2108,7 +2108,7 @@ rde_dump_rib_as(struct prefix *p, struct rde_aspath *asp, pid_t pid, int flags) rib.flags = 0; if (p->rib->active == p) rib.flags |= F_PREF_ACTIVE; - if (asp->peer->conf.ebgp == 0) + if (!asp->peer->conf.ebgp) rib.flags |= F_PREF_INTERNAL; if (asp->flags & F_PREFIX_ANNOUNCED) rib.flags |= F_PREF_ANNOUNCE; diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c index 27586a72c9e..19c9162d721 100644 --- a/usr.sbin/bgpd/rde_decide.c +++ b/usr.sbin/bgpd/rde_decide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_decide.c,v 1.60 2010/05/03 13:09:38 claudio Exp $ */ +/* $OpenBSD: rde_decide.c,v 1.61 2012/04/12 17:31:05 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -136,7 +136,7 @@ prefix_cmp(struct prefix *p1, struct prefix *p2) if (asp1->nexthop != NULL && asp1->nexthop->state != NEXTHOP_REACH) return (-1); - /* 2. preference of prefix, bigger is better */ + /* 2. local preference of prefix, bigger is better */ if ((asp1->lpref - asp2->lpref) != 0) return (asp1->lpref - asp2->lpref); @@ -160,10 +160,10 @@ prefix_cmp(struct prefix *p1, struct prefix *p2) * It is absolutely important that the ebgp value in peer_config.ebgp * is bigger than all other ones (IBGP, confederations) */ - if ((asp1->peer->conf.ebgp - asp2->peer->conf.ebgp) != 0) { - if (asp1->peer->conf.ebgp == 1) /* p1 is EBGP other is lower */ + if (asp1->peer->conf.ebgp != asp2->peer->conf.ebgp) { + if (asp1->peer->conf.ebgp) /* p1 is EBGP other is lower */ return 1; - else if (asp2->peer->conf.ebgp == 1) /* p2 is EBGP */ + else if (asp2->peer->conf.ebgp) /* p2 is EBGP */ return -1; } diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index 0fe31765ca3..afb6e8d357a 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.79 2010/12/31 21:22:42 guenther Exp $ */ +/* $OpenBSD: rde_update.c,v 1.80 2012/04/12 17:31:05 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -293,7 +293,7 @@ up_test_update(struct rde_peer *peer, struct prefix *p) if (peer->capa.mp[addr.aid] == 0) return (-1); - if (p->aspath->peer->conf.ebgp == 0 && peer->conf.ebgp == 0) { + if (!p->aspath->peer->conf.ebgp && !peer->conf.ebgp) { /* * route reflector redistribution rules: * 1. if announce is set -> announce @@ -774,7 +774,7 @@ up_generate_attr(struct rde_peer *peer, struct update_attr *upa, * unless the MED is originating from us or the peer is an IBGP one. * Only exception are routers with "transparent-as yes" set. */ - if (a->flags & F_ATTR_MED && (peer->conf.ebgp == 0 || + if (a->flags & F_ATTR_MED && (!peer->conf.ebgp || a->flags & F_ATTR_MED_ANNOUNCE || peer->conf.flags & PEERFLAG_TRANS_AS)) { tmp32 = htonl(a->med); @@ -784,7 +784,7 @@ up_generate_attr(struct rde_peer *peer, struct update_attr *upa, wlen += r; len -= r; } - if (peer->conf.ebgp == 0) { + if (!peer->conf.ebgp) { /* local preference, only valid for ibgp */ tmp32 = htonl(a->lpref); if ((r = attr_write(up_attr_buf + wlen, len, ATTR_WELL_KNOWN, @@ -819,7 +819,7 @@ up_generate_attr(struct rde_peer *peer, struct update_attr *upa, u_int16_t tas; if ((!(oa->flags & ATTR_TRANSITIVE)) && - peer->conf.ebgp != 0) { + peer->conf.ebgp) { r = 0; break; } @@ -845,7 +845,7 @@ up_generate_attr(struct rde_peer *peer, struct update_attr *upa, case ATTR_ORIGINATOR_ID: case ATTR_CLUSTER_LIST: if ((!(oa->flags & ATTR_TRANSITIVE)) && - peer->conf.ebgp != 0) { + peer->conf.ebgp) { r = 0; break; } |