All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH mptcp-next] squash to "selftests: mptcp: convert iptables to nftables for mptcp_join.sh"
@ 2026-10-09  7:27 Hangbin Liu
  2026-10-09  7:31 ` sashiko-bot
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Hangbin Liu @ 2026-10-09  7:27 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Hangbin Liu, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

After squash, the new commit description could be:

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. The syn mark rule is removed as it is
only for debugging, which could be added easily when needed.

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_sockopt.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index b4e3eddc9cf2..ef2738720e24 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -54,11 +54,6 @@ add_mark_rules()
 			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

---
base-commit: 5ac58fb7c561392ec051c390479ca746c42ca989
change-id: 20261009-mptcp_rm_debug-27ffeedc78aa

Best regards,
-- 
Hangbin Liu <liuhangbin@kylinos.cn>


^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH mptcp-next] Squash to "selftests: mptcp: convert iptables to nftables for mptcp_join.sh"
@ 2026-10-09  7:26 Hangbin Liu
  2026-10-09  8:23 ` MPTCP CI
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Hangbin Liu @ 2026-10-09  7:26 UTC (permalink / raw)
  To: MPTCP Linux; +Cc: Hangbin Liu, Hangbin Liu

From: Hangbin Liu <liuhangbin@kylinos.cn>

After squash, the new commit description could be:

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. Since endpoint_tests is the only test that delete rules,
which inserts and deletes rules one by one. Flushing the table
directly is safe and easier than using nft_handle.

The cBPF bytecode matching MPTCP add‑addr is replaced with native nft
matching using "tcp option mptcp subtype add-addr". But the RM_ADDR
suboption is added after the MPTCP DSS option, and nft is unable to
handle this because it stops parsing further TCP options once it matches
the first one. We therefore use hard-coded offsets to match the RM_ADDR
suboption.

The config file adds CONFIG_NFT_NUMGEN (replaces iptables statistic nth),
CONFIG_NFT_REJECT and CONFIG_NFT_REJECT_INET for reject‑related rules.
Remove other unneeded configs.

Remove the iptables/ip6tables check in mptcp_lib.sh since no script use
it now.

Signed-off-by: Hangbin Liu <liuhangbin@kylinos.cn>
---
Tested with this nft rule and I can see it captures the rm-addr pkts

chain OUTPUT {
        type filter hook output priority filter; policy accept;
        ip saddr 10.0.2.2 tcp doff 12 @th,256,16 0x1e0c @th,352,8 0x1e @th,368,8 & 0xf0 == 0x40 counter packets 3 bytes 204 accept
        ip saddr 10.0.1.2 tcp doff 12 @th,256,16 0x1e0c @th,352,8 0x1e @th,368,8 & 0xf0 == 0x40 drop
}
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index b16e24418e73..cf079c18af12 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -97,6 +97,20 @@ unset add_addr_tx_nr
 unset add_addr_echo_tx_nr
 unset add_addr_drop_tx_nr
 
+# A tcpdump capture of the RM_ADDR message looks like:
+#
+#   [TCP header: 20 bytes] [nop] [nop] [timestamp: 10 bytes] \
+#         [MPTCP DSS: 12 bytes] [MPTCP RM_ADDR: 4 bytes]
+#
+# nft cannot process the RM_ADDR option because it stops parsing after
+# matching the first DSS option. Use hard-coded byte offsets to match
+# RM_ADDR messages. We verify:
+#
+# TCP Data Offset (12 x 4 = 48 bytes), DSS (TCP[32] x 8) kind (MPTCP 0x1e)
+# and length (0x0c). RM_ADDR (TCP[44] x 8) kind (MPTCP 0x1e) and subtype (4)
+
+RM_ADDR_OFFSETS="tcp doff 12 @th,256,16 == 0x1e0c @th,352,8 == 0x1e @th,368,4 == 4"
+
 init_partial()
 {
 	capout=$(mktemp)
@@ -4375,7 +4389,7 @@ endpoint_tests()
 		local nft=1
 		ip netns exec "${ns2}" nft insert rule ip filter OUTPUT \
 			ip saddr 10.0.1.2 meta l4proto tcp \
-			tcp option mptcp subtype remove-addr drop || nft=0
+			"${RM_ADDR_OFFSETS}" drop || nft=0
 		local i
 		for i in $(seq 3); do
 			pm_nl_del_endpoint $ns2 1 10.0.1.2
@@ -4454,7 +4468,7 @@ endpoint_tests()
 		local nft=1
 		ip netns exec "${ns1}" nft insert rule ip filter OUTPUT \
 			ip saddr 10.0.1.1 meta l4proto tcp \
-			tcp option mptcp subtype remove-addr drop || nft=0
+			"${RM_ADDR_OFFSETS}" drop || nft=0
 		pm_nl_del_endpoint $ns1 42 10.0.1.1
 		sleep 0.5
 		chk_subflow_nr "after delete ID 0" 2

---
base-commit: 5ac58fb7c561392ec051c390479ca746c42ca989
change-id: 20261009-mptcp_remove_addr-6777ff1041c6

Best regards,
-- 
Hangbin Liu <liuhangbin@kylinos.cn>


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-10-09  9:52 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-09  7:27 [PATCH mptcp-next] squash to "selftests: mptcp: convert iptables to nftables for mptcp_join.sh" Hangbin Liu
2026-10-09  7:31 ` sashiko-bot
2026-10-09  8:17   ` Hangbin Liu
2026-10-09  8:35 ` MPTCP CI
2026-10-09  9:49 ` [PATCH mptcp-next] squash to "selftests: mptcp: convert iptables to nftables for mptcp_sockopt.sh" Matthieu Baerts
  -- strict thread matches above, loose matches on Subject: below --
2026-10-09  7:26 [PATCH mptcp-next] Squash to "selftests: mptcp: convert iptables to nftables for mptcp_join.sh" Hangbin Liu
2026-10-09  8:23 ` MPTCP CI
2026-10-09  9:03 ` Matthieu Baerts
2026-10-09  9:26   ` Hangbin Liu
2026-10-09  9:38     ` Matthieu Baerts
2026-10-09  9:48       ` Matthieu Baerts
2026-10-09  9:52 ` Matthieu Baerts

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.