🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Shashank Mohan Jain Wed, 18 Nov 2026 12:28
[PATCH nf-next v2] netfilter: ctnetlink: support port filters for SCTP
#18502
Author: Shashank Mohan Jain
Date: Wed, 18 Nov 2026 12:28
54 lines
12902 bytes
The kernel side filtering of ctnetlink compares CTA_PROTO_SRC_PORT and
CTA_PROTO_DST_PORT only for TCP and UDP entries. The SCTP l4proto
parses these attributes into the filter tuple
(nf_ct_port_nlattr_to_tuple()), so a filter such as "protonum SCTP,
src port X" is accepted, but the port is not compared and every SCTP
entry matches. A filtered dump then lists all SCTP entries, and a
filtered IPCTNL_MSG_CT_DELETE removes all of them.

Compare the ports for SCTP entries as well. The SCTP port has the same
offset as the TCP port in nf_conntrack_man_proto and in the dst union,
so the existing comparison works unchanged.

Found by reading the code with LLM assistance. Tested on x86_64 under
QEMU: with three SCTP entries, a delete filtered on one source port
removed all three before this change and only the matching one with
it. Filtered dumps show the same difference.

Assisted-by: LLM
Signed-off-by: Shashank Mohan Jain <jain.sm@gmail.com>
---
Changes in v2:
- Target nf-next as a feature, not a fix (Pablo). Drop the Fixes tag
  and Cc: stable.
- Drop GRE, which has no ports (Pablo).

v1: https://lore.kernel.org/all/20261118042950.83129-1-jain.sm@gmail.com/

Prepared with Claude Code (Anthropic), model Claude Opus 5.5
(claude-opus-5-5).

The QEMU test above was run on v1, whose SCTP part is this change (a
small raw ctnetlink program in a busybox initramfs, x86_64, TCG; TCP
entries behave the same before and after).

 net/netfilter/nf_conntrack_netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 4b6abe3..798c11d 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1127,6 +1127,7 @@ static int ctnetlink_filter_match_tuple(struct nf_conntrack_tuple *filter_tuple,
 	switch (ct_tuple->dst.protonum) {
 	case IPPROTO_TCP:
 	case IPPROTO_UDP:
+	case IPPROTO_SCTP:
 		if ((flags & CTA_FILTER_FLAG(CTA_PROTO_SRC_PORT)) &&
 		    filter_tuple->src.u.tcp.port != ct_tuple->src.u.tcp.port)
 			return 0;
-- 
2.54.0 (Apple Git-157)

base-commit: d0107f38162279d9cb0e012210731176265f835d
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads