Skip to content

Commit fd36fd2

Browse files
pmachatakuba-moo
authored andcommitted
selftests: forwarding.config.sample: Move overrides to lib.sh
forwarding.config.sample, net/lib.sh and net/forwarding/lib.sh contain definitions and redefinitions of some of the same variables. The overlap between net/forwarding/lib.sh and forwarding.config.sample is especially large. This duplication is a potential source of confusion and problems. It would be overall less error prone if each variable were defined in one place only. In this patch set, that place is the library itself. Therefore move all comments from forwarding.config.sample to net/forwarding/lib.sh. Move over also a definition of TC_FLAG, which was missing from lib.sh entirely. Additionally, add to lib.sh a default definition of the topology variables. The logic behind this is that forgetting to specify forwarding.config was a frequent source of frustration for the selftest users. But really, most of the time the default veth based topology is just fine. We considered just sourcing forwarding.config.sample instead if forwarding.config is not available, but this is a cleaner solution. That means the syntax of the forwarding.config.sample override has to change to an array assignment, so that the whole variable is overwritten, not just individual keys, which could leave the value of some keys unchanged. Do the same in lib.sh for any cut'n'pasters out there. The config file is then given a sort of carte blanche to redefine whatever variables it sees fit from the libraries. This is described in a comment in the file. Only a handful of variables are left behind, to illustrate the customization. The fact that the variables are now missing from forwarding.config.sample, and therefore would miss from forwarding.config derived from that file as well, should not change anything. This is just the sample file. Users that keep their own forwarding.config would retain it as before. The only observable change is introduction of TC_FLAG to lib.sh, because now the filters would not be attempted to install to HW datapath. For veth pairs this does not change anything. For HW deployments, users presumably have forwarding.config with this value overridden. Signed-off-by: Petr Machata <[email protected]> Reviewed-by: Benjamin Poirier <[email protected]> Link: https://lore.kernel.org/r/b9b8a11a22821a7aa532211ff461a34f596e26bf.1711464583.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fa61e9a commit fd36fd2

File tree

2 files changed

+74
-48
lines changed

2 files changed

+74
-48
lines changed

tools/testing/selftests/net/forwarding/forwarding.config.sample

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,51 +3,28 @@
33

44
##############################################################################
55
# Topology description. p1 looped back to p2, p3 to p4 and so on.
6-
declare -A NETIFS
76

8-
NETIFS[p1]=veth0
9-
NETIFS[p2]=veth1
10-
NETIFS[p3]=veth2
11-
NETIFS[p4]=veth3
12-
NETIFS[p5]=veth4
13-
NETIFS[p6]=veth5
14-
NETIFS[p7]=veth6
15-
NETIFS[p8]=veth7
16-
NETIFS[p9]=veth8
17-
NETIFS[p10]=veth9
7+
NETIFS=(
8+
[p1]=veth0
9+
[p2]=veth1
10+
[p3]=veth2
11+
[p4]=veth3
12+
[p5]=veth4
13+
[p6]=veth5
14+
[p7]=veth6
15+
[p8]=veth7
16+
[p9]=veth8
17+
[p10]=veth9
18+
)
1819

1920
# Port that does not have a cable connected.
2021
NETIF_NO_CABLE=eth8
2122

2223
##############################################################################
23-
# Defines
24+
# In addition to the topology-related variables, it is also possible to override
25+
# in this file other variables that net/lib.sh, net/forwarding/lib.sh or other
26+
# libraries or selftests use. E.g.:
2427

