Skip to contentSkip to conversation

ss: suppress netlink errors for unsupported protocols

PATCH Applied Stephen Hemminger 2 participants 2 messages Feb 25 – Feb 28

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ss: suppress netlink errors for unsupported protocols

Error messages from sock_diag were only suppressed for extended protocols (> 255). Protocols like SCTP and DCCP also get EINVAL when their kernel modules are not loaded. Remove the conditional so all protocols suppress the error.

This fixes the problem where:

  $ ss >/dev/null
RTNETLINK answers: Invalid argument
---
 misc/ss.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
misc/ss.c +6 -6
index b3566f6b..7520003a 100644
@@ -4120,13 +4120,13 @@ static int inet_show_netlink(struct filter *f, FILE *dump_fp, int protocol)
 	if (preferred_family == PF_INET6)
 		family = PF_INET6;
 
-	/* extended protocol will use INET_DIAG_REQ_PROTOCOL,
-	 * not supported by older kernels. On such kernel
-	 * rtnl_dump will bail with rtnl_dump_error().
-	 * Suppress the error to avoid confusing the user
+	/* Suppress netlink errors. Older kernels do not support extended
+	 * protocol requests using INET_DIAG_REQ_PROTOCOL, and some protocols
+	 * may not be available in the running kernel (e.g. SCTP, DCCP).
+	 * In both cases the kernel returns EINVAL which would cause
+	 * rtnl_dump_error() to print a confusing "RTNETLINK answers" error.
 	 */
-	if (protocol > 255)
-		rth.flags |= RTNL_HANDLE_F_SUPPRESS_NLERR;
+	rth.flags |= RTNL_HANDLE_F_SUPPRESS_NLERR;
 
 again:
 	if ((err = sockdiag_send(family, rth.fd, protocol, f)))
Signature · 1 line
2.51.0
#1 lore raw
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Quoted 10 lines · On Wed, 25 Feb 2026 13:10:25 -0800 you wrote:

Error messages from sock_diag were only suppressed for extended protocols (> 255). Protocols like SCTP and DCCP also get EINVAL when their kernel modules are not loaded. Remove the conditional so all protocols suppress the error.

This fixes the problem where:

  $ ss >/dev/null
RTNETLINK answers: Invalid argument

[...]

Here is the summary with links:
- [iproute2] ss: suppress netlink errors for unsupported protocols

    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=f08cfd36cdf9

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html