Browse Source

aoe-sancheck: Probe interfaces not named eth*. Closes: #986671

Christoph Biedl 3 years ago
parent
commit
b297b965f4

+ 70 - 0
debian/patches/for-upstream/0001-aoe-sancheck-Refine-interface-probing.patch

@@ -0,0 +1,70 @@
+From 4a3ee184e6e76aead8e55c412be3c9c924e76e24 Mon Sep 17 00:00:00 2001
+From: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
+Date: Sat, 22 May 2021 14:37:25 +0200
+Subject: [PATCH 1/2] aoe-sancheck: Refine interface probing
+
+There are two issues in the ethlist function in aoe-sancheck.c:
+
+First it skips all network interfaces that do not start with "eth". This
+is a problem these days where people use different naming schemes like the
+so-called predictable interface names as mandated by udev/systemd.
+
+Second it only probes for interfaces with an interface number of up
+to 15. At least in current Linux, that number can take huge values and
+those interfaces will be ignored completely.
+
+About the first: Probe all interfaces (but lo) that support the ARP
+protocol, assuming that is a fair indicator for ethernet support.
+
+About the second, use the if_nameindex function to get a list of all
+interfaces currently known to the kernel and operate on that one.
+---
+ aoe-sancheck.c | 25 ++++++++++++++++++++-----
+ 1 file changed, 20 insertions(+), 5 deletions(-)
+
+--- a/aoe-sancheck.c
++++ b/aoe-sancheck.c
+@@ -501,23 +501,38 @@
+ int
+ ethlist(char **ifs, int nifs)
+ {
+-	int i, s, n;
++	int s, n;
+ 	struct ifreq ifr;
++	struct if_nameindex *if_ni, *i;
+ 
+ 	s = socket(AF_INET, SOCK_STREAM, 0);
+ 	if (s < 0)
+ 		return 0;
++
++	if_ni = if_nameindex();
++	if (if_ni == NULL)
++		return 0;
++
+ 	n = 0;
+-	for (i=0; i<nifs; i++) {
++	for (i = if_ni; ! (i->if_index == 0 && i->if_name == NULL); i++) {
+ 		memset(&ifr, 0, sizeof ifr);
+-		ifr.ifr_ifindex = i;
+-		if (ioctl(s, SIOCGIFNAME, &ifr) < 0)
++		ifr.ifr_ifindex = i->if_index;
++		strcpy(ifr.ifr_name, i->if_name);
++		// get interface flags
++		if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
++			continue;
++		// only use interfaces that use arp protocol
++		if (ifr.ifr_flags & IFF_NOARP)
+ 			continue;
+-		if (strncmp(ifr.ifr_name, "eth", 3))
++		// skip loopback interfaces
++		if (ifr.ifr_flags & IFF_LOOPBACK)
+ 			continue;
++		if (n == nifs)
++			break;
+ 		inserteth(ifs, nifs, ifr.ifr_name);
+ 		n++;
+ 	}
++	if_freenameindex(if_ni);
+ 	close(s);
+ 	return n;
+ }

+ 33 - 0
debian/patches/for-upstream/0002-aoe-sancheck-Raise-the-number-of-interfaces-to-probe.patch

@@ -0,0 +1,33 @@
+From c80b1bedbbcb068aab8fe66d68be433dc3a6c333 Mon Sep 17 00:00:00 2001
+From: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
+Date: Sat, 22 May 2021 14:54:41 +0200
+Subject: [PATCH 2/2] aoe-sancheck: Raise the number of interfaces to probe to
+ 32, and document the limit
+
+---
+ aoe-sancheck.8 | 2 ++
+ aoe-sancheck.c | 2 +-
+ 2 files changed, 3 insertions(+), 1 deletion(-)
+
+--- a/aoe-sancheck.8
++++ b/aoe-sancheck.8
+@@ -53,6 +53,8 @@
+ This check detects the situation where a local interface is configured for jumbo frames and the AoE device is capable of jumbo frames, but some aspect of the network is incapable of passing frames that size, for example, a misconfigured switch.  \fIAoe-sancheck\fP reports the maximum payload size the path is capable of if less than the configured payload size.
+ .SH BUGS
+ The program may sometimes display inconsistent results between runs showing that a path is capable of a smaller frame size than it actually is.  If you see this behavior, please email one of the authors with your verbose output.
++.PP
++The program probes only the first 32 ethernet interfaces found in the system.
+ .SH "SEE ALSO"
+ .IR aoeping (8),
+ .IR aoetools (8)
+--- a/aoe-sancheck.c
++++ b/aoe-sancheck.c
+@@ -103,7 +103,7 @@
+ };
+ 
+ enum {
+-	Neth= 16,
++	Neth= 32,
+ 	Nstack= 16*1024,
+ 	Nws= 5,
+ 

+ 4 - 0
debian/patches/series

@@ -2,6 +2,10 @@
 # cherry-picked commits. Keep in upstream's chronological order
 cherry-pick/1434503415.aoetools-36-2-ge50247f.check-amount-of-data-read-from-network-before-using-it.patch
 
+# patches for upstream
+for-upstream/0001-aoe-sancheck-Refine-interface-probing.patch
+for-upstream/0002-aoe-sancheck-Raise-the-number-of-interfaces-to-probe.patch
+
 01_no_bashisms.patch
 02_no_hyphen_in_manpages.patch
 03_enable_hardened_build.patch