-/* $OpenBSD: parse.y,v 1.456 2024/03/18 14:54:52 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.457 2024/03/20 09:35:46 claudio Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
uint16_t afi;
if ($3 == SAFI_NONE) {
- for (aid = 0; aid < AID_MAX; aid++) {
+ for (aid = AID_MIN; aid < AID_MAX; aid++) {
if (aid2afi(aid, &afi, &safi) == -1 ||
afi != $2)
continue;
int8_t *ap = curpeer->conf.capabilities.add_path;
uint8_t i;
- for (i = 0; i < AID_MAX; i++)
+ for (i = AID_MIN; i < AID_MAX; i++)
if ($4)
- *ap++ |= CAPA_AP_RECV;
+ ap[i] |= CAPA_AP_RECV;
else
- *ap++ &= ~CAPA_AP_RECV;
+ ap[i] &= ~CAPA_AP_RECV;
}
| ANNOUNCE ADDPATH SEND STRING addpathextra addpathmax {
int8_t *ap = curpeer->conf.capabilities.add_path;
"for 'add-path send no'");
YYERROR;
}
- for (i = 0; i < AID_MAX; i++)
- *ap++ &= ~CAPA_AP_SEND;
- break;
+ mode = ADDPATH_EVAL_NONE;
} else if (!strcmp($4, "all")) {
free($4);
if ($5 != 0 || $6 != 0) {
free($4);
YYERROR;
}
- for (i = 0; i < AID_MAX; i++)
- *ap++ |= CAPA_AP_SEND;
+ for (i = AID_MIN; i < AID_MAX; i++) {
+ if (mode != ADDPATH_EVAL_NONE)
+ ap[i] |= CAPA_AP_SEND;
+ else
+ ap[i] &= ~CAPA_AP_SEND;
+ }
curpeer->conf.eval.mode = mode;
curpeer->conf.eval.extrapaths = $5;
curpeer->conf.eval.maxpaths = $6;
alloc_peer(void)
{
struct peer *p;
- uint8_t i;
if ((p = calloc(1, sizeof(struct peer))) == NULL)
fatal("new_peer");
p->conf.distance = 1;
p->conf.export_type = EXPORT_UNSET;
p->conf.announce_capa = 1;
- for (i = 0; i < AID_MAX; i++)
- p->conf.capabilities.mp[i] = 0;
p->conf.capabilities.refresh = 1;
p->conf.capabilities.grestart.restart = 1;
p->conf.capabilities.as4byte = 1;
-/* $OpenBSD: rde.c,v 1.623 2024/02/22 06:45:22 miod Exp $ */
+/* $OpenBSD: rde.c,v 1.624 2024/03/20 09:35:46 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
log_warnx("%s: wrong imsg len", __func__);
break;
}
- if (aid >= AID_MAX) {
+ if (aid < AID_MIN || aid >= AID_MAX) {
log_warnx("%s: bad AID", __func__);
break;
}
log_warnx("route refresh: wrong imsg len");
break;
}
- if (rr.aid >= AID_MAX) {
+ if (rr.aid < AID_MIN || rr.aid >= AID_MAX) {
log_peer_warnx(&peer->conf,
"route refresh: bad AID %d", rr.aid);
break;
continue;
if (peer->throttled)
continue;
- for (aid = 0; aid < AID_MAX; aid++) {
+ for (aid = AID_MIN; aid < AID_MAX; aid++) {
if (!RB_EMPTY(&peer->updates[aid]) ||
!RB_EMPTY(&peer->withdraws[aid]))
return 1;
peer->reconf_out = 0;
} else if (peer->export_type == EXPORT_DEFAULT_ROUTE) {
/* just resend the default route */
- for (aid = 0; aid < AID_MAX; aid++) {
+ for (aid = AID_MIN; aid < AID_MAX; aid++) {
if (peer->capa.mp[aid])
up_generate_default(peer, aid);
}
RECONF_RELOAD;
} else if (peer->reconf_rib) {
/* dump the full table to neighbors that changed rib */
- for (aid = 0; aid < AID_MAX; aid++) {
+ for (aid = AID_MIN; aid < AID_MAX; aid++) {
if (peer->capa.mp[aid])
peer_dump(peer, aid);
}
-/* $OpenBSD: session.c,v 1.463 2024/02/19 10:15:35 job Exp $ */
+/* $OpenBSD: session.c,v 1.464 2024/03/20 09:35:46 claudio Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
void session_capa_ann_none(struct peer *);
int session_capa_add(struct ibuf *, uint8_t, uint8_t);
int session_capa_add_mp(struct ibuf *, uint8_t);
-int session_capa_add_afi(struct peer *, struct ibuf *, uint8_t, uint8_t);
+int session_capa_add_afi(struct ibuf *, uint8_t, uint8_t);
struct bgp_msg *session_newmsg(enum msg_type, uint16_t);
int session_sendmsg(struct bgp_msg *, struct peer *);
void session_open(struct peer *);
}
int
-session_capa_add_afi(struct peer *p, struct ibuf *b, uint8_t aid,
- uint8_t flags)
+session_capa_add_afi(struct ibuf *b, uint8_t aid, uint8_t flags)
{
u_int errs = 0;
uint16_t afi;
}
/* multiprotocol extensions, RFC 4760 */
- for (i = 0; i < AID_MAX; i++)
+ for (i = AID_MIN; i < AID_MAX; i++)
if (p->capa.ann.mp[i]) { /* 4 bytes data */
errs += session_capa_add(opb, CAPA_MP, 4);
errs += session_capa_add_mp(opb, i);
int rst = 0;
uint16_t hdr = 0;
- for (i = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN; i < AID_MAX; i++) {
if (p->capa.neg.grestart.flags[i] & CAPA_GR_RESTARTING)
rst++;
}
}
/* advertisement of multiple paths, RFC7911 */
- if (p->capa.ann.add_path[0]) { /* variable */
+ if (p->capa.ann.add_path[AID_MIN]) { /* variable */
uint8_t aplen;
if (mpcapa)
if (mpcapa) {
for (i = AID_MIN; i < AID_MAX; i++) {
if (p->capa.ann.mp[i]) {
- errs += session_capa_add_afi(p, opb,
+ errs += session_capa_add_afi(opb,
i, p->capa.ann.add_path[i]);
}
}
} else { /* AID_INET */
- errs += session_capa_add_afi(p, opb, AID_INET,
+ errs += session_capa_add_afi(opb, AID_INET,
p->capa.ann.add_path[AID_INET]);
}
}
if (!(p->capa.neg.refresh || p->capa.neg.enhanced_rr))
return (-1);
- for (i = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN; i < AID_MAX; i++) {
if (p->capa.neg.mp[i] != 0)
session_rrefresh(p, i, ROUTE_REFRESH_REQUEST);
}
timer_set(&p->timers, Timer_RestartTimeout,
p->capa.neg.grestart.timeout);
- for (i = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN; i < AID_MAX; i++) {
if (p->capa.neg.grestart.flags[i] & CAPA_GR_PRESENT) {
if (imsg_rde(IMSG_SESSION_STALE, p->conf.id,
&i, sizeof(i)) == -1)
{
uint8_t i;
- for (i = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN; i < AID_MAX; i++) {
/*
* Only flush if the peer is restarting and the timeout fired.
* In all other cases the session was already flushed when the
uint8_t capa_code;
uint8_t capa_len;
size_t reason_len;
- uint8_t i;
/* just log */
p = peer->rbuf->rptr;
datalen -= capa_len;
switch (capa_code) {
case CAPA_MP:
- for (i = 0; i < AID_MAX; i++)
- peer->capa.ann.mp[i] = 0;
+ memset(peer->capa.ann.mp, 0,
+ sizeof(peer->capa.ann.mp));
log_peer_warnx(&peer->conf,
"disabling multiprotocol capability");
break;
(p->capa.ann.refresh && p->capa.peer.refresh) != 0;
p->capa.neg.enhanced_rr =
(p->capa.ann.enhanced_rr && p->capa.peer.enhanced_rr) != 0;
-
p->capa.neg.as4byte =
(p->capa.ann.as4byte && p->capa.peer.as4byte) != 0;
/* MP: both side must agree on the AFI,SAFI pair */
- for (i = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN; i < AID_MAX; i++) {
if (p->capa.ann.mp[i] && p->capa.peer.mp[i])
p->capa.neg.mp[i] = 1;
else
* supporting graceful restart.
*/
- for (i = 0; i < AID_MAX; i++) {
+ for (i = AID_MIN; i < AID_MAX; i++) {
int8_t negflags;
/* disable GR if the AFI/SAFI is not present */
if (p->capa.ann.grestart.restart == 0)
p->capa.neg.grestart.restart = 0;
-
/*
* ADD-PATH: set only those bits where both sides agree.
* For this compare our send bit with the recv bit from the peer
* and vice versa.
* The flags are stored from this systems view point.
+ * At index 0 the flags are set if any per-AID flag is set.
*/
memset(p->capa.neg.add_path, 0, sizeof(p->capa.neg.add_path));
- if (p->capa.ann.add_path[0]) {
- for (i = AID_MIN; i < AID_MAX; i++) {
- if ((p->capa.ann.add_path[i] & CAPA_AP_RECV) &&
- (p->capa.peer.add_path[i] & CAPA_AP_SEND)) {
- p->capa.neg.add_path[i] |= CAPA_AP_RECV;
- p->capa.neg.add_path[0] |= CAPA_AP_RECV;
- }
- if ((p->capa.ann.add_path[i] & CAPA_AP_SEND) &&
- (p->capa.peer.add_path[i] & CAPA_AP_RECV)) {
- p->capa.neg.add_path[i] |= CAPA_AP_SEND;
- p->capa.neg.add_path[0] |= CAPA_AP_SEND;
- }
+ for (i = AID_MIN; i < AID_MAX; i++) {
+ if ((p->capa.ann.add_path[i] & CAPA_AP_RECV) &&
+ (p->capa.peer.add_path[i] & CAPA_AP_SEND)) {
+ p->capa.neg.add_path[i] |= CAPA_AP_RECV;
+ p->capa.neg.add_path[0] |= CAPA_AP_RECV;
+ }
+ if ((p->capa.ann.add_path[i] & CAPA_AP_SEND) &&
+ (p->capa.peer.add_path[i] & CAPA_AP_RECV)) {
+ p->capa.neg.add_path[i] |= CAPA_AP_SEND;
+ p->capa.neg.add_path[0] |= CAPA_AP_SEND;
}
}
log_warnx("no such peer: id=%u", peerid);
break;
}
- if (rr.aid >= AID_MAX)
+ if (rr.aid < AID_MIN || rr.aid >= AID_MAX)
fatalx("IMSG_REFRESH: bad AID");
session_rrefresh(p, rr.aid, rr.subtype);
break;
log_warnx("no such peer: id=%u", peerid);
break;
}
- if (aid >= AID_MAX)
+ if (aid < AID_MIN || aid >= AID_MAX)
fatalx("IMSG_SESSION_RESTARTED: bad AID");
if (p->capa.neg.grestart.flags[aid] &
CAPA_GR_RESTARTING) {