aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/netinet/multicast.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/sys/netinet/multicast.sh')
-rwxr-xr-xtests/sys/netinet/multicast.sh76
1 files changed, 63 insertions, 13 deletions
diff --git a/tests/sys/netinet/multicast.sh b/tests/sys/netinet/multicast.sh
index a3854fd2fd20..34094ff08705 100755
--- a/tests/sys/netinet/multicast.sh
+++ b/tests/sys/netinet/multicast.sh
@@ -45,6 +45,15 @@ multicast_vnet_init()
jexec mjail2 ifconfig ${epair2}b 192.0.3.2/24
}
+multicast_join()
+{
+ jexec mjail2 $(atf_get_srcdir)/multicast-receive \
+ $1 233.252.0.1 6676 $2 > out & pid=$!
+ while ! jexec mjail2 ifmcstat | grep -q 233\.252\.0\.1; do
+ sleep 0.01
+ done
+}
+
atf_test_case "IP_ADD_MEMBERSHIP_ip_mreq" "cleanup"
IP_ADD_MEMBERSHIP_ip_mreq_head()
{
@@ -56,8 +65,7 @@ IP_ADD_MEMBERSHIP_ip_mreq_body()
multicast_vnet_init
# join group on interface with IP address 192.0.2.2
- jexec mjail2 $(atf_get_srcdir)/multicast-receive \
- ip_mreq 233.252.0.1 6676 192.0.2.2 > out & pid=$!
+ multicast_join ip_mreq 192.0.2.2
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
@@ -65,8 +73,28 @@ IP_ADD_MEMBERSHIP_ip_mreq_body()
atf_check -s exit:0 -o inline:"192.0.2.1:6676 hello\n" cat out
# join group on interface with IP address 192.0.3.2
- jexec mjail2 $(atf_get_srcdir)/multicast-receive \
- ip_mreq 233.252.0.1 6676 192.0.3.2 > out & pid=$!
+ multicast_join ip_mreq 192.0.3.2
+ 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
+
+ # 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
@@ -90,8 +118,7 @@ IP_ADD_MEMBERSHIP_ip_mreqn_body()
multicast_vnet_init
# join group on interface epair2
- jexec mjail2 $(atf_get_srcdir)/multicast-receive \
- ip_mreqn 233.252.0.1 6676 ${epair1}b > out & pid=$!
+ multicast_join ip_mreqn ${epair1}b
atf_check -s exit:0 -o empty \
jexec mjail1 $(atf_get_srcdir)/multicast-send \
0.0.0.0 6676 233.252.0.1 6676 ${epair1}a hello
@@ -99,13 +126,25 @@ IP_ADD_MEMBERSHIP_ip_mreqn_body()
atf_check -s exit:0 -o inline:"192.0.2.1:6676 hello\n" cat out
# join group on interface epair2
- jexec mjail2 $(atf_get_srcdir)/multicast-receive \
- ip_mreqn 233.252.0.1 6676 ${epair2}b > out & pid=$!
+ multicast_join ip_mreqn ${epair2}b
atf_check -s exit:0 -o empty \
jexec mjail1 $(atf_get_srcdir)/multicast-send \
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()
{
@@ -123,9 +162,8 @@ MCAST_JOIN_GROUP_body()
{
multicast_vnet_init
- # join group on interface epair2
- jexec mjail2 $(atf_get_srcdir)/multicast-receive \
- group_req 233.252.0.1 6676 ${epair1}b > out & pid=$!
+ # join group on interface epair1
+ multicast_join group_req ${epair1}b
atf_check -s exit:0 -o empty \
jexec mjail1 $(atf_get_srcdir)/multicast-send \
0.0.0.0 6676 233.252.0.1 6676 ${epair1}a hello
@@ -133,13 +171,25 @@ MCAST_JOIN_GROUP_body()
atf_check -s exit:0 -o inline:"192.0.2.1:6676 hello\n" cat out
# join group on interface epair2
- jexec mjail2 $(atf_get_srcdir)/multicast-receive \
- group_req 233.252.0.1 6676 ${epair2}b > out & pid=$!
+ multicast_join group_req ${epair2}b
atf_check -s exit:0 -o empty \
jexec mjail1 $(atf_get_srcdir)/multicast-send \
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()
{