mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
traffic-pacing-edt: script for VLAN setup
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This commit is contained in:
65
traffic-pacing-edt/testlab_vlan_setup.sh
Executable file
65
traffic-pacing-edt/testlab_vlan_setup.sh
Executable file
@@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Testlab setup script for VLAN Q-in-Q (double tagged VLAN) config.
|
||||
#
|
||||
# Author: Jesper Dangaaard Brouer <netoptimizer@brouer.com>
|
||||
# License: GPLv2
|
||||
#
|
||||
basedir=`dirname $0`
|
||||
source ${basedir}/functions.sh
|
||||
|
||||
root_check_run_with_sudo "$@"
|
||||
|
||||
# Use common parameters
|
||||
source ${basedir}/parameters.sh
|
||||
|
||||
export IP=/sbin/ip
|
||||
function ip() {
|
||||
echo $IP "$@"
|
||||
$IP "$@"
|
||||
}
|
||||
|
||||
function create_vlan_device() {
|
||||
local vlan=${1}
|
||||
local device=${2:-$DEV}
|
||||
shift 2
|
||||
|
||||
if [[ -z "$vlan" ]]; then
|
||||
err 2 "Missing VLAN is as input"
|
||||
fi
|
||||
|
||||
ip link add link "$device" name ${device}.${vlan} type vlan id ${vlan}
|
||||
ip link set ${device}.${vlan} up
|
||||
}
|
||||
|
||||
function delete_vlan_device() {
|
||||
local vlan=${1}
|
||||
local device=${2:-$DEV}
|
||||
shift 2
|
||||
|
||||
if [[ -z "$vlan" ]]; then
|
||||
err 2 "Missing VLAN is as input"
|
||||
fi
|
||||
|
||||
ip link del ${device}.${vlan}
|
||||
}
|
||||
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
err 3 "Missing arg#1 for outer vlan"
|
||||
fi
|
||||
OUTER=$1
|
||||
|
||||
if [[ -z "$2" ]]; then
|
||||
err 3 "Missing arg#2 for inner vlan"
|
||||
fi
|
||||
INNER=$2
|
||||
|
||||
if [[ -n $REMOVE ]]; then
|
||||
delete_vlan_device $INNER ${DEV}.${OUTER}
|
||||
delete_vlan_device $OUTER $DEV
|
||||
exit 0
|
||||
fi
|
||||
|
||||
create_vlan_device $OUTER $DEV
|
||||
create_vlan_device $INNER ${DEV}.${OUTER}
|
Reference in New Issue
Block a user