diff options
| author | Kyrylo Yatsenko <hedrok@gmail.com> | 2026-08-18 13:31:16 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-18 13:31:16 +0300 |
| commit | ce8f2d49ea929a5935f162ea05d7c436a04444c0 (patch) | |
| tree | bbb195b1c03ed7e21306191f636c8aea7b2c057b /src/validators/interface-exists | |
| parent | de57cd205cfd846eb1689967af0dccc3f764b22c (diff) | |
| parent | e31c2f6e816a70ae246ab04e07db745a3af31249 (diff) | |
| download | vyos-1x-ce8f2d49ea929a5935f162ea05d7c436a04444c0.tar.gz vyos-1x-ce8f2d49ea929a5935f162ea05d7c436a04444c0.zip | |
Merge pull request #5393 from c-po/interface-no-vrf
xml: T9179: reject VRF names in interface-name constraint
Diffstat (limited to 'src/validators/interface-exists')
| -rwxr-xr-x | src/validators/interface-exists | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/validators/interface-exists b/src/validators/interface-exists new file mode 100755 index 000000000..d78247e1b --- /dev/null +++ b/src/validators/interface-exists @@ -0,0 +1,40 @@ +#!/bin/sh +# +# Copyright (C) VyOS Inc. +# +# 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 +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Passes only if $1 is a net device that exists on the system and is not a +# VRF. Used as a fallback alongside a naming-pattern regex, so a currently +# existing device is accepted as a physical/logical interface only if it is +# not a VRF (VRFs are real net devices but must never be accepted where an +# interface is expected). + +case "$1" in + ""|.|..|*/*) + echo "Error: $1 does not exist" + exit 1 + ;; +esac + +if [ ! -d "/sys/class/net/$1" ]; then + echo "Error: $1 does not exist" + exit 1 +fi + +if ip vrf show "$1" >/dev/null 2>&1; then + echo "Error: $1 is a VRF, not a network interface" + exit 1 +fi + +exit 0 |
