bgpd: allow equalityop matching for neighbor-as

benaryorg <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
Putting the code on par with what the man-page implies, this will allow using an equalityop to match neighbor-as.
Rules such as `deny from any transit-as != neighbor-as` thus become feasible.

On the other side `as_compare` in `rde_attr.c` already checks for the operations against a unified variable containing the neighbor at the time.

Please note that the code is untested at time of writing as I do not currently have a development environment for OpenBSD, but the change itself seemed trivial enough to throw it out there in case anyone can test this before I get around to do so.

diff --git usr.sbin/bgpd/parse.y usr.sbin/bgpd/parse.y
index 4b24de688e0..e5054dd2b66 100644
--- usr.sbin/bgpd/parse.y
+++ usr.sbin/bgpd/parse.y
@@ -2762,6 +2762,13 @@ filter_as	: as4number_any		{
  				fatal(NULL);
  			$$->a.flags = AS_FLAG_NEIGHBORAS;
  		}
+		| equalityop NEIGHBORAS {
+			if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
+			    NULL)
+				fatal(NULL);
+			$$->a.op = $1;
+			$$->a.flags = AS_FLAG_NEIGHBORAS;
+		}
  		| equalityop as4number_any	{
  			if (($$ = calloc(1, sizeof(struct filter_as_l))) ==
  			    NULL)
OpenPGP_0xE2F22C5EDF20119D.asc (application/pgp-keys, 912 B)
-----BEGIN PGP PUBLIC KEY BLOCK-----

xjMEZPRnKxYJKwYBBAHaRw8BAQdAAKdlNe0o2M0j1n2xyv8Amf+7ct0odnZp4jEA
X4Y3S4TNHWJlbmFyeW9yZyA8YmluYXJ5QGJlbmFyeS5vcmc+wpwEExYKAEQCGwMF
CQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AWIQSAS2y4rtVh2T2tTcXi
8ixe3yARnQUCZPRoPAIZAQAKCRDi8ixe3yARnY3PAQCuFua4uDblRjF011aWK6KI
0mueNX1gZu+SAzO6myGAKAD/aga/N26m1UFPE3yt1MmC6d/3ALQ4tSeuvIbQ0LDF
JgLNHmJlbmFyeW9yZyA8bm9yZXBseUBiZW5hcnkub3JnPsKZBBMWCgBBFiEEgEts
uK7VYdk9rU3F4vIsXt8gEZ0FAmT0Z2gCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsC
BBYCAwECHgcCF4AACgkQ4vIsXt8gEZ1R/AEApobml/Gwt7WzHGk6gfEqXC22VHT+
/DmGPtxHOmqbm+oBAJ5+Soe1Cy7L4q2lLbIdjf8cVltI0tZhKagIphloCQQNzjgE
ZPRnKxIKKwYBBAGXVQEFAQEHQLK2b+AcWndNAuPN/N0XzVTJ2LakT/KbtncIqq9W
Pa9wAwEIB8J+BBgWCgAmFiEEgEtsuK7VYdk9rU3F4vIsXt8gEZ0FAmT0ZysCGwwF
CQWjmoAACgkQ4vIsXt8gEZ1lZgD9FLHYGE2pziHZxNn9sAQm6O6J3AcRGNDVyLwA
O9EeCbABALup8RDA+W+0pTIpG49QEVxumZXEFjPeczDghwuycpIA
=oM9+
-----END PGP PUBLIC KEY BLOCK-----
OpenPGP_signature.asc (application/pgp-signature, 236 B)
-----BEGIN PGP SIGNATURE-----

wnsEABYIACMWIQSAS2y4rtVh2T2tTcXi8ixe3yARnQUCaiKXkgUDAAAAAAAKCRDi8ixe3yARnRRo
AQD6YlfcvatBNfQhLfLo+38xwkeYryqosflvMaTmUyjcggD/VXxZWSuIQHDdGk2XrFecIotBB0RZ
/NVh6SYLF0IQqwA=
=d9jm
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.