Name Date Size #Lines LOC

..--

.gitignoreH A D01-Sep-202058 32

MakefileH A D13-Dec-20253.1 KiB142133

READMEH A D13-Dec-20254.1 KiB10780

bridge_activity_notify.shH A D13-Dec-20254.4 KiB171106

bridge_fdb_learning_limit.shH A D05-Feb-20255.8 KiB302216

bridge_fdb_local_vlan_0.shH A D13-Dec-20258.8 KiB388263

bridge_igmp.shH A D16-Sep-202516.3 KiB637467

bridge_locked_port.shH A D15-Jul-20249.2 KiB366249

bridge_mdb.shH A D20-Jan-202647.4 KiB1,4681,000

bridge_mdb_host.shH A D10-Dec-20221.7 KiB10470

bridge_mdb_max.shH A D23-Feb-202632.2 KiB1,4341,072

bridge_mdb_port_down.shH A D14-Dec-20222.2 KiB11980

bridge_mld.shH A D16-Sep-202517.9 KiB638476

bridge_port_isolation.shH A D14-Jan-20192.3 KiB152112

bridge_sticky_fdb.shH A D14-Jan-20191.1 KiB7052

bridge_vlan_aware.shH A D29-Jun-20256.4 KiB299196

bridge_vlan_mcast.shH A D21-Feb-202316.7 KiB547442

bridge_vlan_unaware.shH A D08-Apr-20251.7 KiB12587

configH A D24-Dec-20251.2 KiB5756

custom_multipath_hash.shH A D13-Dec-20259.8 KiB373245

devlink_lib.shH A D05-Feb-202512.8 KiB599448

dual_vxlan_bridge.shH A D06-Nov-202311.2 KiB368223

fib_offload_lib.shH A D14-Dec-202224.6 KiB874600

forwarding.config.sampleH A D05-Feb-2025706 3116

gre_custom_multipath_hash.shH A D13-Dec-202512.5 KiB465295

gre_inner_v4_multipath.shH A D15-Jul-20247.6 KiB306182

gre_inner_v6_multipath.shH A D15-Jul-20247.7 KiB307183

gre_multipath.shH A D15-Jul-20246.3 KiB258157

gre_multipath_nh.shH A D15-Jul-20248.1 KiB320202

gre_multipath_nh_res.shH A D15-Jul-20248.3 KiB324206

ip6_forward_instats_vrf.shH A D13-Dec-20253 KiB175129

ip6gre_custom_multipath_hash.shH A D13-Dec-202512.8 KiB467297

ip6gre_flat.shH A D05-Feb-20251.2 KiB8056

ip6gre_flat_key.shH A D05-Feb-20251.2 KiB8056

ip6gre_flat_keys.shH A D05-Feb-20251.3 KiB8056

ip6gre_hier.shH A D05-Feb-20251.3 KiB8056

ip6gre_hier_key.shH A D05-Feb-20251.3 KiB8056

ip6gre_hier_keys.shH A D05-Feb-20251.4 KiB8056

ip6gre_inner_v4_multipath.shH A D15-Jul-20247.8 KiB305182

ip6gre_inner_v6_multipath.shH A D15-Jul-20247.9 KiB306183

ip6gre_lib.shH A D05-Feb-202515.7 KiB519283

ipip_flat_gre.shH A D11-Jul-2019838 6443

ipip_flat_gre_key.shH A D11-Jul-2019860 6443

ipip_flat_gre_keys.shH A D11-Jul-2019886 6443

ipip_hier_gre.shH A D11-Jul-2019887 6443

ipip_hier_gre_key.shH A D11-Jul-2019910 6443

ipip_hier_gre_keys.shH A D11-Jul-2019938 6443

ipip_lib.shH A D05-Feb-20258.3 KiB349157

lib.shH A D13-Dec-202542.6 KiB2,1541,648

lib_sh_test.shH A D14-Feb-20263.7 KiB216154

local_termination.shH A D23-Feb-202614.4 KiB598472

min_max_mtu.shH A D05-Feb-20254.7 KiB284192

mirror_gre.shH A D05-Feb-20252.9 KiB14298

mirror_gre_bound.shH A D05-Feb-20255.5 KiB207115

mirror_gre_bridge_1d.shH A D05-Feb-20254.1 KiB11958

mirror_gre_bridge_1d_vlan.shH A D05-Feb-20252.4 KiB11576

mirror_gre_bridge_1q.shH A D05-Feb-20254 KiB11557

mirror_gre_bridge_1q_lag.shH A D13-Dec-20257 KiB277178

mirror_gre_changes.shH A D05-Feb-20255.2 KiB255179

mirror_gre_flower.shH A D05-Feb-20252.6 KiB12583

