projects/linux·tree master · refs

Files

ModeNameSize
040000../--
100644.gitignore63 B
100644Makefile3.1 KiB
100644README4.1 KiB
100755bridge_activity_notify.sh Executable4.4 KiB
100755bridge_fdb_learning_limit.sh Executable5.8 KiB
100755bridge_fdb_local_vlan_0.sh Executable8.8 KiB
100755bridge_igmp.sh Executable16.3 KiB
100755bridge_locked_port.sh Executable9.2 KiB
100755bridge_mdb.sh Executable47.4 KiB
100755bridge_mdb_host.sh Executable1.7 KiB
100755bridge_mdb_max.sh Executable32.2 KiB
100755bridge_mdb_port_down.sh Executable2.2 KiB
100755bridge_mld.sh Executable17.9 KiB
100755bridge_port_isolation.sh Executable2.3 KiB
100755bridge_sticky_fdb.sh Executable1.1 KiB
100755bridge_vlan_aware.sh Executable6.4 KiB
100755bridge_vlan_mcast.sh Executable23.5 KiB
100755bridge_vlan_unaware.sh Executable1.7 KiB
100644config1.2 KiB
100755custom_multipath_hash.sh Executable9.8 KiB
100644devlink_lib.sh12.8 KiB
100755dual_vxlan_bridge.sh Executable11.2 KiB
100644fib_offload_lib.sh24.6 KiB
100644forwarding.config.sample706 B
100755gre_custom_multipath_hash.sh Executable12.5 KiB
100755gre_inner_v4_multipath.sh Executable7.6 KiB
100755gre_inner_v6_multipath.sh Executable7.7 KiB
100755gre_multipath.sh Executable6.3 KiB
100755gre_multipath_nh.sh Executable8.1 KiB
100755gre_multipath_nh_res.sh Executable8.3 KiB
100755ip6_forward_instats_vrf.sh Executable3.0 KiB
100755ip6gre_custom_multipath_hash.sh Executable12.8 KiB
100755ip6gre_flat.sh Executable1.2 KiB
100755ip6gre_flat_key.sh Executable1.2 KiB
100755ip6gre_flat_keys.sh Executable1.3 KiB
100755ip6gre_hier.sh Executable1.3 KiB
100755ip6gre_hier_key.sh Executable1.3 KiB
100755ip6gre_hier_keys.sh Executable1.4 KiB
100755ip6gre_inner_v4_multipath.sh Executable7.8 KiB
100755ip6gre_inner_v6_multipath.sh Executable7.9 KiB
100644ip6gre_lib.sh15.7 KiB
100755ipip_flat_gre.sh Executable838 B
100755ipip_flat_gre_key.sh Executable860 B
100755ipip_flat_gre_keys.sh Executable886 B
100755ipip_hier_gre.sh Executable887 B
100755ipip_hier_gre_key.sh Executable910 B
100755ipip_hier_gre_keys.sh Executable938 B
100644ipip_lib.sh8.3 KiB
100644ipmr.c12.1 KiB
100644lib.sh46.9 KiB
100755lib_sh_test.sh Executable3.7 KiB
100755local_termination.sh Executable15.2 KiB
100755min_max_mtu.sh Executable4.7 KiB
100755mirror_gre.sh Executable2.9 KiB
100755mirror_gre_bound.sh Executable5.5 KiB
100755mirror_gre_bridge_1d.sh Executable4.1 KiB
100755mirror_gre_bridge_1d_vlan.sh Executable2.4 KiB
100755mirror_gre_bridge_1q.sh Executable4.0 KiB
100755mirror_gre_bridge_1q_lag.sh Executable7.0 KiB
100755mirror_gre_changes.sh Executable5.2 KiB
100755mirror_gre_flower.sh Executable2.6 KiB
100755mirror_gre_lag_lacp.sh Executable7.5 KiB
100644mirror_gre_lib.sh3.6 KiB
100755mirror_gre_neigh.sh Executable2.1 KiB
100755mirror_gre_nh.sh Executable2.5 KiB
100644mirror_gre_topo_lib.sh3.4 KiB
100755mirror_gre_vlan.sh Executable1.4 KiB
100755mirror_gre_vlan_bridge_1q.sh Executable8.5 KiB
100644mirror_lib.sh3.7 KiB
100644mirror_topo_lib.sh2.7 KiB
100755mirror_vlan.sh Executable1.9 KiB
100755no_forwarding.sh Executable5.5 KiB
100755pedit_dsfield.sh Executable6.9 KiB
100755pedit_ip.sh Executable4.6 KiB
100755pedit_l4port.sh Executable4.5 KiB
100755q_in_vni.sh Executable10.7 KiB
100755q_in_vni_ipv6.sh Executable10.9 KiB
100755router.sh Executable8.1 KiB
100755router_bridge.sh Executable4.0 KiB
100755router_bridge_1d.sh Executable5.1 KiB
100755router_bridge_1d_lag.sh Executable9.3 KiB
100755router_bridge_lag.sh Executable6.8 KiB
100755router_bridge_pvid_vlan_upper.sh Executable3.5 KiB
100755router_bridge_vlan.sh Executable5.5 KiB
100755router_bridge_vlan_upper.sh Executable3.9 KiB
100755router_bridge_vlan_upper_pvid.sh Executable3.7 KiB
100755router_broadcast.sh Executable5.0 KiB
100755router_mpath_nh.sh Executable10.7 KiB
100644router_mpath_nh_lib.sh3.2 KiB
100755router_mpath_nh_res.sh Executable12.7 KiB
100755router_mpath_seed.sh Executable7.4 KiB
100755router_multicast.sh Executable14.3 KiB
100755router_multipath.sh Executable7.1 KiB
100755router_nh.sh Executable3.3 KiB
100755router_vid_1.sh Executable3.5 KiB
100755sch_ets.sh Executable760 B
100644sch_ets_core.sh7.3 KiB
100644sch_ets_tests.sh4.3 KiB
100755sch_red.sh Executable11.0 KiB
100644sch_tbf_core.sh4.7 KiB
100755sch_tbf_ets.sh Executable118 B
100644sch_tbf_etsprio.sh1.4 KiB
100755sch_tbf_prio.sh Executable118 B
100755sch_tbf_root.sh Executable496 B
100644settings10 B
100755skbedit_priority.sh Executable3.9 KiB
100755tc_actions.sh Executable9.3 KiB
100755tc_chains.sh Executable4.8 KiB
100644tc_common.sh710 B
100755tc_flower.sh Executable22.8 KiB
100755tc_flower_cfm.sh Executable4.9 KiB
100755tc_flower_l2_miss.sh Executable9.1 KiB
100755tc_flower_port_range.sh Executable7.4 KiB
100755tc_flower_router.sh Executable3.0 KiB
100755tc_mpls_l2vpn.sh Executable5.0 KiB
100755tc_police.sh Executable11.7 KiB
100755tc_shblocks.sh Executable2.7 KiB
100755tc_taprio.sh Executable10.2 KiB
100755tc_tunnel_key.sh Executable3.7 KiB
100755tc_vlan_modify.sh Executable3.2 KiB
100644tsn_lib.sh6.1 KiB
100755vxlan_asymmetric.sh Executable17.6 KiB
100755vxlan_asymmetric_ipv6.sh Executable16.0 KiB
100755vxlan_bridge_1d.sh Executable21.2 KiB
100755vxlan_bridge_1d_ipv6.sh Executable21.3 KiB
100755vxlan_bridge_1d_port_8472.sh Executable172 B
100755vxlan_bridge_1d_port_8472_ipv6.sh Executable188 B
100755vxlan_bridge_1q.sh Executable23.6 KiB
100755vxlan_bridge_1q_ipv6.sh Executable24.3 KiB
100755vxlan_bridge_1q_mc_ul.sh Executable20.0 KiB
100755vxlan_bridge_1q_port_8472.sh Executable172 B
100755vxlan_bridge_1q_port_8472_ipv6.sh Executable188 B
100755vxlan_reserved.sh Executable7.2 KiB
100755vxlan_symmetric.sh Executable18.1 KiB
100755vxlan_symmetric_ipv6.sh Executable18.3 KiB

