xref: /linux/tools/testing/selftests/net/forwarding/README (revision 73bae6736b6b577b52fbba2d4b71a5a3e9920fb5)
1*73bae673SIdo SchimmelMotivation
2*73bae673SIdo Schimmel==========
3*73bae673SIdo Schimmel
4*73bae673SIdo SchimmelOne of the nice things about network namespaces is that they allow one
5*73bae673SIdo Schimmelto easily create and test complex environments.
6*73bae673SIdo Schimmel
7*73bae673SIdo SchimmelUnfortunately, these namespaces can not be used with actual switching
8*73bae673SIdo SchimmelASICs, as their ports can not be migrated to other network namespaces
9*73bae673SIdo Schimmel(NETIF_F_NETNS_LOCAL) and most of them probably do not support the
10*73bae673SIdo SchimmelL1-separation provided by namespaces.
11*73bae673SIdo Schimmel
12*73bae673SIdo SchimmelHowever, a similar kind of flexibility can be achieved by using VRFs and
13*73bae673SIdo Schimmelby looping the switch ports together. For example:
14*73bae673SIdo Schimmel
15*73bae673SIdo Schimmel                             br0
16*73bae673SIdo Schimmel                              +
17*73bae673SIdo Schimmel               vrf-h1         |           vrf-h2
18*73bae673SIdo Schimmel                 +        +---+----+        +
19*73bae673SIdo Schimmel                 |        |        |        |
20*73bae673SIdo Schimmel    192.0.2.1/24 +        +        +        + 192.0.2.2/24
21*73bae673SIdo Schimmel               swp1     swp2     swp3     swp4
22*73bae673SIdo Schimmel                 +        +        +        +
23*73bae673SIdo Schimmel                 |        |        |        |
24*73bae673SIdo Schimmel                 +--------+        +--------+
25*73bae673SIdo Schimmel
26*73bae673SIdo SchimmelThe VRFs act as lightweight namespaces representing hosts connected to
27*73bae673SIdo Schimmelthe switch.
28*73bae673SIdo Schimmel
29*73bae673SIdo SchimmelThis approach for testing switch ASICs has several advantages over the
30*73bae673SIdo Schimmeltraditional method that requires multiple physical machines, to name a
31*73bae673SIdo Schimmelfew:
32*73bae673SIdo Schimmel
33*73bae673SIdo Schimmel1. Only the device under test (DUT) is being tested without noise from
34*73bae673SIdo Schimmelother system.
35*73bae673SIdo Schimmel
36*73bae673SIdo Schimmel2. Ability to easily provision complex topologies. Testing bridging
37*73bae673SIdo Schimmelbetween 4-ports LAGs or 8-way ECMP requires many physical links that are
38*73bae673SIdo Schimmelnot always available. With the VRF-based approach one merely needs to
39*73bae673SIdo Schimmelloopback more ports.
40*73bae673SIdo Schimmel
41*73bae673SIdo SchimmelThese tests are written with switch ASICs in mind, but they can be run
42*73bae673SIdo Schimmelon any Linux box using veth pairs to emulate physical loopbacks.
43*73bae673SIdo Schimmel
44*73bae673SIdo SchimmelGuidelines for Writing Tests
45*73bae673SIdo Schimmel============================
46*73bae673SIdo Schimmel
47*73bae673SIdo Schimmelo Where possible, reuse an existing topology for different tests instead
48*73bae673SIdo Schimmel  of recreating the same topology.
49*73bae673SIdo Schimmelo Where possible, IPv6 and IPv4 addresses shall conform to RFC 3849 and
50*73bae673SIdo Schimmel  RFC 5737, respectively.
51*73bae673SIdo Schimmelo Where possible, tests shall be written so that they can be reused by
52*73bae673SIdo Schimmel  multiple topologies and added to lib.sh.
53*73bae673SIdo Schimmelo Checks shall be added to lib.sh for any external dependencies.
54*73bae673SIdo Schimmelo Code shall be checked using ShellCheck [1] prior to submission.
55*73bae673SIdo Schimmel
56*73bae673SIdo Schimmel1. https://www.shellcheck.net/
57