mirror_gre_lag_lacp.shH A D08-Apr-20257.5 KiB272167

mirror_gre_lib.shH A D05-Feb-20253.6 KiB173136

mirror_gre_neigh.shH A D05-Feb-20252.1 KiB9966

mirror_gre_nh.shH A D05-Feb-20252.5 KiB11370

mirror_gre_topo_lib.shH A D15-Jul-20243.4 KiB9545

mirror_gre_vlan.shH A D05-Feb-20251.4 KiB7448

mirror_gre_vlan_bridge_1q.shH A D13-Dec-20258.5 KiB330211

mirror_lib.shH A D05-Feb-20253.7 KiB181145

mirror_topo_lib.shH A D06-Nov-20232.7 KiB10360

mirror_vlan.shH A D05-Feb-20251.9 KiB11376

no_forwarding.shH A D05-Feb-20255.5 KiB265190

pedit_dsfield.shH A D23-Feb-20266.9 KiB322242

pedit_ip.shH A D23-Feb-20264.6 KiB210150

pedit_l4port.shH A D15-Jan-20224.5 KiB201144

q_in_vni.shH A D06-Nov-202310.7 KiB349214

q_in_vni_ipv6.shH A D31-May-202210.9 KiB348213

router.shH A D13-Dec-20258.1 KiB370246

router_bridge.shH A D15-Jul-20244 KiB191132

router_bridge_1d.shH A D15-Jul-20245.1 KiB186126

router_bridge_1d_lag.shH A D08-Apr-20259.3 KiB410271

router_bridge_lag.shH A D08-Apr-20256.8 KiB325242

router_bridge_pvid_vlan_upper.shH A D15-Jul-20243.5 KiB156100

router_bridge_vlan.shH A D15-Jul-20245.5 KiB225152

router_bridge_vlan_upper.shH A D15-Jul-20243.9 KiB170111

router_bridge_vlan_upper_pvid.shH A D15-Jul-20243.7 KiB172114

router_broadcast.shH A D23-Aug-20195 KiB238179

router_mpath_nh.shH A D05-Feb-202510.7 KiB465315

router_mpath_nh_lib.shH A D05-Feb-20253.2 KiB133107

router_mpath_nh_res.shH A D05-Feb-202512.7 KiB491334

router_mpath_seed.shH A D05-Feb-20257.4 KiB334247

router_multicast.shH A D01-Nov-202514.3 KiB484306

router_multipath.shH A D05-Feb-20257.1 KiB308222

router_nh.shH A D05-Feb-20253.3 KiB175112

router_vid_1.shH A D14-Dec-20223.5 KiB16198

sch_ets.shH A D21-Nov-2025760 4431

sch_ets_core.shH A D13-Dec-20257.3 KiB277164

sch_ets_tests.shH A D21-Nov-20254.3 KiB235183

sch_red.shH A D13-Dec-202511 KiB461313

sch_tbf_core.shH A D13-Dec-20254.7 KiB201116

sch_tbf_ets.shH A D06-Jun-2020118 73

sch_tbf_etsprio.shH A D05-Feb-20251.4 KiB7350

sch_tbf_prio.shH A D06-Jun-2020118 73

sch_tbf_root.shH A D05-Feb-2025496 3926

settingsH A D06-Nov-202310 21

skbedit_priority.shH A D06-Nov-20233.9 KiB173116

tc_actions.shH A D23-Feb-20269.3 KiB363272

tc_chains.shH A D04-May-20214.8 KiB206148

tc_common.shH A D05-Feb-2025710 3725

tc_flower.shH A D01-Nov-202522.8 KiB768527

tc_flower_cfm.shH A D06-Nov-20234.9 KiB207152

tc_flower_l2_miss.shH A D15-Jul-20249.1 KiB358240

tc_flower_port_range.shH A D28-May-20257.4 KiB275210

tc_flower_router.shH A D16-Sep-20193 KiB173123

tc_mpls_l2vpn.shH A D24-Feb-20215 KiB193111

tc_police.shH A D05-Feb-202511.7 KiB442292

tc_shblocks.shH A D16-Sep-20192.7 KiB153108

tc_taprio.shH A D29-Jun-202510.2 KiB422338

tc_tunnel_key.shH A D05-Feb-20253.7 KiB163126

tc_vlan_modify.shH A D20-Jul-20193.2 KiB165116

tsn_lib.shH A D29-Jun-20256.1 KiB276209

vxlan_asymmetric.shH A D14-Dec-202217.6 KiB578354

vxlan_asymmetric_ipv6.shH A D31-May-202216 KiB505312

vxlan_bridge_1d.shH A D23-Feb-202621.2 KiB814561

