* [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables
@ 2026-09-04 7:31 Hangbin Liu
2026-09-04 7:31 ` [PATCH mptcp-next v3 1/2] selftests: mptcp: convert iptables to nftables for mptcp_sockopt.sh Hangbin Liu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Hangbin Liu @ 2026-09-04 7:31 UTC (permalink / raw)
To: MPTCP Linux; +Cc: Hangbin Liu, Hangbin Liu
iptables has been deprecated for years. The Linux kernel has included
nftables as the successor to iptables since 2014, and every major
distribution uses nftables as the default packet filtering framework.
The iptables command we run on modern systems is actually iptables‑nft,
a compatibility layer that translates iptables syntax to nftables rules
behind the scenes.
There are also some features that can be set easily with nft, while we need
to convert to BPF code under iptables, such as MPTCP add‑addr and
remove‑addr suboptions. To make future work easier, convert iptables usage
in mptcp to nftables.
For mptcp_join.sh, I add an init_nftables() function so we can only init
nftables when needed. With debug kernel on my 4 cpu vm, Here is the
total running time of mptcp_join.sh.
With iptables
real 35m44.460s
user 0m22.455s
sys 25m17.923s
With nft init on each init_partial (Last patch version)
real 43m37.393s
user 0m29.183s
sys 32m15.354s
With nft init only called needed (This patch version)
real 37m6.645s
user 0m25.325s
sys 27m10.385s
We only increase 1m22s compared with iptables.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
Changes in v3:
- Use jq to get the nft handle and drop count (Matthieu Baerts)
- Remove iptables/ip6tables and CONFIG_NFT_COMPAT since no one use it
after the conversion. (Matthieu Baerts)
- Add init_nftables() so we can only init the nf tables when needed (Matthieu Baerts)
- Bundle the nft init steps so we only need to call the nft binary once (Florian Westphal)
- Only get the nft_handle when needed and reset it before using (Matthieu Baerts)
- Link to v2: https://lore.kernel.org/r/20260903-mptcp_nft-v2-0-66283e4b9c3b@kylinos.cn
Changes in v2:
- Fix --sync and --tcp-flags RST convert not match issue (sashiko)
- make sure drop is a number in check_mark. (sashiko)
- Other than using one inet table, use ip/ip6 tables to retain the same
table and chain names used by the original iptables/ip6tables setup.
- Link to v1: https://lore.kernel.org/r/20260902-mptcp_nft-v1-0-559caa16f410@kylinos.cn
---
Hangbin Liu (2):
selftests: mptcp: convert iptables to nftables for mptcp_sockopt.sh
selftests: mptcp: convert iptables to nftables for mptcp_join.sh
tools/testing/selftests/net/mptcp/config | 4 +-
tools/testing/selftests/net/mptcp/mptcp_join.sh | 158 +++++++++------------
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 2 +-
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 64 +++++----
4 files changed, 107 insertions(+), 121 deletions(-)
---
base-commit: e9b3407fa4686e58a862f6889b18a4f422199261
change-id: 20260902-mptcp_nft-b892782ef929
Best regards,
--
Hangbin Liu <liuhangbin@kylinos.cn>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH mptcp-next v3 1/2] selftests: mptcp: convert iptables to nftables for mptcp_sockopt.sh
2026-09-04 7:31 [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables Hangbin Liu
@ 2026-09-04 7:31 ` Hangbin Liu
2026-09-04 7:31 ` [PATCH mptcp-next v3 2/2] selftests: mptcp: convert iptables to nftables for mptcp_join.sh Hangbin Liu
2026-09-04 8:41 ` [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables MPTCP CI
2 siblings, 0 replies; 6+ messages in thread
From: Hangbin Liu @ 2026-09-04 7:31 UTC (permalink / raw)
To: MPTCP Linux; +Cc: Hangbin Liu, Hangbin Liu
From: Hangbin Liu <liuhangbin@kylinos.cn>
During the conversion, we retain the same filter and chain names previously
used by iptables/ip6tables. Counters are not added to accept rules because
the test does not inspect them. After conversion, the generated output
matches the original iptables/ip6tables behavior.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 2 +-
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 64 ++++++++++++----------
2 files changed, 37 insertions(+), 29 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index b9d14647f401..e65b4ebee06a 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -528,7 +528,7 @@ mptcp_lib_check_tools() {
exit ${KSFT_SKIP}
fi
;;
- "iptables"* | "ip6tables"*)
+ "iptables"* | "ip6tables"* | "nft" | "jq")
if ! "${tool}" -V &> /dev/null; then
mptcp_lib_pr_skip "Could not run all tests without ${tool}"
exit ${KSFT_SKIP}
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index e850a87429b6..b4e3eddc9cf2 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -15,8 +15,6 @@ cin=""
cout=""
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
-iptables="iptables"
-ip6tables="ip6tables"
ns1=""
ns2=""
@@ -49,16 +47,27 @@ add_mark_rules()
local ns=$1
local m=$2
- local t
- for t in ${iptables} ${ip6tables}; do
- # just to debug: check we have multiple subflows connection requests
- ip netns exec $ns $t -A OUTPUT -p tcp --syn -m mark --mark $m -j ACCEPT
-
- # RST packets might be handled by a internal dummy socket
- ip netns exec $ns $t -A OUTPUT -p tcp --tcp-flags RST RST -m mark --mark 0 -j ACCEPT
-
- ip netns exec $ns $t -A OUTPUT -p tcp -m mark --mark $m -j ACCEPT
- ip netns exec $ns $t -A OUTPUT -p tcp -m mark --mark 0 -j DROP
+ local table
+ for table in ip ip6; do
+ ip netns exec "$ns" nft -f - <<-EOF
+ add table $table filter
+ add chain $table filter OUTPUT \
+ { type filter hook output priority 0; policy accept; }
+
+ # just to debug: check we have multiple subflows connection requests
+ add rule $table filter OUTPUT \
+ tcp flags & (fin | syn | rst | ack) == syn \
+ meta mark $m accept
+
+ # RST packets might be handled by a internal dummy socket
+ add rule $table filter OUTPUT \
+ tcp flags & rst == rst meta mark 0x0 accept
+
+ add rule $table filter OUTPUT \
+ meta l4proto tcp meta mark $m accept
+ add rule $table filter OUTPUT \
+ meta l4proto tcp meta mark 0 counter drop
+ EOF
done
}
@@ -105,32 +114,31 @@ cleanup()
mptcp_lib_check_mptcp
mptcp_lib_check_kallsyms
-mptcp_lib_check_tools ip "${iptables}" "${ip6tables}"
+mptcp_lib_check_tools ip nft jq
check_mark()
{
local ns=$1
local af=$2
- local tables=${iptables}
+ local tables="ip"
if [ $af -eq 6 ];then
- tables=${ip6tables}
+ tables="ip6"
fi
- local counters values
- counters=$(ip netns exec $ns $tables -v -L OUTPUT | grep DROP)
- values=${counters%DROP*}
-
- local v
- for v in $values; do
- if [ $v -ne 0 ]; then
- mptcp_lib_pr_fail "got $tables $values in ns $ns," \
- "not 0 - not all expected packets marked"
- ret=${KSFT_FAIL}
- return 1
- fi
- done
+ local drops
+ drops=$(ip netns exec "$ns" nft -j list table "$tables" filter | \
+ jq '.nftables[] | select(has("rule")) | .rule |
+ select (.chain=="OUTPUT" and any(.expr[]; has("drop"))) |
+ .expr[] | select(has("counter")) | .counter.packets')
+
+ if [ -z "$drops" ] || [ "$drops" -ne 0 ]; then
+ mptcp_lib_pr_fail "got $tables $drops in ns $ns," \
+ "not 0 - not all expected packets marked"
+ ret=${KSFT_FAIL}
+ return 1
+ fi
return 0
}
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH mptcp-next v3 2/2] selftests: mptcp: convert iptables to nftables for mptcp_join.sh
2026-09-04 7:31 [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables Hangbin Liu
2026-09-04 7:31 ` [PATCH mptcp-next v3 1/2] selftests: mptcp: convert iptables to nftables for mptcp_sockopt.sh Hangbin Liu
@ 2026-09-04 7:31 ` Hangbin Liu
2026-09-04 7:42 ` sashiko-bot
2026-09-04 8:41 ` [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables MPTCP CI
2 siblings, 1 reply; 6+ messages in thread
From: Hangbin Liu @ 2026-09-04 7:31 UTC (permalink / raw)
To: MPTCP Linux; +Cc: Hangbin Liu, Hangbin Liu
From: Hangbin Liu <liuhangbin@kylinos.cn>
During conversion, we retain the same table and chain names used by the
original iptables/ip6tables setup, so rule output is identical to the
former iptables/ip6tables output. Add new function init_nftables so we
only do nft table setup when test need set nft rules.
Unlike iptables, nftables cannot match rules based on their full
specification. Some test need to delete the rules we add, so add
variable nft_handle and reset it before adding nf tables.
The BPF bytecode matching MPTCP add‑addr and remove‑addr suboptions
is replaced with native nft matching using "tcp option mptcp subtype".
The config file adds CONFIG_NFT_NUMGEN (replaces iptables statistic nth),
CONFIG_NFT_REJECT and CONFIG_NFT_REJECT_INET for reject‑related rules.
Remove CONFIG_NFT_COMPAT since we don't need it now.
Remove the iptables/ip6tables check in mptcp_lib.sh since no script use
it now.
Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
tools/testing/selftests/net/mptcp/config | 4 +-
tools/testing/selftests/net/mptcp/mptcp_join.sh | 158 ++++++++++--------------
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 2 +-
3 files changed, 71 insertions(+), 93 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/config b/tools/testing/selftests/net/mptcp/config
index 59051ee2a986..25dd134b9907 100644
--- a/tools/testing/selftests/net/mptcp/config
+++ b/tools/testing/selftests/net/mptcp/config
@@ -29,7 +29,9 @@ CONFIG_NET_SCH_INGRESS=m
CONFIG_NET_SCH_NETEM=m
CONFIG_NF_TABLES=m
CONFIG_NF_TABLES_INET=y
-CONFIG_NFT_COMPAT=m
+CONFIG_NFT_NUMGEN=m
+CONFIG_NFT_REJECT=m
+CONFIG_NFT_REJECT_INET=m
CONFIG_NFT_SOCKET=m
CONFIG_NFT_TPROXY=m
CONFIG_SYN_COOKIES=y
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 18ce7136a2b0..835cb92cab1a 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -26,8 +26,6 @@ capout=""
cappid=""
ns1=""
ns2=""
-iptables="iptables"
-ip6tables="ip6tables"
timeout_poll=30
timeout_test=$((timeout_poll * 2 + 1))
capture=false
@@ -50,6 +48,7 @@ declare -A failed_tests
MPTCP_LIB_TEST_FORMAT="%03u %s\n"
TEST_NAME=""
nr_blank=6
+nft_handle=""
# These var are used only in some tests, make sure they are not already set
unset FAILING_LINKS
@@ -99,42 +98,6 @@ unset add_addr_tx_nr
unset add_addr_echo_tx_nr
unset add_addr_drop_tx_nr
-# generated using "nfbpf_compile '(ip && (ip[54] & 0xf0) == 0x30) ||
-# (ip6 && (ip6[74] & 0xf0) == 0x30)'"
-CBPF_MPTCP_SUBOPTION_ADD_ADDR="14,
- 48 0 0 0,
- 84 0 0 240,
- 21 0 3 64,
- 48 0 0 54,
- 84 0 0 240,
- 21 6 7 48,
- 48 0 0 0,
- 84 0 0 240,
- 21 0 4 96,
- 48 0 0 74,
- 84 0 0 240,
- 21 0 1 48,
- 6 0 0 65535,
- 6 0 0 0"
-
-# IPv4: TCP hdr of 48B, a first suboption of 12B (DACK8), the RM_ADDR suboption
-# generated using "nfbpf_compile '(ip[32] & 0xf0) == 0xc0 && ip[53] == 0x0c &&
-# (ip[66] & 0xf0) == 0x40'"
-CBPF_MPTCP_SUBOPTION_RM_ADDR="13,
- 48 0 0 0,
- 84 0 0 240,
- 21 0 9 64,
- 48 0 0 32,
- 84 0 0 240,
- 21 0 6 192,
- 48 0 0 53,
- 21 0 4 12,
- 48 0 0 66,
- 84 0 0 240,
- 21 0 1 64,
- 6 0 0 65535,
- 6 0 0 0"
-
init_partial()
{
capout=$(mktemp)
@@ -184,6 +147,28 @@ init_shapers()
done
}
+init_nftables()
+{
+ nft_handle=""
+
+ local netns table
+ for netns in "$ns1" "$ns2"; do
+ for table in ip ip6; do
+ ip netns exec "$netns" nft -f - <<-EOF
+ add table $table filter
+ add chain $table filter INPUT \
+ { type filter hook input priority filter; policy accept; }
+ add chain $table filter OUTPUT \
+ { type filter hook output priority filter; policy accept; }
+
+ table $table mangle
+ chain $table mangle OUTPUT \
+ { type route hook output priority mangle; policy accept; }
+ EOF
+ done
+ done
+}
+
cleanup_partial()
{
rm -f "$capout"
@@ -196,7 +181,7 @@ init() {
mptcp_lib_check_mptcp
mptcp_lib_check_kallsyms
- mptcp_lib_check_tools ip tc ss "${iptables}" "${ip6tables}"
+ mptcp_lib_check_tools ip tc ss nft jq
sin=$(mktemp)
sout=$(mktemp)
@@ -380,24 +365,18 @@ reset_with_cookies()
# $1: test name
reset_with_add_addr_timeout()
{
- local ip="${2:-4}"
- local tables
+ local ip="${2:-}"
reset "${1}" || return 1
-
- tables="${iptables}"
- if [ $ip -eq 6 ]; then
- tables="${ip6tables}"
- fi
+ init_nftables
# set a maximum, to avoid too long timeout with exponential backoff
ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
- if ! ip netns exec $ns2 $tables -A OUTPUT -p tcp \
- -m tcp --tcp-option 30 \
- -m bpf --bytecode \
- "$CBPF_MPTCP_SUBOPTION_ADD_ADDR" \
- -j DROP; then
+ if ! ip netns exec "$ns2" nft add rule \
+ ip"$ip" filter OUTPUT meta l4proto tcp \
+ tcp option mptcp subtype add-addr \
+ drop; then
mark_as_skipped "unable to set the 'add addr' rule"
return 1
fi
@@ -449,22 +428,14 @@ setup_fail_rules()
check_invert=1
validate_checksum=true
local i="$1"
- local ip="${2:-4}"
- local tables
+ local ip="${2:-}"
- tables="${iptables}"
- if [ $ip -eq 6 ]; then
- tables="${ip6tables}"
- fi
-
- ip netns exec $ns2 $tables \
- -t mangle \
- -A OUTPUT \
- -o ns2eth$i \
- -p tcp \
- -m length --length 150:9999 \
- -m statistic --mode nth --packet 1 --every 99999 \
- -j MARK --set-mark 42 || return ${KSFT_SKIP}
+ init_nftables
+ ip netns exec "$ns2" nft add rule \
+ ip"$ip" mangle OUTPUT oifname ns2eth$i \
+ meta l4proto tcp \
+ meta length 150-9999 numgen inc mod 99999 1 \
+ meta mark set 42 || return ${KSFT_SKIP}
tc -n $ns2 qdisc add dev ns2eth$i clsact || return ${KSFT_SKIP}
tc -n $ns2 filter add dev ns2eth$i egress \
@@ -510,16 +481,19 @@ reset_with_tcp_filter()
reset "${1}" || return 1
shift
+ init_nftables
+
local ns="${!1}"
local src="${2}"
local target="${3}"
local chain="${4:-INPUT}"
- if ! ip netns exec "${ns}" ${iptables} \
- -A "${chain}" \
- -s "${src}" \
- -p tcp \
- -j "${target}"; then
+ # Capture nft handle as endpoint_tests() need it
+ nft_handle=$(ip netns exec "$ns" nft -e --json add rule \
+ ip filter "${chain}" ip saddr "${src}" \
+ meta l4proto tcp "${target,,}" | \
+ jq '.nftables[] | select(has("add")) | .add.rule.handle')
+ if [ -z "$nft_handle" ]; then
mark_as_skipped "unable to set the filter rules"
return 1
fi
@@ -4313,12 +4287,15 @@ userspace_tests()
chk_mptcp_info subflows 1 subflows 1
chk_subflows_total 2 2
+ init_nftables
# force quick loss
ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_retries=1
- if ip netns exec "${ns1}" ${iptables} -A INPUT -s "10.0.1.2" \
- -p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset &&
- ip netns exec "${ns2}" ${iptables} -A INPUT -d "10.0.1.2" \
- -p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset; then
+ if ip netns exec "${ns1}" nft add rule ip filter INPUT \
+ ip saddr "10.0.1.2" meta l4proto tcp \
+ tcp option mptcp exists reject with tcp reset &&
+ ip netns exec "${ns2}" nft add rule ip filter INPUT \
+ ip daddr "10.0.1.2" meta l4proto tcp \
+ tcp option mptcp exists reject with tcp reset; then
wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1
wait_event ns1 MPTCP_LIB_EVENT_SUB_CLOSED 1
chk_subflows_total 1 1
@@ -4393,7 +4370,7 @@ endpoint_tests()
chk_subflow_nr "after new reject" 2
chk_mptcp_info subflows 1 subflows 1
- ip netns exec "${ns2}" ${iptables} -D OUTPUT -s "10.0.3.2" -p tcp -j REJECT
+ ip netns exec "${ns2}" nft delete rule ip filter OUTPUT handle "$nft_handle"
pm_nl_del_endpoint $ns2 3 10.0.3.2
pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow
wait_mpj 3
@@ -4402,12 +4379,10 @@ endpoint_tests()
# To make sure RM_ADDR are sent over a different subflow, but
# allow the rest to quickly and cleanly close the subflow
- local ipt=1
- ip netns exec "${ns2}" ${iptables} -I OUTPUT -s "10.0.1.2" \
- -p tcp -m tcp --tcp-option 30 \
- -m bpf --bytecode \
- "$CBPF_MPTCP_SUBOPTION_RM_ADDR" \
- -j DROP || ipt=0
+ nft_handle=$(ip netns exec "${ns2}" nft -e --json insert rule \
+ ip filter OUTPUT ip saddr 10.0.1.2 meta l4proto tcp \
+ tcp option mptcp subtype remove-addr drop | \
+ jq '.nftables[] | select(has("insert")) | .insert.rule.handle')
local i
for i in $(seq 3); do
pm_nl_del_endpoint $ns2 1 10.0.1.2
@@ -4420,7 +4395,8 @@ endpoint_tests()
chk_subflow_nr "after re-add id 0 ($i)" 3
chk_mptcp_info subflows 3 subflows 3
done
- [ ${ipt} = 1 ] && ip netns exec "${ns2}" ${iptables} -D OUTPUT 1
+ [ -n "${nft_handle}" ] && ip netns exec "${ns2}" nft delete rule \
+ ip filter OUTPUT handle "${nft_handle}"
mptcp_lib_kill_group_wait $tests_pid
@@ -4480,20 +4456,20 @@ endpoint_tests()
chk_mptcp_info subflows 2 subflows 2
chk_mptcp_info add_addr_signal 2 add_addr_accepted 2
+ init_nftables
# To make sure RM_ADDR are sent over a different subflow, but
# allow the rest to quickly and cleanly close the subflow
- local ipt=1
- ip netns exec "${ns1}" ${iptables} -I OUTPUT -s "10.0.1.1" \
- -p tcp -m tcp --tcp-option 30 \
- -m bpf --bytecode \
- "$CBPF_MPTCP_SUBOPTION_RM_ADDR" \
- -j DROP || ipt=0
+ nft_handle=$(ip netns exec "${ns1}" nft -e --json insert rule \
+ ip filter OUTPUT ip saddr 10.0.1.1 meta l4proto tcp \
+ tcp option mptcp subtype remove-addr drop | \
+ jq '.nftables[] | select(has("insert")) | .insert.rule.handle')
pm_nl_del_endpoint $ns1 42 10.0.1.1
sleep 0.5
chk_subflow_nr "after delete ID 0" 2
chk_mptcp_info subflows 2 subflows 2
chk_mptcp_info add_addr_signal 2 add_addr_accepted 2
- [ ${ipt} = 1 ] && ip netns exec "${ns1}" ${iptables} -D OUTPUT 1
+ [ -n "${nft_handle}" ] && ip netns exec "${ns1}" nft delete rule \
+ ip filter OUTPUT handle "${nft_handle}"
pm_nl_add_endpoint $ns1 10.0.1.1 id 42 flags signal
wait_mpj 4
@@ -4555,7 +4531,7 @@ endpoint_tests()
pm_nl_flush_endpoint $ns2
pm_nl_flush_endpoint $ns1
wait_rm_addr $ns2 0
- ip netns exec "${ns2}" ${iptables} -D OUTPUT -s "10.0.3.2" -p tcp -j REJECT
+ ip netns exec "${ns2}" nft delete rule ip filter OUTPUT handle "$nft_handle"
pm_nl_add_endpoint $ns2 10.0.3.2 id 3 flags subflow
wait_mpj 1
pm_nl_add_endpoint $ns1 10.0.3.1 id 2 flags signal
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index e65b4ebee06a..0559bb168203 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -528,7 +528,7 @@ mptcp_lib_check_tools() {
exit ${KSFT_SKIP}
fi
;;
- "iptables"* | "ip6tables"* | "nft" | "jq")
+ "nft" | "jq")
if ! "${tool}" -V &> /dev/null; then
mptcp_lib_pr_skip "Could not run all tests without ${tool}"
exit ${KSFT_SKIP}
--
2.55.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH mptcp-next v3 2/2] selftests: mptcp: convert iptables to nftables for mptcp_join.sh
2026-09-04 7:31 ` [PATCH mptcp-next v3 2/2] selftests: mptcp: convert iptables to nftables for mptcp_join.sh Hangbin Liu
@ 2026-09-04 7:42 ` sashiko-bot
2026-09-04 9:33 ` Hangbin Liu
0 siblings, 1 reply; 6+ messages in thread
From: sashiko-bot @ 2026-09-04 7:42 UTC (permalink / raw)
To: Hangbin Liu; +Cc: mptcp
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing 'add' keyword in nftables configuration script causes syntax error, silently skipping tests.
--
commit 45eaf6e2e654e036380de79d25fbc989c2055da7
Author: Hangbin Liu <liuhangbin@kylinos.cn>
selftests: mptcp: convert iptables to nftables for mptcp_join.sh
This commit replaces the iptables/ip6tables setup with nftables in the
mptcp_join.sh selftest. It introduces a new init_nftables function to setup
the nft tables using a heredoc rather than configuring them inline.
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 18ce7136a2b0e..835cb92cab1a4 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
[ ... ]
> @@ -184,6 +147,28 @@ init_shapers()
> done
> }
>
> +init_nftables()
> +{
> + nft_handle=""
> +
> + local netns table
> + for netns in "$ns1" "$ns2"; do
> + for table in ip ip6; do
> + ip netns exec "$netns" nft -f - <<-EOF
> + add table $table filter
> + add chain $table filter INPUT \
> + { type filter hook input priority filter; policy accept; }
> + add chain $table filter OUTPUT \
> + { type filter hook output priority filter; policy accept; }
> +
> + table $table mangle
> + chain $table mangle OUTPUT \
^^^^
[Severity: Medium]
Are these table and chain declarations missing the "add" keyword?
The filter table rules above them use "add table" and "add chain", but the
mangle declarations omit "add". Does this syntax error cause the "nft -f -"
command to fail and abort the entire transaction, preventing the creation of
both the filter and mangle tables?
If the tables aren't created, subsequent "nft add rule" commands, like those
in setup_fail_rules() or reset_with_add_addr_timeout(), will fail. This
appears to cause the affected fault-injection and filtering tests to be
silently skipped rather than executed.
> + { type route hook output priority mangle; policy accept; }
> + EOF
> + done
> + done
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mptcp_nft-v3-0-4abedaf00bf9@kylinos.cn?part=2
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables
2026-09-04 7:31 [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables Hangbin Liu
2026-09-04 7:31 ` [PATCH mptcp-next v3 1/2] selftests: mptcp: convert iptables to nftables for mptcp_sockopt.sh Hangbin Liu
2026-09-04 7:31 ` [PATCH mptcp-next v3 2/2] selftests: mptcp: convert iptables to nftables for mptcp_join.sh Hangbin Liu
@ 2026-09-04 8:41 ` MPTCP CI
2 siblings, 0 replies; 6+ messages in thread
From: MPTCP CI @ 2026-09-04 8:41 UTC (permalink / raw)
To: Hangbin Liu; +Cc: mptcp
Hi Hangbin,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Unstable: 1 failed test(s): selftest_mptcp_connect ⚠️
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/33850602816
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/54e93a0f92b7
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1157667
If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normal
For more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH mptcp-next v3 2/2] selftests: mptcp: convert iptables to nftables for mptcp_join.sh
2026-09-04 7:42 ` sashiko-bot
@ 2026-09-04 9:33 ` Hangbin Liu
0 siblings, 0 replies; 6+ messages in thread
From: Hangbin Liu @ 2026-09-04 9:33 UTC (permalink / raw)
To: sashiko-reviews; +Cc: mptcp
On Fri, Sep 04, 2026 at 07:42:06AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Missing 'add' keyword in nftables configuration script causes syntax error, silently skipping tests.
> --
>
> commit 45eaf6e2e654e036380de79d25fbc989c2055da7
> Author: Hangbin Liu <liuhangbin@kylinos.cn>
>
> selftests: mptcp: convert iptables to nftables for mptcp_join.sh
>
> This commit replaces the iptables/ip6tables setup with nftables in the
> mptcp_join.sh selftest. It introduces a new init_nftables function to setup
> the nft tables using a heredoc rather than configuring them inline.
>
> > diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > index 18ce7136a2b0e..835cb92cab1a4 100755
> > --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> > +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
>
> [ ... ]
>
> > @@ -184,6 +147,28 @@ init_shapers()
> > done
> > }
> >
> > +init_nftables()
> > +{
> > + nft_handle=""
> > +
> > + local netns table
> > + for netns in "$ns1" "$ns2"; do
> > + for table in ip ip6; do
> > + ip netns exec "$netns" nft -f - <<-EOF
> > + add table $table filter
> > + add chain $table filter INPUT \
> > + { type filter hook input priority filter; policy accept; }
> > + add chain $table filter OUTPUT \
> > + { type filter hook output priority filter; policy accept; }
> > +
> > + table $table mangle
> > + chain $table mangle OUTPUT \
> ^^^^
>
> [Severity: Medium]
> Are these table and chain declarations missing the "add" keyword?
>
Ah, copy‑and‑paste error. But the test passed when I run it.
After investigating, I found the interesting usage for nft. Both
nft -f - <<-EOF
add table ...
add chain ..
EOF
and
nft -f - <<-EOF
table ...
chain ..
EOF
Works!
Anyway, I will sync the writing in next version (if have) to not miss-leading
others.
Thanks
Hangbin
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-04 9:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04 7:31 [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables Hangbin Liu
2026-09-04 7:31 ` [PATCH mptcp-next v3 1/2] selftests: mptcp: convert iptables to nftables for mptcp_sockopt.sh Hangbin Liu
2026-09-04 7:31 ` [PATCH mptcp-next v3 2/2] selftests: mptcp: convert iptables to nftables for mptcp_join.sh Hangbin Liu
2026-09-04 7:42 ` sashiko-bot
2026-09-04 9:33 ` Hangbin Liu
2026-09-04 8:41 ` [PATCH mptcp-next v3 0/2] selftests: mptcp: convert iptables to nftables MPTCP CI
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox