public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] ss: suppress netlink errors for unsupported protocols
@ 2026-02-25 21:10 Stephen Hemminger
  2026-02-28  1:10 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2026-02-25 21:10 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

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

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 misc/ss.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index b3566f6b..7520003a 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -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)))
-- 
2.51.0


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

end of thread, other threads:[~2026-02-28  1:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-25 21:10 [PATCH iproute2] ss: suppress netlink errors for unsupported protocols Stephen Hemminger
2026-02-28  1:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox