Add tests for adding a route using an interface only (without an IP address).
This is a test for D41330. Essentially a copy/paste from the existing IPv6 one.
Differential D41436
netlink: Add tests when adding an interface route jlduran on Aug 12 2023, 4:31 PM. Authored by Tags None Referenced Files
Details Add tests for adding a route using an interface only (without an IP address). This is a test for D41330. Essentially a copy/paste from the existing IPv6 one. # kyua debug sys/netlink/test_rtnl_route.py:TestRtNlRoute::test_add_route4_ll_gw ============================= test session starts ============================== platform freebsd14 -- Python 3.9.17, pytest-7.4.0, pluggy-1.2.0 -- /usr/local/bin/python3.9 rootdir: /usr/tests/sys/netlink collecting ... collected 1 item ../../../../usr/tests/sys/netlink/test_rtnl_route.py::TestRtNlRoute::test_add_route4_ll_gw Creating if1 run: '/sbin/ifconfig epair create' run: '/usr/sbin/jail -i -c name=pytest:TestRtNlRoute:test_add_route4_ll_gw persist vnet vnet.interface=epair0a' run: 'jexec pytest:TestRtNlRoute:test_add_route4_ll_gw /sbin/ifconfig lo0 inet 127.0.0.1/8' run: 'jexec pytest:TestRtNlRoute:test_add_route4_ll_gw /sbin/ifconfig lo0 up' run: 'jexec pytest:TestRtNlRoute:test_add_route4_ll_gw /sbin/ifconfig -l' ============= TEST TOPOLOGY ============= # vnet vnet1 -> pytest:TestRtNlRoute:test_add_route4_ll_gw # iface if1: vnet1::epair0a -> main::epair0b # setup_vnet(pytest:TestRtNlRoute:test_add_route4_ll_gw) run: '/sbin/sysctl net.inet6.ip6.dad_count=0' run: '/sbin/ifconfig epair0a up' run: '/usr/sbin/ndp -i epair0a -disabled' run: '/sbin/ifconfig epair0a inet6 2001:db8::1/64' run: '/sbin/ifconfig epair0a inet6' run: '/sbin/ifconfig tun create' ============= >> TX MESSAGE ============= len=0, type=RTM_NEWROUTE, flags=NLM_F_REQUEST,NLM_F_ACK,0x400(0x405), seq=1, pid=841 family=AF_INET, dst_len=32, src_len=0, tos=0, table=0, protocol=RTPROT_UNSPEC(0), scope=RT_SCOPE_UNIVERSE(0), type=RTN_UNSPEC(0), flags=(0) len=8 type=RTA_DST(1) addr=192.0.2.1 len=8 type=RTA_OIF(4) val=6 ===vv -- DATA -- (len: 44) vv=== 2C 00 00 00 18 00 05 04 01 00 00 00 49 03 00 00 02 20 00 00 00 00 00 00 00 00 00 00 08 00 01 00 C0 00 02 01 08 00 04 00 06 00 00 00 -------------------- ============= << RX MESSAGE ============= len=36, type=NLMSG_ERROR, flags=NLM_F_CAPPED(0x100), seq=1, pid=0 error=0, len=44, type=msg#24, flags=NLM_F_REQUEST,NLM_F_ACK,0x200,0x400(0x605), seq=1, pid=0 ======= ifconfig ===== lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384 options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 groups: lo nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> epair0a: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500 options=8<VLAN_MTU> ether 02:79:2a:a1:b4:0a inet6 2001:db8::1 prefixlen 64 inet6 fe80::79:2aff:fea1:b40a%epair0a prefixlen 64 scopeid 0x3 groups: epair media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>) status: active nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> tun0: flags=8010<POINTOPOINT,MULTICAST> metric 0 mtu 1500 options=80000<LINKSTATE> groups: tun nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> ======= netstat -rnW ===== Routing tables Internet: Destination Gateway Flags Nhop# Mtu Netif Expire 127.0.0.1 link#5 UH 1 16384 lo0 192.0.2.1 link#6 UH 2 1500 tun0 Internet6: Destination Gateway Flags Nhop# Mtu Netif Expire ::1 link#5 UHS 1 16384 lo0 2001:db8::/64 link#3 U 5 1500 epair0a 2001:db8::1 link#5 UHS 4 16384 lo0 fe80::%epair0a/64 link#3 U 6 1500 epair0a fe80::79:2aff:fea1:b40a%lo0 link#5 UHS 4 16384 lo0 fe80::%lo0/64 link#5 U 3 16384 lo0 fe80::1%lo0 link#5 UHS 2 16384 lo0 ======= netstat -4onW ===== Nexthop data Internet: Idx Type IFA Gateway Flags Use Mtu Netif Addrif Refcnt Prepend 1 v4/resolve 127.0.0.1 lo0/resolve H 0 16384 lo0 2 2 v4/resolve link#6 tun0/resolve H 0 1500 tun0 2 PASSED ============================== 1 passed in 1.15s =============================== ============================= test session starts ============================== platform freebsd14 -- Python 3.9.17, pytest-7.4.0, pluggy-1.2.0 -- /usr/local/bin/python3.9 rootdir: /usr/tests/sys/netlink collecting ... collected 1 item ../../../../usr/tests/sys/netlink/test_rtnl_route.py::TestRtNlRoute::test_add_route4_ll_gw ==== vnet cleanup === # topology_id: 'TestRtNlRoute:test_add_route4_ll_gw' run: '/usr/sbin/jexec pytest:TestRtNlRoute:test_add_route4_ll_gw ifconfig lo0 destroy' run: '/usr/sbin/jexec pytest:TestRtNlRoute:test_add_route4_ll_gw ifconfig epair0a destroy' run: '/usr/sbin/jexec pytest:TestRtNlRoute:test_add_route4_ll_gw ifconfig tun0 destroy' run: '/usr/sbin/jail -r pytest:TestRtNlRoute:test_add_route4_ll_gw' PASSED ============================== 1 passed in 0.40s =============================== ifconfig: SIOCIFDESTROY: Invalid argument sys/netlink/test_rtnl_route.py:TestRtNlRoute::test_add_route4_ll_gw -> passed root@fbsd:/usr/tests # kyua test sys/netlink/test_rtnl_route.py:TestRtNlRoute Results file id is usr_tests.20230812-161612-029905 Results saved to /root/.kyua/store/results.usr_tests.20230812-161612-029905.db kyua: W: No test cases matched by the filter 'sys/netlink/test_rtnl_route.py:TestRtNlRoute'. root@fbsd:/usr/tests # kyua test sys/netlink/test_rtnl_route.py:TestRtNlRoute::test_add_route4_ll_gw sys/netlink/test_rtnl_route.py:TestRtNlRoute::test_add_route4_ll_gw -> passed [2.417s] Results file id is usr_tests.20230812-161622-240342 Results saved to /root/.kyua/store/results.usr_tests.20230812-161622-240342.db 1/1 passed (0 failed)
Diff Detail
Event TimelineComment Actions Phabricator's built-in tracker could serve this purpose but we don't use it. The review URL can be added to "see also" in PR271607 and a reference in the pr body. Comment Actions ah yes, I should have scrolled up. Is that really testing for the same case? # setup_vnet(pytest:TestRtNlRoute:test_add_route4_ll_gw) run: '/sbin/sysctl net.inet6.ip6.dad_count=0' run: '/sbin/ifconfig epair0a up' run: '/usr/sbin/ndp -i epair0a -disabled' run: '/sbin/ifconfig epair0a inet6 2001:db8::1/64' run: '/sbin/ifconfig epair0a inet6' run: '/sbin/ifconfig tun create' The whole point of D41330 was to handle the case where the interface doesn't have a v4/v6 address. Comment Actions I'm working on adding it. Just like the IPv4 one (using tun, without a gateway), I'll name the tests add_route{4,6}_ll_if_gw. Comment Actions Thanks! I'm adding some atf-sh tests for sbin/route that will complement this nicely. I'll land both when you're done ;) Comment Actions
pytests are currently perhaps too verbose; The last line run: '/sbin/ifconfig tun create' is the one we actually use for testing. Here is the output for IPv6 passing (notice the output of netstat, index 7): # kyua debug -k /usr/tests/Kyuafile sys/netlink/test_rtnl_route.py:TestRtNlRoute::test_add_route6_ll_if_gw ============================= test session starts ============================== platform freebsd15 -- Python 3.9.18, pytest-7.4.3, pluggy-1.3.0 -- /usr/local/bin/python3.9 rootdir: /usr/tests/sys/netlink collecting ... collected 1 item ../../../../usr/tests/sys/netlink/test_rtnl_route.py::TestRtNlRoute::test_add_route6_ll_if_gw Creating if1 run: '/sbin/ifconfig epair create' run: '/usr/sbin/jail -i -c name=pytest:TestRtNlRoute:test_add_route6_ll_if_gw persist vnet vnet.interface=epair0a' run: '/usr/sbin/jexec pytest:TestRtNlRoute:test_add_route6_ll_if_gw /sbin/ifconfig -l' ============= TEST TOPOLOGY ============= # vnet vnet1 -> pytest:TestRtNlRoute:test_add_route6_ll_if_gw # iface if1: vnet1::epair0a -> main::epair0b # setup_vnet(pytest:TestRtNlRoute:test_add_route6_ll_if_gw) run: '/sbin/sysctl net.inet6.ip6.dad_count=0' run: '/sbin/ifconfig tun create' ============= >> TX MESSAGE ============= len=0, type=RTM_NEWROUTE, flags=NLM_F_REQUEST,NLM_F_ACK,0x400(0x405), seq=1, pid=52305 family=AF_INET6, dst_len=64, src_len=0, tos=0, table=0, protocol=RTPROT_UNSPEC(0), scope=RT_SCOPE_UNIVERSE(0), type=RTN_UNSPEC(0), flags=(0) len=20 type=RTA_DST(1) addr=2001:db8:2:: len=8 type=RTA_OIF(4) val=6 ===vv -- DATA -- (len: 56) vv=== 38 00 00 00 18 00 05 04 01 00 00 00 51 CC 00 00 1C 40 00 00 00 00 00 00 00 00 00 00 14 00 01 00 20 01 0D B8 00 02 00 00 00 00 00 00 00 00 00 00 08 00 04 00 06 00 00 00 -------------------- ============= << RX MESSAGE ============= len=36, type=NLMSG_ERROR, flags=NLM_F_CAPPED(0x100), seq=1, pid=0 error=0, len=56, type=msg#24, flags=NLM_F_REQUEST,NLM_F_ACK,0x200,0x400(0x605), seq=1, pid=0 ======= ifconfig ===== lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384 options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6> inet 127.0.0.1 netmask 0xff000000 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5 groups: lo nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> epair0a: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500 options=8<VLAN_MTU> ether 02:b0:ef:37:fa:0a inet6 2001:db8::1 prefixlen 64 inet6 fe80::b0:efff:fe37:fa0a%epair0a prefixlen 64 scopeid 0x3 groups: epair media: Ethernet 10Gbase-T (10Gbase-T <full-duplex>) status: active nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL> tun0: flags=8010<POINTOPOINT,MULTICAST> metric 0 mtu 1500 options=80000<LINKSTATE> groups: tun nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL> ======= netstat -rnW ===== Routing tables Internet: Destination Gateway Flags Nhop# Mtu Netif Expire 127.0.0.1 link#5 UH 1 16384 lo0 Internet6: Destination Gateway Flags Nhop# Mtu Netif Expire ::1 link#5 UHS 1 16384 lo0 2001:db8::/64 link#3 U 5 1500 epair0a 2001:db8::1 link#5 UHS 4 16384 lo0 2001:db8:2::/64 link#6 U 7 1500 tun0 fe80::%epair0a/64 link#3 U 6 1500 epair0a fe80::b0:efff:fe37:fa0a%lo0 link#5 UHS 4 16384 lo0 fe80::%lo0/64 link#5 U 3 16384 lo0 fe80::1%lo0 link#5 UHS 2 16384 lo0 ======= netstat -6onW ===== Nexthop data Internet6: Idx Type IFA Gateway Flags Use Mtu Netif Addrif Refcnt Prepend 1 v6/resolve ::1 lo0/resolve HS 0 16384 lo0 2 2 v6/resolve fe80::1%lo0 lo0/resolve HS 0 16384 lo0 2 3 v6/resolve fe80::1%lo0 lo0/resolve 0 16384 lo0 2 4 v6/resolve ::1 lo0/resolve HS 0 16384 lo0 epair0a 3 5 v6/resolve 2001:db8::1 epair0a/resolve 0 1500 epair0a 2 6 v6/resolve fe80::b0:efff:fe37:fa0a%epair0a epair0a/resolve 0 1500 epair0a 2 7 v6/resolve link#6 tun0/resolve 0 1500 tun0 2 PASSED ============================== 1 passed in 0.14s =============================== ============================= test session starts ============================== platform freebsd15 -- Python 3.9.18, pytest-7.4.3, pluggy-1.3.0 -- /usr/local/bin/python3.9 rootdir: /usr/tests/sys/netlink collecting ... collected 1 item ../../../../usr/tests/sys/netlink/test_rtnl_route.py::TestRtNlRoute::test_add_route6_ll_if_gw ============= vnet cleanup ============= # topology_id: 'TestRtNlRoute:test_add_route6_ll_if_gw' Skipping interface pytest:TestRtNlRoute:test_add_route6_ll_if_gw:lo0 run: '/usr/sbin/jexec pytest:TestRtNlRoute:test_add_route6_ll_if_gw /sbin/ifconfig epair0a destroy' run: '/usr/sbin/jexec pytest:TestRtNlRoute:test_add_route6_ll_if_gw /sbin/ifconfig tun0 destroy' run: '/usr/sbin/jail -r pytest:TestRtNlRoute:test_add_route6_ll_if_gw' PASSED ============================== 1 passed in 4.55s =============================== sys/netlink/test_rtnl_route.py:TestRtNlRoute::test_add_route6_ll_if_gw -> passed |