vxlan_bridge_1d_ipv6.shH A D23-Feb-202621.3 KiB805569

vxlan_bridge_1d_port_8472.shH A D11-Jul-2019172 115

vxlan_bridge_1d_port_8472_ipv6.shH A D31-May-2022188 126

vxlan_bridge_1q.shH A D02-Jun-202523.6 KiB856548

vxlan_bridge_1q_ipv6.shH A D15-Jul-202424.3 KiB838547

vxlan_bridge_1q_mc_ul.shH A D24-Dec-202520 KiB753500

vxlan_bridge_1q_port_8472.shH A D11-Jul-2019172 115

vxlan_bridge_1q_port_8472_ipv6.shH A D31-May-2022188 126

vxlan_reserved.shH A D13-Dec-20257.2 KiB348253

vxlan_symmetric.shH A D23-Feb-202118.1 KiB562346

vxlan_symmetric_ipv6.shH A D31-May-202218.3 KiB564348

README

1Motivation
2==========
3
4One of the nice things about network namespaces is that they allow one
5to easily create and test complex environments.
6
7Unfortunately, these namespaces can not be used with actual switching
8ASICs, as their ports can not be migrated to other network namespaces
9(dev->netns_immutable) and most of them probably do not support the
10L1-separation provided by namespaces.
11
12However, a similar kind of flexibility can be achieved by using VRFs and
13by looping the switch ports together. For example:
14
15                             br0
16                              +
17               vrf-h1         |           vrf-h2
18                 +        +---+----+        +
19                 |        |        |        |
20    192.0.2.1/24 +        +        +        + 192.0.2.2/24
21               swp1     swp2     swp3     swp4
22                 +        +        +        +
23                 |        |        |        |
24                 +--------+        +--------+
25
26The VRFs act as lightweight namespaces representing hosts connected to
27the switch.
28
29This approach for testing switch ASICs has several advantages over the
30traditional method that requires multiple physical machines, to name a
31few:
32
331. Only the device under test (DUT) is being tested without noise from
34other system.
35
362. Ability to easily provision complex topologies. Testing bridging
37between 4-ports LAGs or 8-way ECMP requires many physical links that are
38not always available. With the VRF-based approach one merely needs to
39loopback more ports.
40
41These tests are written with switch ASICs in mind, but they can be run
42on any Linux box using veth pairs to emulate physical loopbacks.
43
44Guidelines for Writing Tests
45============================
46
47o Where possible, reuse an existing topology for different tests instead
48  of recreating the same topology.
49o Tests that use anything but the most trivial topologies should include
50  an ASCII art showing the topology.
51o Where possible, IPv6 and IPv4 addresses shall conform to RFC 3849 and
52  RFC 5737, respectively.
53o Where possible, tests shall be written so that they can be reused by
54  multiple topologies and added to lib.sh.
55o Checks shall be added to lib.sh for any external dependencies.
56o Code shall be checked using ShellCheck [1] prior to submission.
57
581. https://www.shellcheck.net/
59
60Cleanups
61--------
62
63o lib.sh brings in defer.sh (by way of ../lib.sh) by default. Consider
64  making use of the defer primitive to schedule automatic cleanups. This
65  makes it harder to forget to remove a temporary netdevice, kill a running
66  process or perform other cleanup when the test script is interrupted.
67
68o When adding a helper that dirties the environment, but schedules all
69  necessary cleanups through defer, consider prefixing it adf_ for
70  consistency with lib.sh and ../lib.sh helpers. This serves as an
71  immediately visible bit of documentation about the helper API.
72
73o Definitely do the above for any new code in lib.sh, if practical.
74
75Customization
76=============
77
78The forwarding selftests framework uses a number of variables that
79influence its behavior and tools it invokes, and how it invokes them, in
80various ways. A number of these variables can be overridden. The way these
81overridable variables are specified is typically one of the following two
82syntaxes:
83
84	: "${VARIABLE:=default_value}"
85	VARIABLE=${VARIABLE:=default_value}
86
87Any of these variables can be overridden. Notably net/forwarding/lib.sh and
88net/lib.sh contain a number of overridable variables.
89
90One way of overriding these variables is through the environment:
91
92	PAUSE_ON_FAIL=yes ./some_test.sh
93
94The variable NETIFS is special. Since it is an array variable, there is no
95way to pass it through the environment. Its value can instead be given as
96consecutive arguments to the selftest:
97
98	./some_test.sh swp{1..8}
99
100A way to customize variables in a persistent fashion is to create a file
101named forwarding.config in this directory. lib.sh sources the file if
102present, so it can contain any shell code. Typically it will contain
103assignments of variables whose value should be overridden.
104
105forwarding.config.sample is available in the directory as an example of
106how forwarding.config might look.
107