]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests: forwarding: adf_mcd_start(): Allow configuring custom interfaces
authorPetr Machata <petrm@nvidia.com>
Mon, 16 Jun 2025 22:44:22 +0000 (00:44 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 18 Jun 2025 01:18:46 +0000 (18:18 -0700)
Tests may wish to add other interfaces to listen on. Notably locally
generated traffic uses dummy interfaces. The multicast daemon needs to know
about these so that it allows forming rules that involve these interfaces,
and so that net.ipv4.conf.X.mc_forwarding is set for the interfaces.

To that end, allow passing in a list of interfaces to configure in addition
to all the physical ones.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/2e8d83297985933be4850f2b9f296b3c27110388.1750113335.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/forwarding/lib.sh

index 253847372062eecb7e4e3e22e12268a313ef5ed4..83ee6a07e07206f64803feb5e94a558d46582a9d 100644 (file)
@@ -1760,9 +1760,12 @@ mc_send()
 
 adf_mcd_start()
 {
+       local ifs=("$@")
+
        local table_name="$MCD_TABLE_NAME"
        local smcroutedir
        local pid
+       local if
        local i
 
        check_command "$MCD" || return 1
@@ -1776,6 +1779,16 @@ adf_mcd_start()
                        "$smcroutedir/$table_name.conf"
        done
 
+       for if in "${ifs[@]}"; do
+               if ! ip_link_has_flag "$if" MULTICAST; then
+                       ip link set dev "$if" multicast on
+                       defer ip link set dev "$if" multicast off
+               fi
+
+               echo "phyint $if enable" >> \
+                       "$smcroutedir/$table_name.conf"
+       done
+
        "$MCD" -N -I "$table_name" -f "$smcroutedir/$table_name.conf" \
                -P "$smcroutedir/$table_name.pid"
        busywait "$BUSYWAIT_TIMEOUT" test -e "$smcroutedir/$table_name.pid"