2023-05-10 11:22:21

by Andrea Mayer

[permalink] [raw]
Subject: [net 2/2] selftets: seg6: disable rp_filter by default in srv6_end_dt4_l3vpn_test

On some distributions, the rp_filter is automatically set (=1) by
default on a netdev basis (also on VRFs).
In an SRv6 End.DT4 behavior, decapsulated IPv4 packets are routed using
the table associated with the VRF bound to that tunnel. During lookup
operations, the rp_filter can lead to packet loss when activated on the
VRF.
Therefore, we chose to make this selftest more robust by explicitly
disabling the rp_filter during tests (as it is automatically set by some
Linux distributions).

Fixes: 2195444e09b4 ("selftests: add selftest for the SRv6 End.DT4 behavior")
Reported-by: Hangbin Liu <[email protected]>
Signed-off-by: Andrea Mayer <[email protected]>
Tested-by: Hangbin Liu <[email protected]>
---
.../testing/selftests/net/srv6_end_dt4_l3vpn_test.sh | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/srv6_end_dt4_l3vpn_test.sh b/tools/testing/selftests/net/srv6_end_dt4_l3vpn_test.sh
index 37f08d582d2f..f96282362811 100755
--- a/tools/testing/selftests/net/srv6_end_dt4_l3vpn_test.sh
+++ b/tools/testing/selftests/net/srv6_end_dt4_l3vpn_test.sh
@@ -258,6 +258,12 @@ setup_hs()

# set the networking for the host
ip netns add ${hsname}
+
+ # disable the rp_filter otherwise the kernel gets confused about how
+ # to route decap ipv4 packets.
+ ip netns exec ${rtname} sysctl -wq net.ipv4.conf.all.rp_filter=0
+ ip netns exec ${rtname} sysctl -wq net.ipv4.conf.default.rp_filter=0
+
ip -netns ${hsname} link add veth0 type veth peer name ${rtveth}
ip -netns ${hsname} link set ${rtveth} netns ${rtname}
ip -netns ${hsname} addr add ${IPv4_HS_NETWORK}.${hs}/24 dev veth0
@@ -276,11 +282,6 @@ setup_hs()

ip netns exec ${rtname} sysctl -wq net.ipv4.conf.${rtveth}.proxy_arp=1

- # disable the rp_filter otherwise the kernel gets confused about how
- # to route decap ipv4 packets.
- ip netns exec ${rtname} sysctl -wq net.ipv4.conf.all.rp_filter=0
- ip netns exec ${rtname} sysctl -wq net.ipv4.conf.${rtveth}.rp_filter=0
-
ip netns exec ${rtname} sh -c "echo 1 > /proc/sys/net/vrf/strict_mode"
}

--
2.20.1



2023-05-10 20:12:54

by David Ahern

[permalink] [raw]
Subject: Re: [net 2/2] selftets: seg6: disable rp_filter by default in srv6_end_dt4_l3vpn_test

On 5/10/23 5:16 AM, Andrea Mayer wrote:
> On some distributions, the rp_filter is automatically set (=1) by
> default on a netdev basis (also on VRFs).
> In an SRv6 End.DT4 behavior, decapsulated IPv4 packets are routed using
> the table associated with the VRF bound to that tunnel. During lookup
> operations, the rp_filter can lead to packet loss when activated on the
> VRF.
> Therefore, we chose to make this selftest more robust by explicitly
> disabling the rp_filter during tests (as it is automatically set by some
> Linux distributions).
>
> Fixes: 2195444e09b4 ("selftests: add selftest for the SRv6 End.DT4 behavior")
> Reported-by: Hangbin Liu <[email protected]>
> Signed-off-by: Andrea Mayer <[email protected]>
> Tested-by: Hangbin Liu <[email protected]>
> ---
> .../testing/selftests/net/srv6_end_dt4_l3vpn_test.sh | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>

Reviewed-by: David Ahern <[email protected]>