tools/testing/selftests/net/forwarding/README

Motivation
==========

One of the nice things about network namespaces is that they allow one
to easily create and test complex environments.

Unfortunately, these namespaces can not be used with actual switching
ASICs, as their ports can not be migrated to other network namespaces
(dev->netns_immutable) and most of them probably do not support the
L1-separation provided by namespaces.

However, a similar kind of flexibility can be achieved by using VRFs and
by looping the switch ports together. For example:

                             br0
                              +
               vrf-h1         |           vrf-h2
                 +        +---+----+        +
                 |        |        |        |
    192.0.2.1/24 +        +        +        + 192.0.2.2/24
               swp1     swp2     swp3     swp4
                 +        +        +        +
                 |        |        |        |
                 +--------+        +--------+

The VRFs act as lightweight namespaces representing hosts connected to
the switch.

This approach for testing switch ASICs has several advantages over the
traditional method that requires multiple physical machines, to name a
few:

1. Only the device under test (DUT) is being tested without noise from
other system.

2. Ability to easily provision complex topologies. Testing bridging
between 4-ports LAGs or 8-way ECMP requires many physical links that are
not always available. With the VRF-based approach one merely needs to
loopback more ports.

These tests are written with switch ASICs in mind, but they can be run
on any Linux box using veth pairs to emulate physical loopbacks.

