]> The Tcpdump Group git mirrors - libpcap/commit
Don't sort interfaces by unit number.
authorGuy Harris <[email protected]>
Wed, 23 Oct 2019 01:09:27 +0000 (18:09 -0700)
committerGuy Harris <[email protected]>
Wed, 23 Oct 2019 01:09:27 +0000 (18:09 -0700)
commitdfc9b5a23e05c26878abe61610629e742ca9b3c7
tree3da738de3c49be43235966cda5be112965cc605c
parentcf8baed429dfdca67b0f57e7f6ddfeea0987667d
Don't sort interfaces by unit number.

1) Not all interfaces have a unit number (systemd, for example, might
assign interface names based on the interface's MAC address or on the
physical location of the adapter's connector).

2) If the name does end with a simple unit number, it's not a global
property of the interface, it's only useful as a sort key for device
names with the same prefix, so xyz0 shouldn't necessarily sort before
abc2.

This means that interfaces with the same figure of merit will be sorted
by the order in which the mechanism from which we're getting the
interfaces supplies them.

This will help with some macOS boxes that lack en0 but have utun0; it
may keep utun0 from getting sorted before, say, en2 just because it has
a lower unit number.

(More should be done, e.g. penalizing all interfaces through which the
default route doesn't go, putting the interface for the default route at
the top.)
pcap.c