Created
February 28, 2020 01:09
-
-
Save iMasaruOki/a4e4cf03f4b754cb5d5f17633276a381 to your computer and use it in GitHub Desktop.
similar to "ip vrf exec" for linux kernel 4.9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
EXEC= | |
ARG="$@" | |
VRF=$1 | |
if [ "x$USER" != "xroot" ]; then | |
echo "Root privileges are required for this operation" | |
exit 1 | |
fi | |
ip link show $VRF > /dev/null 2>&1 | |
if [ "$?" != 0 ]; then | |
echo "VRF $VRF does not exist." | |
exit 1 | |
fi | |
ip link show $VRF | grep MASTER > /dev/null 2>&1 | |
if [ "$?" != 0 ]; then | |
echo "$VRF is not VRF." | |
exit 1 | |
fi | |
cgget -r l3mdev.master-device $VRF 2>&1 | grep cannot > /dev/null 2>&1 | |
if [ "$?" = 0 ]; then | |
$EXEC cgcreate -g l3mdev:$VRF | |
fi | |
$EXEC cgset -r l3mdev.master-device=$VRF $VRF | |
$EXEC cgexec -g l3mdev:$ARG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment