|
@@ -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;
|
|
|
+ }
|