Skip to contentSkip to conversation

iproute: Properly handle protocol level diag module absence

PATCH In review Pavel Emelyanov 3 participants 3 messages Jan 28, 2014 – Feb 10, 2014

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

PATCH 1/1 iproute: Properly handle protocol level diag module absence

When *_diag module is missing in the kernel, the ss tool should go ad read legacry /proc/* files.

This is the case when all *_diag stuff is missing, but in case the inet_diag.ko is loaded, but (tcp|udp)_diag.ko is not, the ss tool doesn't notice this and produces empty output. The reason for that is -- error from the inet_diag module (which means, that e.g. the udp_diag is missing) is reported in the NLMSG_DONE message body.

That said, we need to check the NLMSG_DONE's message return code and act respectively.

---

misc/ss.c +8 -1
index 37dcc11..9c7d937 100644
@@ -1746,8 +1746,15 @@ again:
 			    h->nlmsg_seq != 123456)
 				goto skip_it;
 
-			if (h->nlmsg_type == NLMSG_DONE)
+			if (h->nlmsg_type == NLMSG_DONE) {
+				int *len = (int *)NLMSG_DATA(h);
+				if (*len < 0) {
+					close(fd);
+					return -1;
+				}
+
 				goto done;
+			}
 
 			if (h->nlmsg_type == NLMSG_ERROR) {
 				struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(h);
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Pavel Emelyanov

When *_diag module is missing in the kernel, the ss tool should go ad read legacry /proc/* files.

This is the case when all *_diag stuff is missing, but in case the inet_diag.ko is loaded, but (tcp|udp)_diag.ko is not, the ss tool doesn't notice this and produces empty output. The reason for that is -- error from the inet_diag module (which means, that e.g. the udp_diag is missing) is reported in the NLMSG_DONE message body.

Quoted 7 lines

That said, we need to check the NLMSG_DONE's message return code and act respectively.

---

#2 lore raw
In reply to Pavel Emelyanov
Quoted 9 lines · On Tue, 28 Jan 2014 21:32:00 +0400 Pavel Emelyanov <[email protected]> wrote:

When *_diag module is missing in the kernel, the ss tool should go ad read legacry /proc/* files.

This is the case when all *_diag stuff is missing, but in case the inet_diag.ko is loaded, but (tcp|udp)_diag.ko is not, the ss tool doesn't notice this and produces empty output. The reason for that is -- error from the inet_diag module (which means, that e.g. the udp_diag is missing) is reported in the NLMSG_DONE message body.

Quoted 6 lines

That said, we need to check the NLMSG_DONE's message return code and act respectively.

Silently ignoring the error seems wrong.
The fallback is good, but we should try and report the error so that the user fixes the kernel config.