diff options
| author | Daniil Baturin <daniil@vyos.io> | 2026-03-02 08:26:30 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-02 08:26:30 +0000 |
| commit | 4292d2b893f429003b70e8f1cb74986a5f12cf47 (patch) | |
| tree | 392dd6258ad55abdf3166774c688a14ce04fdba6 /src | |
| parent | 3e448bd51685688bdae6ec698a3923cfdeb83689 (diff) | |
| parent | da2349c0eaca742dffa5e271d0d53937ecec9f8f (diff) | |
| download | vyos-1x-4292d2b893f429003b70e8f1cb74986a5f12cf47.tar.gz vyos-1x-4292d2b893f429003b70e8f1cb74986a5f12cf47.zip | |
Merge pull request #5018 from c-po/vrf
vrf: T8320: only allow alpha numerical characters, - and _ as VRF name
Diffstat (limited to 'src')
| -rwxr-xr-x | src/validators/vrf-name | 7 |
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): |
