Add basic tests covering routing table and lltable manipulations via rtsock
Having such tests help monitoring our ABI stability and eases testing upcoming routing changes.
Current set of tests
Routes:
- rtm_get_v4_exact_success: Tests RTM_GET with exact prefix lookup on an interface prefix
- rtm_get_v4_lpm_success: Tests RTM_GET with address lookup on an existing prefix
- rtm_get_v4_empy_dst_failure: Tests RTM_GET with empty DST addr
- rtm_get_v4_hostbits_failure: Tests RTM_GET with prefix with some hosts-bits set
- rtm_add_v4_gw_direct_success: Tests IPv4 route addition with directly-reachable GW specified by IP
- rtm_del_v4_prefix_nogw_success: Tests IPv4 route removal without specifying gateway
- rtm_add_v6_gu_gw_gu_direct_success: Tests IPv6 global unicast prefix addition with directly-reachable GU GW
- rtm_del_v6_gu_prefix_nogw_success: Tests IPv6 global unicast prefix removal without specifying gateway
LLtable:
- rtm_add_v6_ll_lle_success: Tests addition of link-local IPv6 ND entry
- rtm_add_v6_gu_lle_success: Tests addition of global IPv6 ND entry
- rtm_add_v4_gu_lle_success: Tests addition of IPv4 ARP entry
- rtm_del_v6_ll_lle_success: Tests removal of link-local IPv6 ND entry
- rtm_del_v6_gu_lle_success: Tests removal of global IPv6 ND entry
- rtm_del_v4_gu_lle_success: Tests removal of IPv4 ARP entry
Code layout
Generally many more - large tens of additional tests are needed to check for corner cases and most popular software behaviour.
Given that, these files are organised as a small framework of helper functions, allowing to write relatively high-level code in the actual tests.
To be more specific,
- rtsock_config.h contains commong test config functions (param instantiation from the test variables, cleanup routines)
- rtsock_print.h contains functions on fancy-printing sockaddrs and route messages
- rtsock_common.h contains function for sockaddr manipulation (easy filling and verification routines), rtsock helpers (socket wrappers, message construction and validation helpers), iface helpers (interface cloning, destroying, adding and removing addresses).
All these files should be libraries, the reason they are included directly is either my inability of finding proper atf.test.mk tunables or lack of such tunables.
Comments on test required infrastructure
As most of the tests involve operation on ARP/ND/route entires, test setup/teardown operations include
- creating new interface (currently tap, as it mimics ethernet pretty well)
- assigning v4/v6 address prefixes according to the configuration
- adding/deleting ARP/ND/route entries (all within specified v4/v6 prefixes)
- cleaning up by destroying the interface
Given that, tests require having if_tuntap module either compiled-in (default) or loadable.
Currently existing test variables
- rtsock.ifname: interface to operate on, defaults to tap4242
- rtsock.create_interface: whether to auto-create/destroy the interface, default to true
- rtsock.v4prefix: IPv4 prefix to operate on (subprefixes can be created), defaults to 192.0.2.0/24 (ipv4 documentation prefix)
- rtsock.v6prefix: IPv6 prefix to operate on (subprefixes can be created), defaults to 2001:DB8::/32 (ipv6 documentation prefix)
- rtsock.remote_lladdr: mac address to use for arp/nd entries, defaults to 00-00-5E-00-53-FF (IANA OUI documentation)