Just rename and move some functions used to get per-peer settings to the
hopefully better names peer_has_as4byte() and peer_accept_no_as_set().
--
:wq Claudio
Index: rde.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.c,v
retrieving revision 1.522
diff -u -p -r1.522 rde.c
--- rde.c 27 May 2021 08:38:42 -0000 1.522
+++ rde.c 27 May 2021 14:10:24 -0000
@@ -81,7 +81,6 @@ static void rde_softreconfig_sync_reeva
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,
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 "
@@ -3739,18 +3738,6 @@ int
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 */
Index: rde.h
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde.h,v
retrieving revision 1.238
diff -u -p -r1.238 rde.h
--- rde.h 6 May 2021 09:18:54 -0000 1.238
+++ rde.h 27 May 2021 14:09:09 -0000
@@ -378,10 +378,11 @@ void rde_generate_updates(struct rib *,
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 *);
Index: rde_peer.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_peer.c,v
retrieving revision 1.7
diff -u -p -r1.7 rde_peer.c
--- rde_peer.c 6 May 2021 09:18:54 -0000 1.7
+++ rde_peer.c 27 May 2021 14:08:32 -0000
@@ -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)
{
Index: rde_update.c
===================================================================
RCS file: /cvs/src/usr.sbin/bgpd/rde_update.c,v
retrieving revision 1.128
diff -u -p -r1.128 rde_update.c
--- rde_update.c 27 May 2021 08:45:24 -0000 1.128
+++ rde_update.c 27 May 2021 14:10:53 -0000
@@ -371,7 +371,7 @@ up_generate_attr(u_char *buf, int len, s
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, s
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;