Skip to content

Commit

Permalink
ixgbe: Add basic tests for Double VLAN mode
Browse files Browse the repository at this point in the history
There are two basic deployment scenarious we test:

  o Stacked VLANs on top of real network device
  o Stacked VLANs on top of MACVLAN network device

Test environment consists from single host with multi-core CPU (we used
4 cores) and one dual port Intel (R) 10 GbE NIC based on 82599+ chip.
Ports are looped together using DAC (Direct Attach Cable). Network
devices representing these ports are kept in initial network namespace,
while VLANs and MACVLANs are put into different network namespaces (pc10
and pc20).

Environment initialization and finalization is done by setup.sh script
according to given configuration file:

  o vlan.conf for VLANs on top of real network devices and
  o macvlan.conf for VLANs on top of MACVLAN.

It is expected that irqbalance(1) service running and configured with
--deepestcache=2 and --hintpolicy=exact to configure MSI-X vectors IRQs
affinity according to their /proc/irq/<vector_irq>/affinity_hint. With
this configuration there is no need to manually set IRQ affinity for
packet receive. To monitor interrupts distribution one can use
watch-proc-interrupts.sh script.

On transmit queue selected by XPS mechanism and CPU affinity configure
by the driver (see cat /sys/class/net/<real_dev>/queues/tx-*/xps_cpus
for configuration on your system).

To generate double tagged frames pktgen module is used and pktgen.sh
script configures real network device for transmit. By default when
MAC address isn't specified frames are sent to broadcast address, but
if desired destination address could be specified on command line.

Confguration for RHEL6,7 and their derivates (i.e. CentOS) and Debian7
provided in os-specific-network-config/ subdirectory. Replace templates
<x_enXX_mac_addr> with real NIC mac addresses.

Tested on following distros:

  1) CentOS 6.9 (kernel 2.6.32, iproute-3.3 see README file), kernel
     may crash for VLANs on top of real devices (vlan.conf)
  2) CentOS 7.4 (kernel 3.10, iproute 3.10)
  3) Debian 7 (kernel 3.2, iproute-20120521)
  4) Ubuntu 16.04 (kernel 4.4.0, 4.3.0-1ubuntu3.16.04)

Signed-off-by: Serhey Popovych <[email protected]>
  • Loading branch information
serhepopovych committed Feb 15, 2024
1 parent 3269ddc commit 3ff3c64
Show file tree
Hide file tree
Showing 18 changed files with 602 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

Note for RHEL6/CentOS6/SL6
--------------------------

In RHEL6 and it's derivates (e.g CentOS, Scientific Linux) iproute package does
not have netns subcommand while kernel supports network namespaces. To overcome
this limitation you can rebuild (e.g. using mock) iproute-3.3.0-2.fc17.src.rpm
from Fedora 17 and install on target system.

Note that even with ip-netns(8) subcommand support kernel does not support
moving real network devices to network namespace other than initial: create
vlans in network namespace for */vlan.conf tests not moving real ones.
38 changes: 38 additions & 0 deletions tests/ixgbe/macvlan.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

# This configuration file assumes two NICs available on host and looped together

# Module to load
declare -r MODULE='ixgbe'

# Network namespaces to create
declare -ar NETNS_NAMES=(
'pc10'
'pc20'
)

# Real network device names
declare -ar LOWERDEVS=(
'en10'
'en20'
)

# MACVLAN network device names
declare -ar UPPERDEVS=(
'mv10'
'mv20'
)

# MAC addresses for UPPERDEVS
declare -ar UPPERMACS=(
'02:0a:fe:ed:ca:fe'
'02:0a:fe:ed:c0:de'
)

# Last octet for IP address on UPPERDEVS
declare -ar UPPERIPAS=(
'10'
'20'
)

# Template for IP address on UPPERDEVS
declare -r IPA_TEMPL='10.%u.%u.%u/24'
38 changes: 38 additions & 0 deletions tests/ixgbe/vlan.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

# This configuration file assumes two NICs available on host and looped together

# Module to load
declare -r MODULE='ixgbe'

# Network namespaces to create
declare -ar NETNS_NAMES=(
'pc10'
'pc20'
)

