]> The Tcpdump Group git mirrors - libpcap/commitdiff
2.6.0 didn't have "subsystem" links; use "ifindex" instead.
authorGuy Harris <[email protected]>
Mon, 3 Dec 2012 09:29:32 +0000 (01:29 -0800)
committerGuy Harris <[email protected]>
Mon, 3 Dec 2012 09:30:46 +0000 (01:30 -0800)
pcap-linux.c

index 36eaf67a608e1dabb08f5bd4324488ac352e3873..ad22821020f2dbdfbfa3048d8ce5b8d3cfa8eb91 100644 (file)
@@ -2007,22 +2007,32 @@ scan_sys_class_net(pcap_if_t **devlistp, char *errbuf)
                        continue;
 
                /*
-                * Ignore plain files.
+                * Ignore plain files; they do not have subdirectories
+                * and thus have no attributes.
                 */
                if (ent->d_type == DT_REG)
                        continue;
 
                /*
-                * Is there a "subsystem" file under that name?
+                * Is there an "ifindex" file under that name?
                 * (We don't care whether it's a directory or
                 * a symlink; older kernels have directories
                 * for devices, newer kernels have symlinks to
                 * directories.)
                 */
                snprintf(subsystem_path, sizeof subsystem_path,
-                   "/sys/class/net/%s/subsystem", ent->d_name);
+                   "/sys/class/net/%s/ifindex", ent->d_name);
                if (lstat(subsystem_path, &statb) != 0) {
-                       /* Stat failed, ignore */
+                       /*
+                        * Stat failed.  Either there was an error
+                        * other than ENOENT, and we don't know if
+                        * this is an interface, or it's ENOENT,
+                        * and either some part of "/sys/class/net/{if}"
+                        * disappeared, in which case it probably means
+                        * the interface disappeared, or there's no
+                        * "ifindex" file, which means it's not a
+                        * network interface.
+                        */
                        continue;
                }