bgpd: Make aspath_highest 4-byte compatible for private AS
* bgp_aspath.h: Add BGP_AS_IS_PRIVATE macro.
* bgp_aspath.c: (aspath_highest) use said macro to also ensure 4-byte private
AS range is ignored in calculating highest public ASN.
(aspath_private_as_check) consolidate to use said macro.
Note: Extracted from 'bgpd: Add replace-as option to remove-private-as'
by paul@jakma.org.
diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c
index 8c87d17..3fd359c 100644
--- a/bgpd/bgp_aspath.c
+++ b/bgpd/bgp_aspath.c
@@ -475,9 +475,8 @@
while (seg)
{
for (i = 0; i < seg->length; i++)
- if (seg->as[i] > highest
- && (seg->as[i] < BGP_PRIVATE_AS_MIN
- || seg->as[i] > BGP_PRIVATE_AS_MAX))
+ if (seg->as[i] > highest
+ && !BGP_AS_IS_PRIVATE(seg->as[i]))
highest = seg->as[i];
seg = seg->next;
}
@@ -1280,10 +1279,7 @@
for (i = 0; i < seg->length; i++)
{
- if ( (seg->as[i] < BGP_PRIVATE_AS_MIN)
- || (seg->as[i] > BGP_PRIVATE_AS_MAX &&
- seg->as[i] < BGP_PRIVATE_AS4_MIN)
- || (seg->as[i] > BGP_PRIVATE_AS4_MAX))
+ if (!BGP_AS_IS_PRIVATE(seg->as[i]))
return 0;
}
seg = seg->next;