blob: d78247e1b09c6d7269be9c7bb30b6793a2d228ad (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
|