# Real network device names
declare -ar LOWERDEVS=(
'en10'
'en20'
)

# MACVLAN network device names
declare -ar UPPERDEVS=(
'en10' # Skip intermediate MACVLAN
'en20' # Skip intermediate MACVLAN
)

# MAC addresses for UPPERDEVS
declare -ar UPPERMACS=(
'' # Inherited from lowerdev
'' # Inherited from lowerdev
)

# Last octet for IP address on UPPERDEVS
declare -ar UPPERIPAS=(
'10'
'20'
)

# Template for IP address on UPPERDEVS
declare -r IPA_TEMPL='10.%u.%u.%u/24'
128 changes: 128 additions & 0 deletions tests/libcfg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
#!/bin/bash -xe

[ -n "$__included_libcfg_sh" ] && return
declare -r __included_libcfg_sh=1

# Prepare environment, see how we've called and check arguments

# Usage: fatal [<fmt> [...]]
fatal()
{
local -i rc=$?
local fmt="${1:?missing 1st argument to \"$FUNCNAME\" (fmt)}"
shift
local fd

[ $rc -eq 0 ] && fd=1 || fd=2
printf -- "$fmt" "$@" >>"$fd"

exit $rc
}
declare -fr fatal

# program invocation name short
[ -n "$prog_name" ] || declare prog_name="${0##*/}"
declare -r prog_name

# program directory
[ -n "$prog_dir" ] || declare prog_dir="${0%/*}"
declare -r prog_dir

# Requires root privileges to run
[ $UID -eq 0 ] ||
fatal 'root (uid: 0) privileges required, but uid is %u\n' $UID

## Source configuration file

# Usage: test_fsr <file>
test_fsr()
{
local file="${1:?missing 1st argument to \"$FUNCNAME\" (file)}"

# Configuration file is:
#
# 1) regular file (i.e. not socket, fifo, device, directory)
# 2) has size greather than zero
# 3) readable by current user
#
test -f "$file" -a \
-s "$file" -a \
-r "$file"
}
declare -fr test_fsr

declare config
declare cfg="$1"

# First try config in same directory as script
config="$prog_dir/$cfg"
if ! test_fsr "$config"; then
# Next try config specified on command line
config="$cfg"
test_fsr "$config" ||
fatal 'missing, empty or unreadable config file\n'
fi

# Do not search for configs in "$PATH"
declare sourcepath_save="$(shopt -p sourcepath)"
shopt -u sourcepath

source "$config" ||
fatal 'cannot source configuration file %s\n' "$config"

eval "$sourcepath_save"

