Skip to contentSkip to conversation

ss: fix fallback to procfs for raw sockets

PATCH New Jakub Kicinski 1 participant 1 message Aug 18, 2021

Subsystems (2)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 ss: fix fallback to procfs for raw sockets

Jonas reports that ss -awp does not display any RAW sockets on a Knoppix 4.4 kernel.

sockdiag_send() diverts to tcpdiag_send() to try the older netlink interface. tcpdiag_send() works for TCP and DCCP but not other protocols. Instead of rejecting unsupported protocols (and missing RAW and SCTP) match on supported ones.

Reported-and-tested-by Jonas Bechtel <[email protected]>
Fixes 41fe6c34de50 ("ss: Add inet raw sockets information gathering via netlink diag interface")
---
 misc/ss.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
misc/ss.c +4 -4
index 894ad40574f1..b39f63fe3b17 100644
@@ -3404,13 +3404,13 @@ static int tcpdiag_send(int fd, int protocol, struct filter *f)
 	struct iovec iov[3];
 	int iovlen = 1;
 
-	if (protocol == IPPROTO_UDP || protocol == IPPROTO_MPTCP)
-		return -1;
-
 	if (protocol == IPPROTO_TCP)
 		req.nlh.nlmsg_type = TCPDIAG_GETSOCK;
-	else
+	else if (protocol == IPPROTO_DCCP)
 		req.nlh.nlmsg_type = DCCPDIAG_GETSOCK;
+	else
+		return -1;
+
 	if (show_mem) {
 		req.r.idiag_ext |= (1<<(INET_DIAG_MEMINFO-1));
 		req.r.idiag_ext |= (1<<(INET_DIAG_SKMEMINFO-1));
Signature · 1 line
2.31.1