Skip to contentSkip to conversation

selftests: wireguard: load nf_conntrack if it's not present

PATCH Superseded Hangbin Liu 2 participants 2 messages Nov 7, 2024 – Nov 10, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: wireguard: load nf_conntrack if it's not present

Some distros may not load nf_conntrack by default, which will cause subsequent nf_conntrack settings to fail. Let's load this module if it's not loaded by default.

Fixes e7096c131e51 ("net: WireGuard secure network tunnel")
---
 tools/testing/selftests/wireguard/netns.sh | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/wireguard/netns.sh +1 -0
index 405ff262ca93..508b391e8d9a 100755
@@ -66,6 +66,7 @@ cleanup() {
 orig_message_cost="$(< /proc/sys/net/core/message_cost)"
 trap cleanup EXIT
 printf 0 > /proc/sys/net/core/message_cost
+lsmod | grep -q nf_conntrack || modprobe nf_conntrack
 
 ip netns del $netns0 2>/dev/null || true
 ip netns del $netns1 2>/dev/null || true
Signature · 1 line
2.46.0
reviewer
#1 lore raw
Quoted 15 lines · Hangbin Liu

Some distros may not load nf_conntrack by default, which will cause subsequent nf_conntrack settings to fail. Let's load this module if it's not loaded by default.

Fixes e7096c131e51 ("net: WireGuard secure network tunnel")
---
 tools/testing/selftests/wireguard/netns.sh | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/wireguard/netns.sh +0 -0
index 405ff262ca93..508b391e8d9a 100755

tools/testing/selftests/wireguard/netns.sh cleanup() { · line 69

Quoted 4 lines
tools/testing/selftests/wireguard/netns.sh +1 -0
@@ -66,6 +66,7 @@ cleanup() {
 orig_message_cost="$(< /proc/sys/net/core/message_cost)"
 trap cleanup EXIT
 printf 0 > /proc/sys/net/core/message_cost
+lsmod | grep -q nf_conntrack || modprobe nf_conntrack

Hi Hangbin,

As modprobe should be idempotent both for the case were nf_conntrack is built-in (I'm unsure if that case can ever occur) and the module has already been inserted, I think you simply use:

modprobe nf_conntrack

Of course, if nf_conntrack isn't available at all, then this will fail. But that was the case with your patch too. And so I assume it is intended.

Quoted 7 lines
tools/testing/selftests/wireguard/netns.sh +0 -0
 ip netns del $netns0 2>/dev/null || true
 ip netns del $netns1 2>/dev/null || true
Signature · 1 line
2.46.0