]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ss: suppress netlink errors for unsupported protocols
authorStephen Hemminger <stephen@networkplumber.org>
Wed, 25 Feb 2026 20:59:13 +0000 (12:59 -0800)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 25 Feb 2026 20:59:13 +0000 (12:59 -0800)
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.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
misc/ss.c

index b3566f6b6b81427609829720496e80bea7cfeef7..7520003a89e8d3a03c58a58a9917c834255816fb 100644 (file)
--- 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)))