# Check for configuration file data consistency
declare -ir NETNS_NR=${#NETNS_NAMES[@]}

[ $NETNS_NR -gt 0 ] ||
fatal 'number of network namespaces in NETNS_NAMES must be > 0\n'

declare -i LOWERDEVS_NR=${#LOWERDEVS[@]}
[ $NETNS_NR -eq $LOWERDEVS_NR ] ||
usage 'number of %s(%u) is not the same as number of NETNS(%u)\n' \
'LOWERDEVS' $NETNS_NR $LOWERDEVS_NR

declare -i UPPERDEVS_NR=${#UPPERDEVS[@]}
[ $NETNS_NR -eq $UPPERDEVS_NR ] ||
usage 'number of %s(%u) is not the same as number of NETNS(%u)\n' \
'UPPERDEVS' $NETNS_NR $UPPERDEVS_NR

declare -i UPPERMACS_NR=${#UPPERMACS[@]}
[ $NETNS_NR -eq $UPPERMACS_NR ] ||
usage 'number of %s(%u) is not the same as number of NETNS(%u)\n' \
'UPPERMACS' $NETNS_NR $UPPERMACS_NR

declare -i UPPERIPAS_NR=${#UPPERIPAS[@]}
[ $NETNS_NR -eq $UPPERIPAS_NR ] ||
usage 'number of %s(%u) is not the same as number of NETNS(%u)\n' \
'UPPERIPAS' $NETNS_NR $UPPERIPAS_NR

for ((i = 0; i < NETNS_NR; i++)); do
[ -n "${NETNS_NAMES[$i]}" ] ||
usage '%s cannot be empty (index: %u)\n' \
'netns name' $i
[ -n "${LOWERDEVS[$i]}" ] ||
usage '%s cannot be empty (index: %u)\n' \
'upper device name' $i
[ -n "${UPPERDEVS[$i]}" ] ||
usage '%s cannot be empty (index: %u)\n' \
'lower device name' $i
# MACs can be empty: either random is used in case of MACVLAN or
# inherited from parent network device in case of VLAN
[ -n "${UPPERIPAS[$i]}" ] ||
usage '%s cannot be empty (index: %u)\n' \
'ip address' $i
done

[ -n "$MODULE" ] ||
usage '%s must be specified\n' 'MODULE'

[ -n "$IPA_TEMPL" ] ||
usage '%s must be specified\n' 'IPA_TEMPL'

# Cleanup environment
unset i cfg config sourcepath_save
unset LOWERDEVS_NR UPPERDEVS_NR UPPERMACS_NR UPPERIPAS_NR

:
1 change: 1 addition & 0 deletions tests/os-specific-network-config/centos6
1 change: 1 addition & 0 deletions tests/os-specific-network-config/centos7
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# To install these rules to system replace all <x_enXX_mac_addr> templates
# with real MAC address values and issue command:
#
# cat <this_file> >>/etc/udev/rules.d/70-persistent-net.rules
#

# ixgbe
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<x_en10_mac_addr>", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="*", NAME="en10"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<x_en20_mac_addr>", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="*", NAME="en20"

# igb
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<x_en30_mac_addr>", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="*", NAME="en30"
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="<x_en40_mac_addr>", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="*", NAME="en40"
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ONBOOT=yes
UUID=1e3c3f0b-e63a-4a54-a045-c085f4426eb6
NAME=en10
DEVICE=en10
TYPE=Ethernet
HWADDR=<x_en10_mac_addr>
BOOTPROTO=none
MTU=1504
#ETHTOOL_OPTS='--set-priv-flags en10 vlan-stag-rx on'

# IPv4
NOZEROCONF=yes
ARPCHECK=no

# IPv6
IPV6INIT=no
IPV6FORWARDING=no
IPV6_AUTOCONF=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ONBOOT=yes
UUID=4586a51d-13af-43c0-8463-230cc2e4cd1b
NAME=en20
DEVICE=en20
TYPE=Ethernet
HWADDR=<x_en20_mac_addr>
BOOTPROTO=none
MTU=1504
#ETHTOOL_OPTS='--set-priv-flags en20 vlan-stag-rx on'

# IPv4
NOZEROCONF=yes
ARPCHECK=no

# IPv6
IPV6INIT=no
IPV6FORWARDING=no
IPV6_AUTOCONF=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ONBOOT=yes
UUID=ff6636ac-d017-4dbe-bc7c-1e86e5703f2a
NAME=en30
DEVICE=en30
TYPE=Ethernet
HWADDR=<x_en30_mac_addr>
BOOTPROTO=none
MTU=1504
#ETHTOOL_OPTS='--set-priv-flags en30 vlan-stag-rx on'

# IPv4
NOZEROCONF=yes
ARPCHECK=no

# IPv6
IPV6INIT=no
IPV6FORWARDING=no
IPV6_AUTOCONF=no
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ONBOOT=yes
UUID=f73f2cb9-4e2e-4b31-ab4b-57e369eaca10
NAME=en40
DEVICE=en40
TYPE=Ethernet
HWADDR=<x_en40_mac_addr>
BOOTPROTO=none
MTU=1504
#ETHTOOL_OPTS='--set-priv-flags en40 vlan-stag-rx on'

# IPv4
NOZEROCONF=yes
ARPCHECK=no

# IPv6
IPV6INIT=no
IPV6FORWARDING=no
IPV6_AUTOCONF=no
1 change: 1 addition & 0 deletions tests/os-specific-network-config/rhel7/etc/sysconfig
Empty file.
Empty file.
1 change: 1 addition & 0 deletions tests/os-specific-network-config/ubuntu16.04
Loading

0 comments on commit 3ff3c64

Please sign in to comment.