Choose first running interface, rather than first "up" interface (Redhat #1403025)

Robert Scheck <robert@fedoraproject.org>
This commit is contained in:
Paul Warren
2017-03-22 09:11:22 +00:00
parent 35af3cf65f
commit 949ed0f7e2
2 changed files with 4 additions and 1 deletions

View File

@@ -110,7 +110,7 @@ static char *get_first_interface(void) {
while(nameindex[j].if_index != 0) {
if (strcmp(nameindex[j].if_name, "lo") != 0 && !is_bad_interface_name(nameindex[j].if_name)) {
strncpy(ifr.ifr_name, nameindex[j].if_name, sizeof(ifr.ifr_name));
if ((s == -1) || (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) || (ifr.ifr_flags & IFF_UP)) {
if ((s == -1) || (ioctl(s, SIOCGIFFLAGS, &ifr) == -1) || (ifr.ifr_flags & IFF_RUNNING)) {
i = xstrdup(nameindex[j].if_name);
break;
}