]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
selftests: forwarding: lib: Support VLAN devices
authorPetr Machata <petrm@mellanox.com>
Thu, 24 May 2018 14:27:26 +0000 (16:27 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 May 2018 02:26:19 +0000 (22:26 -0400)
Add vlan_create() and vlan_destroy() to manage VLAN netdevices.

Signed-off-by: Petr Machata <petrm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/lib.sh

index 91041c49655baee70bb81b4af326def01a90cdb1..63641ad55074a02ac6523b778db62e1ddefc16ec 100644 (file)
@@ -340,6 +340,31 @@ tunnel_destroy()
        ip link del dev $name
 }
 
+vlan_create()
+{
+       local if_name=$1; shift
+       local vid=$1; shift
+       local vrf=$1; shift
+       local ips=("${@}")
+       local name=$if_name.$vid
+
+       ip link add name $name link $if_name type vlan id $vid
+       if [ "$vrf" != "" ]; then
+               ip link set dev $name master $vrf
+       fi
+       ip link set dev $name up
+       __addr_add_del $name add "${ips[@]}"
+}
+
+vlan_destroy()
+{
+       local if_name=$1; shift
+       local vid=$1; shift
+       local name=$if_name.$vid
+
+       ip link del dev $name
+}
+
 master_name_get()
 {
        local if_name=$1