selftests/net/lib.sh contains a suite of iproute2 wrappers that automatically schedule the corresponding cleanup through defer. The fact they do so is however not immediately obvious, one needs to know which functions are handling the deferral behind the scenes, and which expect the caller to handle cleanups themselves.
A convention for these auto-deferring functions would help both writing and patch review. This patchset does so by marking these functions with an adf_ prefix. We already have a few such functions: forwarding/lib.sh has adf_mcd_start() and a few selftests add private helpers that conform to this convention.
Patches #1 to #8 gradually convert individual functions, one per patch.
Patch #9 renames an auto-deferring private helpers named dfr_* to adf_*. The plan is not to retro-rename all private helpers, but I happened to know about this one.
Patches #10 to #12 introduce several autodefer helpers for commonly used forwarding/lib.sh functions, and opportunistically convert straightforward instances of 'action; defer counteraction' to the new helpers.
Patch #13 adds some README verbiage to pitch defer and the adf_* convention.
Petr Machata (13): selftests: net: lib: Rename ip_link_add() to adf_* selftests: net: lib: Rename ip_link_set_master() to adf_* selftests: net: lib: Rename ip_link_set_addr() to adf_* selftests: net: lib: Rename ip_link_set_up() to adf_* selftests: net: lib: Rename ip_link_set_down() to adf_* selftests: net: lib: Rename ip_addr_add() to adf_* selftests: net: lib: Rename ip_route_add() to adf_* selftests: net: lib: Rename bridge_vlan_add() to adf_* selftests: net: vlan_bridge_binding: Rename dfr_set_binding_*() to adf_* selftests: forwarding: lib: Add an autodefer variant of vrf_prepare() selftests: forwarding: lib: Add an autodefer variant of simple_if_init() selftests: forwarding: lib: Add an autodefer variant of forwarding_enable() selftests: forwarding: README: Mention defer, adf_
.../drivers/net/mlxsw/devlink_trap_policer.sh | 9 +- .../drivers/net/mlxsw/qos_ets_strict.sh | 12 +- .../drivers/net/mlxsw/qos_max_descriptors.sh | 9 +- .../drivers/net/mlxsw/qos_mc_aware.sh | 12 +- .../drivers/net/mlxsw/sch_red_core.sh | 6 +- tools/testing/selftests/net/fdb_notify.sh | 26 ++-- tools/testing/selftests/net/forwarding/README | 15 ++ .../net/forwarding/bridge_activity_notify.sh | 21 ++- .../net/forwarding/bridge_fdb_local_vlan_0.sh | 65 ++++---- tools/testing/selftests/net/forwarding/lib.sh | 18 +++ .../selftests/net/forwarding/sch_ets_core.sh | 9 +- .../selftests/net/forwarding/sch_red.sh | 12 +- .../selftests/net/forwarding/sch_tbf_core.sh | 6 +- .../net/forwarding/vxlan_bridge_1q_mc_ul.sh | 141 +++++++++--------- .../net/forwarding/vxlan_reserved.sh | 33 ++-- tools/testing/selftests/net/lib.sh | 16 +- .../net/test_vxlan_fdb_changelink.sh | 8 +- .../selftests/net/vlan_bridge_binding.sh | 44 +++--- 18 files changed, 225 insertions(+), 237 deletions(-)