Page MenuHomeFreeBSD

tests/netinet: make connect_bound_socket_from_2address_jail self-contained
Needs ReviewPublic

Authored by olivier on Tue, Oct 6, 11:16 PM.
Tags
None
Referenced Files
F175597146: D60423.id188913.diff
Sun, Oct 11, 10:41 PM
Unknown Object (File)
Sun, Oct 11, 4:36 AM
Unknown Object (File)
Sat, Oct 10, 11:32 PM
Unknown Object (File)
Fri, Oct 9, 12:56 AM
Unknown Object (File)
Thu, Oct 8, 11:23 PM
Unknown Object (File)
Thu, Oct 8, 2:03 PM
Unknown Object (File)
Wed, Oct 7, 6:02 PM
Unknown Object (File)
Wed, Oct 7, 5:01 PM
Subscribers

Details

Reviewers
glebius
Group Reviewers
transport
Summary

Run the test case in a fresh vnet jail with 192.0.2.1/24 assigned to
lo0, so it no longer depends on the host routing table. Skip it when
the kernel lacks VIMAGE.

Fixes: 2e16d37e275fa6bcd0494dbc48868a979404ce56

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

No objection. When writing this test I relied on @igoro and other test team members to deliver a framework where you would describe a jail for a test to be delivered real soon.

No objection. When writing this test I relied on @igoro and other test team members to deliver a framework where you would describe a jail for a test to be delivered real soon.

the existing jail/vnet helpers are shell only, so it seems simpler to add this C-only way for this use-case.

No objection. When writing this test I relied on @igoro and other test team members to deliver a framework where you would describe a jail for a test to be delivered real soon.

the existing jail/vnet helpers are shell only, so it seems simpler to add this C-only way for this use-case.

Probably this is a good context to consider this addition to Kyua: https://reviews.freebsd.org/D55859. It requires opinions to make sure it really helps and provides the most flexible and practical interface.

Having that patch applied, the udp_bindings:connect_bound_socket_from_2address_jail test case could be wrapped into a jail with pre-configuration like this:

diff --git a/tests/sys/netinet/Makefile b/tests/sys/netinet/Makefile
index 0812dc12a242..2adda73fd9d0 100644
--- a/tests/sys/netinet/Makefile
+++ b/tests/sys/netinet/Makefile
@@ -64,9 +64,11 @@ PROGS=       ip6_mrouted     \
        tcp_user_cookie \
        udp_dontroute

-${PACKAGE}FILES+=              redirect.py
+${PACKAGE}FILES+=              redirect.py \
+                               udp_bindings.setup_vnet

 ${PACKAGE}FILESMODE_redirect.py=0555
+${PACKAGE}FILESMODE_udp_bindings.setup_vnet=0555

 MAN=

diff --git a/tests/sys/netinet/udp_bindings.c b/tests/sys/netinet/udp_bindings.c
index 8470318aafef..8e22419bd5f8 100644
--- a/tests/sys/netinet/udp_bindings.c
+++ b/tests/sys/netinet/udp_bindings.c
@@ -215,7 +215,14 @@ ATF_TC_BODY(gethostname_jailed, tc)
        close(s);
 }

-ATF_TC_WITHOUT_HEAD(connect_bound_socket_from_2address_jail);
+ATF_TC(connect_bound_socket_from_2address_jail);
+ATF_TC_HEAD(connect_bound_socket_from_2address_jail, tc)
+{
+       atf_tc_set_md_var(tc, "require.user", "root");
+       atf_tc_set_md_var(tc, "execenv", "jail");
+       atf_tc_set_md_var(tc, "execenv.jail.params", "vnet");
+       atf_tc_set_md_var(tc, "setup", ".setup_vnet");
+}
 ATF_TC_BODY(connect_bound_socket_from_2address_jail, tc)
 {
        struct in_addr addrs[] = {
diff --git a/tests/sys/netinet/udp_bindings.setup_vnet b/tests/sys/netinet/udp_bindings.setup_vnet
new file mode 100644
index 000000000000..4aeb720b9c07
--- /dev/null
+++ b/tests/sys/netinet/udp_bindings.setup_vnet
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+ifconfig lo0 192.0.2.1/24

Having that patch applied, the udp_bindings:connect_bound_socket_from_2address_jail test case could be wrapped into a jail with pre-configuration like this:

And the ATF_TC_BODY(connect_bound_socket_from_2address_jail, tc) will shrink to just a few lines. I would love it!