diff --git a/src/osdnet.c b/src/osdnet.c index fc41702..7408e05 100644 --- a/src/osdnet.c +++ b/src/osdnet.c @@ -1705,19 +1705,19 @@ pfopen(char *basename, struct tuntap_context *tt_ctx, struct osnpf *osnpf) (void) snprintf(pfname, BASENAMESIZE, "%s%d", basename, i++); fd = open(pfname, O_RDWR, 0); } while (fd < 0 && errno == EBUSY); /* If device busy, keep looking */ - } - - if (fd < 0) { - /* Note possible error meanings: - ENOENT - no such filename - ENXIO - not configured in kernel - */ - esfatal(1, "Couldn't find or open packetfilter device, last tried %s", - pfname); - } + if (fd >= 0) { + basenamecpy(osnpf->osnpf_ifnam, pfname, IFNAM_LEN); + } else { + /* Note possible error meanings: + ENOENT - no such filename + ENXIO - not configured in kernel + */ + esfatal(1, "Couldn't find or open packetfilter device, last tried %s", + pfname); + }; + }; tt_ctx->my_tap = TRUE; - basenamecpy(osnpf->osnpf_ifnam, pfname, IFNAM_LEN); return fd; /* Success! */ }