summaryrefslogtreecommitdiff
path: root/src/validators/vrf-name
diff options
context:
space:
mode:
Diffstat (limited to 'src/validators/vrf-name')
-rwxr-xr-xsrc/validators/vrf-name9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/validators/vrf-name b/src/validators/vrf-name
index 29167c635..b56ebd036 100755
--- a/src/validators/vrf-name
+++ b/src/validators/vrf-name
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2020 VyOS maintainers and contributors
+# Copyright VyOS maintainers and contributors <maintainers@vyos.io>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -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):