Page MenuHomeFreeBSD

Add userland tests for route table/lltable rtsock operations.
ClosedPublic

Authored by melifaro on Dec 17 2019, 11:15 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 2 2024, 10:28 AM
Unknown Object (File)
Sep 27 2024, 1:11 AM
Unknown Object (File)
Sep 25 2024, 9:01 PM
Unknown Object (File)
Sep 24 2024, 4:12 AM
Unknown Object (File)
Sep 20 2024, 9:11 PM
Unknown Object (File)
Sep 19 2024, 9:50 PM
Unknown Object (File)
Sep 18 2024, 9:25 AM
Unknown Object (File)
Sep 18 2024, 12:52 AM
Subscribers

Details

Summary

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)
Test Plan
23:57 [1] m@devel0 s kyua test -k /usr/obj/usr/home/melifaro/free/head/amd64.amd64/tests/sys/net/routing/Kyuafile
test_rtsock_l3:rtm_add_v4_gw_direct_success  ->  passed  [0.016s]
test_rtsock_l3:rtm_add_v6_gu_gw_gu_direct_success  ->  passed  [0.006s]
test_rtsock_l3:rtm_del_v4_prefix_nogw_success  ->  passed  [0.005s]
test_rtsock_l3:rtm_del_v6_gu_prefix_nogw_success  ->  failed: /usr/home/melifaro/free/head/tests/sys/net/routing/test_rtsock_l3.c:123: NETMASK sa diff: overall memcmp() reports diff for af 28 offset 2  [0.005s]
test_rtsock_l3:rtm_get_v4_empty_dst_failure  ->  passed  [0.002s]
test_rtsock_l3:rtm_get_v4_exact_success  ->  passed  [0.006s]
test_rtsock_l3:rtm_get_v4_hostbits_failure  ->  passed  [0.005s]
test_rtsock_l3:rtm_get_v4_lpm_success  ->  passed  [0.005s]
test_rtsock_lladdr:rtm_add_v4_gu_lle_success  ->  passed  [0.005s]
test_rtsock_lladdr:rtm_add_v6_gu_lle_success  ->  passed  [0.002s]
test_rtsock_lladdr:rtm_add_v6_ll_lle_success  ->  passed  [0.003s]
test_rtsock_lladdr:rtm_del_v4_gu_lle_success  ->  passed  [0.005s]
test_rtsock_lladdr:rtm_del_v6_gu_lle_success  ->  passed  [0.002s]
test_rtsock_lladdr:rtm_del_v6_ll_lle_success  ->  passed  [0.003s]

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Update default mac address.

melifaro edited the test plan for this revision. (Show Details)
melifaro added reviewers: network, lwhsu, ae.
melifaro edited the summary of this revision. (Show Details)
melifaro edited the test plan for this revision. (Show Details)

Update tests descriptions.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 28 2019, 12:16 PM
This revision was automatically updated to reflect the committed changes.