25-
# IPv4 ping utility name
26-
PING=ping
27-
# IPv6 ping utility name. Some distributions use 'ping' for IPv6.
2828
PING6=ping6
29-
# Packet generator. Some distributions use 'mz'.
3029
MZ=mausezahn
31-
# mausezahn delay between transmissions in microseconds.
32-
MZ_DELAY=0
33-
# Time to wait after interfaces participating in the test are all UP
3430
WAIT_TIME=5
35-
# Whether to pause on failure or not.
36-
PAUSE_ON_FAIL=no
37-
# Whether to pause on cleanup or not.
38-
PAUSE_ON_CLEANUP=no
39-
# Type of network interface to create
40-
NETIF_TYPE=veth
41-
# Whether to create virtual interfaces (veth) or not
42-
NETIF_CREATE=yes
43-
# Timeout (in seconds) before ping exits regardless of how many packets have
44-
# been sent or received
45-
PING_TIMEOUT=5
46-
# Minimum ageing_time (in centiseconds) supported by hardware
47-
LOW_AGEING_TIME=1000
48-
# Flag for tc match, supposed to be skip_sw/skip_hw which means do not process
49-
# filter by software/hardware
50-
TC_FLAG=skip_hw
51-
# IPv6 traceroute utility name.
52-
TROUTE6=traceroute6
53-

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 59 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,83 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
##############################################################################
5+
# Topology description. p1 looped back to p2, p3 to p4 and so on.
6+
7+
declare -A NETIFS=(
8+
[p1]=veth0
9+
[p2]=veth1
10+
[p3]=veth2
11+
[p4]=veth3
12+
[p5]=veth4
13+
[p6]=veth5
14+
[p7]=veth6
15+
[p8]=veth7
16+
[p9]=veth8
17+
[p10]=veth9
18+
)
19+
20+
# Port that does not have a cable connected.
21+
: "${NETIF_NO_CABLE:=eth8}"
22+
423
##############################################################################
524
# Defines
625

7-
# Can be overridden by the configuration file.
26+
# Networking utilities.
827
: "${PING:=ping}"
9-
: "${PING6:=ping6}"
10-
: "${MZ:=mausezahn}"
11-
: "${MZ_DELAY:=0}"
28+
: "${PING6:=ping6}" # Some distros just use ping.
1229
: "${ARPING:=arping}"
30+
: "${TROUTE6:=traceroute6}"
31+
32+
# Packet generator.
33+
: "${MZ:=mausezahn}" # Some distributions use 'mz'.
34+
: "${MZ_DELAY:=0}"
35+
36+
# Host configuration tools.
1337
: "${TEAMD:=teamd}"
38+
: "${MCD:=smcrouted}"
39+
: "${MC_CLI:=smcroutectl}"
40+
41+
# Constants for netdevice bring-up:
42+
# Default time in seconds to wait for an interface to come up before giving up
43+
# and bailing out. Used during initial setup.
44+
: "${INTERFACE_TIMEOUT:=600}"
45+
# Like INTERFACE_TIMEOUT, but default for ad-hoc waiting in testing scripts.
46+
: "${WAIT_TIMEOUT:=20}"
47+
# Time to wait after interfaces participating in the test are all UP.
1448
: "${WAIT_TIME:=5}"
49+
50+
# Whether to pause on, respectively, after a failure and before cleanup.
1551
: "${PAUSE_ON_FAIL:=no}"
1652
: "${PAUSE_ON_CLEANUP:=no}"
17-
: "${NETIF_TYPE:=veth}"
53+
54+
# Whether to create virtual interfaces, and what netdevice type they should be.
1855
: "${NETIF_CREATE:=yes}"
19-
: "${MCD:=smcrouted}"
20-
: "${MC_CLI:=smcroutectl}"
56+
: "${NETIF_TYPE:=veth}"
57+
58+
# Constants for ping tests:
59+
# How many packets should be sent.
2160
: "${PING_COUNT:=10}"
61+
# Timeout (in seconds) before ping exits regardless of how many packets have
62+
# been sent or received
2263
: "${PING_TIMEOUT:=5}"
23-
: "${WAIT_TIMEOUT:=20}"
24-
: "${INTERFACE_TIMEOUT:=600}"
64+
65+
# Minimum ageing_time (in centiseconds) supported by hardware
2566
: "${LOW_AGEING_TIME:=1000}"
67+
68+
# Whether to check for availability of certain tools.
2669
: "${REQUIRE_JQ:=yes}"
2770
: "${REQUIRE_MZ:=yes}"
2871
: "${REQUIRE_MTOOLS:=no}"
72+
73+
# Whether to override MAC addresses on interfaces participating in the test.
2974
: "${STABLE_MAC_ADDRS:=no}"
75+
76+
# Flags for tcpdump
3077
: "${TCPDUMP_EXTRA_FLAGS:=}"
31-
: "${TROUTE6:=traceroute6}"
78+
79+
# Flags for TC filters.
80+
: "${TC_FLAG:=skip_hw}"
3281

3382
net_forwarding_dir=$(dirname "$(readlink -e "${BASH_SOURCE[0]}")")
3483

0 commit comments

Comments
 (0)