From: claudio Date: Thu, 27 May 2021 14:32:08 +0000 (+0000) Subject: Rename and move functions used to get per-peer settings to the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e4b4fff89b1138e2b3f516519dd79c1b0a8a3706;p=openbsd Rename and move functions used to get per-peer settings to the hopefully better names peer_has_as4byte() and peer_accept_no_as_set(). Move them to rde_peer.c where all other peer functions live. OK sthen@ --- diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 34b99af95e3..9cbeb7c4d33 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.522 2021/05/27 08:38:42 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.523 2021/05/27 14:32:08 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -81,7 +81,6 @@ static void rde_softreconfig_sync_reeval(struct rib_entry *, void *); static void rde_softreconfig_sync_fib(struct rib_entry *, void *); static void rde_softreconfig_sync_done(void *, u_int8_t); static void rde_roa_reload(void); -static int rde_no_as_set(struct rde_peer *); int rde_update_queue_pending(void); void rde_update_queue_runner(void); void rde_update6_queue_runner(u_int8_t); @@ -1661,8 +1660,8 @@ bad_flags: case ATTR_ASPATH: if (!CHECK_FLAGS(flags, ATTR_WELL_KNOWN, 0)) goto bad_flags; - error = aspath_verify(p, attr_len, rde_as4byte(peer), - rde_no_as_set(peer)); + error = aspath_verify(p, attr_len, peer_has_as4byte(peer), + peer_accept_no_as_set(peer)); if (error == AS_ERR_SOFT) { /* * soft errors like unexpected segment types are @@ -1677,7 +1676,7 @@ bad_flags: } if (a->flags & F_ATTR_ASPATH) goto bad_list; - if (rde_as4byte(peer)) { + if (peer_has_as4byte(peer)) { npath = p; nlen = attr_len; } else { @@ -1761,8 +1760,8 @@ bad_flags: goto bad_flags; goto optattr; case ATTR_AGGREGATOR: - if ((!rde_as4byte(peer) && attr_len != 6) || - (rde_as4byte(peer) && attr_len != 8)) { + if ((!peer_has_as4byte(peer) && attr_len != 6) || + (peer_has_as4byte(peer) && attr_len != 8)) { /* * ignore attribute in case of error as per * RFC 7606 @@ -1775,7 +1774,7 @@ bad_flags: if (!CHECK_FLAGS(flags, ATTR_OPTIONAL|ATTR_TRANSITIVE, ATTR_PARTIAL)) goto bad_flags; - if (!rde_as4byte(peer)) { + if (!peer_has_as4byte(peer)) { /* need to inflate aggregator AS to 4-byte */ u_char t[8]; t[0] = t[1] = 0; @@ -1921,7 +1920,7 @@ bad_flags: ATTR_PARTIAL)) goto bad_flags; if ((error = aspath_verify(p, attr_len, 1, - rde_no_as_set(peer))) != 0) { + peer_accept_no_as_set(peer))) != 0) { /* As per RFC6793 use "attribute discard" here. */ log_peer_warnx(&peer->conf, "bad AS4_PATH, " "attribute discarded"); @@ -2170,7 +2169,7 @@ rde_as4byte_fixup(struct rde_peer *peer, struct rde_aspath *a) nasp = attr_optget(a, ATTR_AS4_PATH); naggr = attr_optget(a, ATTR_AS4_AGGREGATOR); - if (rde_as4byte(peer)) { + if (peer_has_as4byte(peer)) { /* NEW session using 4-byte ASNs */ if (nasp) { log_peer_warnx(&peer->conf, "uses 4-byte ASN " @@ -3741,18 +3740,6 @@ rde_decisionflags(void) return (conf->flags & BGPD_FLAG_DECISION_MASK); } -int -rde_as4byte(struct rde_peer *peer) -{ - return (peer->capa.as4byte); -} - -static int -rde_no_as_set(struct rde_peer *peer) -{ - return (peer->flags & PEERFLAG_NO_AS_SET); -} - /* End-of-RIB marker, RFC 4724 */ static void rde_peer_recv_eor(struct rde_peer *peer, u_int8_t aid) diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 1fad1c41fdc..3cbfec7a53a 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.238 2021/05/06 09:18:54 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.239 2021/05/27 14:32:08 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker and @@ -378,10 +378,11 @@ void rde_generate_updates(struct rib *, struct prefix *, struct prefix *, int); u_int32_t rde_local_as(void); int rde_decisionflags(void); -int rde_as4byte(struct rde_peer *); int rde_match_peer(struct rde_peer *, struct ctl_neighbor *); /* rde_peer.c */ +int peer_has_as4byte(struct rde_peer *); +int peer_accept_no_as_set(struct rde_peer *); void peer_init(u_int32_t); void peer_shutdown(void); void peer_foreach(void (*)(struct rde_peer *, void *), void *); diff --git a/usr.sbin/bgpd/rde_peer.c b/usr.sbin/bgpd/rde_peer.c index 9a7d084f11f..904fd92848e 100644 --- a/usr.sbin/bgpd/rde_peer.c +++ b/usr.sbin/bgpd/rde_peer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_peer.c,v 1.8 2021/05/27 13:59:44 claudio Exp $ */ +/* $OpenBSD: rde_peer.c,v 1.9 2021/05/27 14:32:08 claudio Exp $ */ /* * Copyright (c) 2019 Claudio Jeker @@ -44,6 +44,18 @@ struct iq { extern struct filter_head *out_rules; +int +peer_has_as4byte(struct rde_peer *peer) +{ + return (peer->capa.as4byte); +} + +int +peer_accept_no_as_set(struct rde_peer *peer) +{ + return (peer->flags & PEERFLAG_NO_AS_SET); +} + void peer_init(u_int32_t hashsize) { diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index b20da366937..66abee9b2f1 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.128 2021/05/27 08:45:24 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.129 2021/05/27 14:32:08 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker @@ -371,7 +371,7 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, pdata = aspath_prepend(asp->aspath, peer->conf.local_as, 1, &plen); - if (!rde_as4byte(peer)) + if (!peer_has_as4byte(peer)) pdata = aspath_deflate(pdata, &plen, &neednewpath); @@ -498,7 +498,7 @@ up_generate_attr(u_char *buf, int len, struct rde_peer *peer, case ATTR_AGGREGATOR: if (oa == NULL || oa->type != type) break; - if (!rde_as4byte(peer)) { + if (!peer_has_as4byte(peer)) { /* need to deflate the aggregator */ u_int8_t t[6]; u_int16_t tas;