summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/validators/vrf-name7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/validators/vrf-name b/src/validators/vrf-name
index cc4be2510..b56ebd036 100755
--- a/src/validators/vrf-name
+++ b/src/validators/vrf-name
@@ -24,15 +24,22 @@ if __name__ == '__main__':
vrf = argv[1]
length = len(vrf)
+ # must not exceed Linux Kernel IFNAMSIZ definition
if length not in range(1, 16):
exit(1)
+ # allow only alpha numerical characters, - and _
+ pattern = r'^[A-Za-z0-9_-]+$'
+ if not re.match(pattern, vrf):
+ exit(1)
+
# Treat loopback interface "lo" explicitly. Adding "lo" explicitly to the
# following regex pattern would deny any VRF name starting with lo - thuse
# local-vrf would be illegal - and that we do not want.
if vrf == "lo":
exit(1)
+ # VRF name must not conflict with local interface type prefix
pattern = r'^(?!(bond|br|dum|eth|lan|eno|ens|enp|enx|gnv|ipoe|l2tp|l2tpeth|\
vtun|ppp|pppoe|peth|tun|vti|vxlan|wg|wlan|wwan|\d)\d*(\.\d+)?(v.+)?).*$'
if not re.match(pattern, vrf):