Guidelines for Writing Tests
============================

o Where possible, reuse an existing topology for different tests instead
  of recreating the same topology.
o Tests that use anything but the most trivial topologies should include
  an ASCII art showing the topology.
o Where possible, IPv6 and IPv4 addresses shall conform to RFC 3849 and
  RFC 5737, respectively.
o Where possible, tests shall be written so that they can be reused by
  multiple topologies and added to lib.sh.
o Checks shall be added to lib.sh for any external dependencies.
o Code shall be checked using ShellCheck [1] prior to submission.

1. https://www.shellcheck.net/

Cleanups
--------

o lib.sh brings in defer.sh (by way of ../lib.sh) by default. Consider
  making use of the defer primitive to schedule automatic cleanups. This
  makes it harder to forget to remove a temporary netdevice, kill a running
  process or perform other cleanup when the test script is interrupted.

o When adding a helper that dirties the environment, but schedules all
  necessary cleanups through defer, consider prefixing it adf_ for
  consistency with lib.sh and ../lib.sh helpers. This serves as an
  immediately visible bit of documentation about the helper API.

o Definitely do the above for any new code in lib.sh, if practical.

Customization
=============

The forwarding selftests framework uses a number of variables that
influence its behavior and tools it invokes, and how it invokes them, in
various ways. A number of these variables can be overridden. The way these
overridable variables are specified is typically one of the following two
syntaxes:

	: "${VARIABLE:=default_value}"
	VARIABLE=${VARIABLE:=default_value}

Any of these variables can be overridden. Notably net/forwarding/lib.sh and
net/lib.sh contain a number of overridable variables.

One way of overriding these variables is through the environment:

	PAUSE_ON_FAIL=yes ./some_test.sh

The variable NETIFS is special. Since it is an array variable, there is no
way to pass it through the environment. Its value can instead be given as
consecutive arguments to the selftest:

	./some_test.sh swp{1..8}

A way to customize variables in a persistent fashion is to create a file
named forwarding.config in this directory. lib.sh sources the file if
present, so it can contain any shell code. Typically it will contain
assignments of variables whose value should be overridden.

forwarding.config.sample is available in the directory as an example of
how forwarding.config might look.