Skip to content

Commit

Permalink
Be sure RFC8950 is not allowed on BIRD 1.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pierky committed Feb 28, 2024
1 parent 2fb8e8b commit 08eabb9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
29 changes: 22 additions & 7 deletions pierky/arouteserver/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,13 @@ def _are_there_32bit_clients(self):
return True
return False

def _get_rfc8950_clients(self):
res = []
for client in self.cfg_clients.cfg["clients"]:
if client["cfg"]["rfc8950"]:
res.append(client["ip"])
return res

def enrich_config(self):
# Unique ASNs from clients list.
clients_asns = {}
Expand Down Expand Up @@ -1023,6 +1030,18 @@ def validate_bgpspeaker_specific_configuration(self):
):
res = False

if version.parse(self.target_version) < version.parse("2.0"):
rfc8950_clients = self._get_rfc8950_clients()
cnt = len(rfc8950_clients)
if rfc8950_clients:
raise BuilderError(
"RFC8950 is not supported on BIRD 1.x, but it is "
"enabled for the following clients: {}{}.".format(
", ".join(rfc8950_clients[:3]),
"" if cnt <= 3 else " and {} more".format(cnt - 3)
)
)

return res

def _include_local_file(self, local_file_id):
Expand Down Expand Up @@ -1101,7 +1120,6 @@ def validate_bgpspeaker_specific_configuration(self):
add_path_clients = []
max_prefix_action_clients = []
max_prefix_count_rejected_routes_clients = []
rfc8950_clients = []
for client in self.cfg_clients.cfg["clients"]:
if client["cfg"]["add_path"]:
add_path_clients.append(client["ip"])
Expand All @@ -1115,9 +1133,6 @@ def validate_bgpspeaker_specific_configuration(self):
if not max_prefix_count_rejected_routes:
max_prefix_count_rejected_routes_clients.append(client["ip"])

if client["cfg"]["rfc8950"]:
rfc8950_clients.append(client["ip"])

if add_path_clients and \
version.parse(self.target_version) < version.parse("7.5"):

Expand Down Expand Up @@ -1162,14 +1177,14 @@ def validate_bgpspeaker_specific_configuration(self):
):
res = False

rfc8950_clients = self._get_rfc8950_clients()
if rfc8950_clients:
clients = rfc8950_clients
cnt = len(clients)
cnt = len(rfc8950_clients)
if not self.process_compatibility_issue(
"rfc8950",
"RFC8950 not supported by OpenBGPD but "
"enabled for the following clients: {}{}.".format(
", ".join(clients[:3]),
", ".join(rfc8950_clients[:3]),
"" if cnt <= 3 else " and {} more".format(cnt - 3)
)
):
Expand Down
22 changes: 22 additions & 0 deletions tests/cli
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ EOF
# ---------------------------------------------
# Build and validate configs

# RFC8950
reset
GENERAL="tests/var/general.yml"
cat <<EOF >$GENERAL
cfg:
rs_as: 99999999
router_id: "192.0.2.2"
rfc8950: True
EOF
TITLE="RFC8950 support, BIRD 1.x (must fail)"
EXP_ERR="RFC8950 is not supported on BIRD 1.x"

SUB_TEST="$LINENO"
build_cmd "bird" \
--target-ver 1.6.8 \
--ip-ver 4 | must_contain "${EXP_ERR}"

TITLE="RFC8950 support, BIRD 2.x (must succeed)"
SUB_TEST="$LINENO"
build_cmd "bird" \
--target-ver ${BIRD2_LATEST_VER} | must_not_contain "${EXP_ERR}"

# Multiple router_id
reset
GENERAL="tests/var/general.yml"
Expand Down

0 comments on commit 08eabb9

Please sign in to comment.