aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rwxr-xr-xtests/sys/netinet/carp.sh3
-rw-r--r--tests/sys/netinet/multicast-receive.c16
-rwxr-xr-xtests/sys/netinet/multicast.sh47
3 files changed, 60 insertions, 6 deletions
diff --git a/tests/sys/netinet/carp.sh b/tests/sys/netinet/carp.sh
index 2aae2854826e..568d2beaf914 100755
--- a/tests/sys/netinet/carp.sh
+++ b/tests/sys/netinet/carp.sh
@@ -215,6 +215,9 @@ unicast_v4_body()
unicast_v4_cleanup()
{
+ jexec carp_uni_v4_one killall routed
+ jexec carp_uni_v4_two killall routed
+ jexec carp_uni_v4_three killall routed
vnet_cleanup
}
diff --git a/tests/sys/netinet/multicast-receive.c b/tests/sys/netinet/multicast-receive.c
index 81d0f10f5cfe..62fc68200dd6 100644
--- a/tests/sys/netinet/multicast-receive.c
+++ b/tests/sys/netinet/multicast-receive.c
@@ -36,6 +36,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sysexits.h>
#include <limits.h>
#include <err.h>
@@ -93,8 +94,9 @@ usage:
.imr_multiaddr = maddr,
.imr_interface = ifaddr,
};
- assert(setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
- sizeof(mreq)) == 0);
+ if (setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq,
+ sizeof(mreq)) != 0)
+ err(EX_OSERR, "setsockopt");
} else if (strcmp(argv[1], "ip_mreqn") == 0) {
/*
* ip_mreqn shall be used with index, but for testing
@@ -105,8 +107,9 @@ usage:
.imr_address = index ? (struct in_addr){ 0 } : ifaddr,
.imr_ifindex = index ? ifindex : 0,
};
- assert(setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreqn,
- sizeof(mreqn)) == 0);
+ if (setsockopt(s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreqn,
+ sizeof(mreqn)) != 0)
+ err(EX_OSERR, "setsockopt");
} else if (strcmp(argv[1], "group_req") == 0) {
if (!index)
errx(1, "group_req expects index");
@@ -116,8 +119,9 @@ usage:
gsa->sin_family = AF_INET;
gsa->sin_len = sizeof(struct sockaddr_in);
gsa->sin_addr = maddr;
- assert(setsockopt(s, IPPROTO_IP, MCAST_JOIN_GROUP, &greq,
- sizeof(greq)) == 0);
+ if (setsockopt(s, IPPROTO_IP, MCAST_JOIN_GROUP, &greq,
+ sizeof(greq)) != 0)
+ err(EX_OSERR, "setsockopt");
} else
goto usage;
diff --git a/tests/sys/netinet/multicast.sh b/tests/sys/netinet/multicast.sh
index 273970d0f7ea..34094ff08705 100755
--- a/tests/sys/netinet/multicast.sh
+++ b/tests/sys/netinet/multicast.sh
@@ -79,6 +79,27 @@ IP_ADD_MEMBERSHIP_ip_mreq_body()
0.0.0.0 6676 233.252.0.1 6676 192.0.3.1 hello
atf_check -s exit:0 sh -c "wait $pid; exit $?"
atf_check -s exit:0 -o inline:"192.0.3.1:6676 hello\n" cat out
+
+ # join group on the first multicast capable interface (epair1a)
+ multicast_join ip_mreq 0.0.0.0
+ atf_check -s exit:0 -o empty \
+ jexec mjail1 $(atf_get_srcdir)/multicast-send \
+ 0.0.0.0 6676 233.252.0.1 6676 192.0.2.1 hello
+ atf_check -s exit:0 sh -c "wait $pid; exit $?"
+ atf_check -s exit:0 -o inline:"192.0.2.1:6676 hello\n" cat out
+
+ # Set up the receiving jail so that first multicast capable interface
+ # is epair1a and default route points into epair2a. This will allow us
+ # to exercise both branches of inp_lookup_mcast_ifp().
+ jexec mjail2 route add default 192.0.3.254
+
+ # join group on the interface determined by the route lookup
+ multicast_join ip_mreq 0.0.0.0
+ atf_check -s exit:0 -o empty \
+ jexec mjail1 $(atf_get_srcdir)/multicast-send \
+ 0.0.0.0 6676 233.252.0.1 6676 192.0.3.1 hello
+ atf_check -s exit:0 sh -c "wait $pid; exit $?"
+ atf_check -s exit:0 -o inline:"192.0.3.1:6676 hello\n" cat out
}
IP_ADD_MEMBERSHIP_ip_mreq_cleanup()
{
@@ -111,6 +132,19 @@ IP_ADD_MEMBERSHIP_ip_mreqn_body()
0.0.0.0 6676 233.252.0.1 6676 ${epair2}a hello
atf_check -s exit:0 sh -c "wait $pid; exit $?"
atf_check -s exit:0 -o inline:"192.0.3.1:6676 hello\n" cat out
+
+ # try to join group on the interface determined by the route lookup
+ atf_check -s exit:71 -e inline:"multicast-receive: setsockopt: Can't assign requested address\n" \
+ jexec mjail2 $(atf_get_srcdir)/multicast-receive \
+ ip_mreqn 233.252.0.1 6676 0
+ # add route and try again
+ jexec mjail2 route add default 192.0.3.254
+ multicast_join ip_mreqn 0
+ atf_check -s exit:0 -o empty \
+ jexec mjail1 $(atf_get_srcdir)/multicast-send \
+ 0.0.0.0 6676 233.252.0.1 6676 192.0.3.1 hello
+ atf_check -s exit:0 sh -c "wait $pid; exit $?"
+ atf_check -s exit:0 -o inline:"192.0.3.1:6676 hello\n" cat out
}
IP_ADD_MEMBERSHIP_ip_mreqn_cleanup()
{
@@ -143,6 +177,19 @@ MCAST_JOIN_GROUP_body()
0.0.0.0 6676 233.252.0.1 6676 ${epair2}a hello
atf_check -s exit:0 sh -c "wait $pid; exit $?"
atf_check -s exit:0 -o inline:"192.0.3.1:6676 hello\n" cat out
+
+ # try to join group on the interface determined by the route lookup
+ atf_check -s exit:71 -e inline:"multicast-receive: setsockopt: Can't assign requested address\n" \
+ jexec mjail2 $(atf_get_srcdir)/multicast-receive \
+ group_req 233.252.0.1 6676 0
+ # add route and try again
+ jexec mjail2 route add default 192.0.3.254
+ multicast_join group_req 0
+ atf_check -s exit:0 -o empty \
+ jexec mjail1 $(atf_get_srcdir)/multicast-send \
+ 0.0.0.0 6676 233.252.0.1 6676 192.0.3.1 hello
+ atf_check -s exit:0 sh -c "wait $pid; exit $?"
+ atf_check -s exit:0 -o inline:"192.0.3.1:6676 hello\n" cat out
}
MCAST_JOIN_GROUP_cleanup()
{