public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2] ss: suppress netlink errors for unsupported protocols
Date: Wed, 25 Feb 2026 13:10:25 -0800	[thread overview]
Message-ID: <20260225211118.314008-1-stephen@networkplumber.org> (raw)

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


             reply	other threads:[~2026-02-25 21:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 21:10 Stephen Hemminger [this message]
2026-02-28  1:10 ` [PATCH iproute2] ss: suppress netlink errors for unsupported protocols patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260225211118.314008-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox