summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/util.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-03-20 09:35:47 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-03-20 09:35:47 +0000
commit10b47e06b9a66bd538e2979cd32287e61d67b312 (patch)
tree9c546a1860cd70f1e6f1458bed87073e5d5ed64b /usr.sbin/bgpd/util.c
parent75a7e046e7dba2363497efaa11c8f99b939a7560 (diff)
Cleanup AID handling.
- Loops over all valid AID should start with AID_MIN and go up to AID_MAX - 1 e.g. for (i = AID_MIN; i < AID_MAX; i++) If for some reason AID_UNSPEC must be handled make that explicit in the for loop. - aid2afi() now returns an error for AID_UNSPEC since there is no valid AFI SAFI combo for AID_UNSPEC. - Add additional checks for AID_MIN where currently only AID_MAX was checked. This affects imsg for route refresh and graceful restart. - Simplify add-path capability handling. Only the negotiated add_path capa sets the flag for AID_UNSPEC to help code to quickly check if any add-path is active. OK tb@
Diffstat (limited to 'usr.sbin/bgpd/util.c')
-rw-r--r--usr.sbin/bgpd/util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/util.c b/usr.sbin/bgpd/util.c
index 0f9e89bc248..db4f5e75765 100644
--- a/usr.sbin/bgpd/util.c
+++ b/usr.sbin/bgpd/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.82 2024/02/22 06:45:22 miod Exp $ */
+/* $OpenBSD: util.c,v 1.83 2024/03/20 09:35:46 claudio Exp $ */
/*
* Copyright (c) 2006 Claudio Jeker <claudio@openbsd.org>
@@ -922,7 +922,7 @@ aid2str(uint8_t aid)
int
aid2afi(uint8_t aid, uint16_t *afi, uint8_t *safi)
{
- if (aid < AID_MAX) {
+ if (aid != AID_UNSPEC && aid < AID_MAX) {
*afi = aid_vals[aid].afi;
*safi = aid_vals[aid].safi;
return (0);
@@ -935,7 +935,7 @@ afi2aid(uint16_t afi, uint8_t safi, uint8_t *aid)
{
uint8_t i;
- for (i = 0; i < AID_MAX; i++)
+ for (i = AID_MIN; i < AID_MAX; i++)
if (aid_vals[i].afi == afi && aid_vals[i].safi == safi) {
*aid = i;
return (0);
@@ -960,7 +960,7 @@ af2aid(sa_family_t af, uint8_t safi, uint8_t *aid)
if (safi == 0) /* default to unicast subclass */
safi = SAFI_UNICAST;
- for (i = 0; i < AID_MAX; i++)
+ for (i = AID_UNSPEC; i < AID_MAX; i++)
if (aid_vals[i].af == af && aid_vals[i].safi == safi) {
*aid = i;
return (0);