Skip to content

Commit f23cddc

Browse files
vladimirolteandavem330
authored andcommitted
selftests: forwarding: add helpers for IP multicast group joins/leaves
Extend the forwarding library with calls to some small C programs which join an IP multicast group and send some packets to it. Both IPv4 and IPv6 groups are supported. Use cases range from testing IGMP/MLD snooping, to RX filtering, to multicast routing. Testing multicast traffic using msend/mreceive is intended to be done using tcpdump. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6182c5c commit f23cddc

File tree

1 file changed

+38
-0
lines changed
  • tools/testing/selftests/net/forwarding

1 file changed

+38
-0
lines changed

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ INTERFACE_TIMEOUT=${INTERFACE_TIMEOUT:=600}
2727
LOW_AGEING_TIME=${LOW_AGEING_TIME:=1000}
2828
REQUIRE_JQ=${REQUIRE_JQ:=yes}
2929
REQUIRE_MZ=${REQUIRE_MZ:=yes}
30+
REQUIRE_MTOOLS=${REQUIRE_MTOOLS:=no}
3031
STABLE_MAC_ADDRS=${STABLE_MAC_ADDRS:=no}
3132
TCPDUMP_EXTRA_FLAGS=${TCPDUMP_EXTRA_FLAGS:=}
3233

@@ -161,6 +162,12 @@ fi
161162
if [[ "$REQUIRE_MZ" = "yes" ]]; then
162163
require_command $MZ
163164
fi
165+
if [[ "$REQUIRE_MTOOLS" = "yes" ]]; then
166+
# https://github.com/vladimiroltean/mtools/
167+
# patched for IPv6 support
168+
require_command msend
169+
require_command mreceive
170+
fi
164171

165172
if [[ ! -v NUM_NETIFS ]]; then
166173
echo "SKIP: importer does not define \"NUM_NETIFS\""
@@ -1548,6 +1555,37 @@ brmcast_check_sg_state()
15481555
done
15491556
}
15501557

1558+
mc_join()
1559+
{
1560+
local if_name=$1
1561+
local group=$2
1562+
local vrf_name=$(master_name_get $if_name)
1563+
1564+
# We don't care about actual reception, just about joining the
1565+
# IP multicast group and adding the L2 address to the device's
1566+
# MAC filtering table
1567+
ip vrf exec $vrf_name \
1568+
mreceive -g $group -I $if_name > /dev/null 2>&1 &
1569+
mreceive_pid=$!
1570+
1571+
sleep 1
1572+
}
1573+
1574+
mc_leave()
1575+
{
1576+
kill "$mreceive_pid" && wait "$mreceive_pid"
1577+
}
1578+
1579+
mc_send()
1580+
{
1581+
local if_name=$1
1582+
local groups=$2
1583+
local vrf_name=$(master_name_get $if_name)
1584+
1585+
ip vrf exec $vrf_name \
1586+
msend -g $groups -I $if_name -c 1 > /dev/null 2>&1
1587+
}
1588+
15511589
start_ip_monitor()
15521590
{
15531591
local mtype=$1; shift

0 commit comments

Comments
 (0)