From 0e4490fc0651f92947f57b455cb6e9de56b57143 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Mon, 16 Jan 2023 14:20:07 +0000 Subject: [PATCH] Make 'any' a reserved name for prefixlists --- docs/config-guide.md | 2 +- vppcfg/config/prefixlist.py | 6 ++++++ vppcfg/unittest/yaml/error-prefixlist1.yaml | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 vppcfg/unittest/yaml/error-prefixlist1.yaml diff --git a/docs/config-guide.md b/docs/config-guide.md index 3beaaac..2f40390 100644 --- a/docs/config-guide.md +++ b/docs/config-guide.md @@ -363,7 +363,7 @@ interfaces: This construct allows to enumerate a list of IPv4 or IPv6 host addresses and/or networks. Each prefixlist has a name which consists of anywhere between 1 and 56 characters, and it must start -with a letter. The syntax is straight forward: +with a letter. The prefixlist name `any` is reserved. The syntax is straight forward: * ***description***: A string, no longer than 64 characters, and excluding the single quote ' and double quote ". This string is currently not used anywhere, and serves for enduser diff --git a/vppcfg/config/prefixlist.py b/vppcfg/config/prefixlist.py index 8160b60..bd8192e 100644 --- a/vppcfg/config/prefixlist.py +++ b/vppcfg/config/prefixlist.py @@ -113,6 +113,12 @@ def validate_prefixlists(yaml): for plname, pl in yaml["prefixlists"].items(): logger.debug(f"prefixlist {plname}: {pl}") + if plname in ["any"]: + ## Note: ACL 'source' and 'destination', when they are empty, will resolve + ## to 'any', and can thus never refer to a prefixlist called 'any'. + msgs.append(f"prefixlist {plname} is a reserved name") + result = False + members = 0 for pl_member in pl["members"]: members += 1 diff --git a/vppcfg/unittest/yaml/error-prefixlist1.yaml b/vppcfg/unittest/yaml/error-prefixlist1.yaml new file mode 100644 index 0000000..e000d9c --- /dev/null +++ b/vppcfg/unittest/yaml/error-prefixlist1.yaml @@ -0,0 +1,18 @@ +test: + description: "Some prefixlist names are reserved" + errors: + expected: + - "prefixlist any is a reserved name" + count: 1 +--- +prefixlists: + any: + description: "any is a reserved name" + members: + - 192.0.2.1 + - 192.0.2.0/24 + v6only: + members: + - 2001:db8::1 + - 2001:db8::/64 + - 2001:db8::/48