X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=9c0455c0da62e4fb31ed0e4b3ae542bab293844d;hb=4cb90c1fb141ae3cca08c2ac9c663c14a4d2473e;hp=e7f851c02512394cc1ebe5b63f771eb4890846b4;hpb=607d8eadccfd62c1fa84a36bd1440bd48b4e55ca;p=ppp.git diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index e7f851c..9c0455c 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -878,6 +878,11 @@ static int make_ppp_unit(void) ifunit = -1; x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); } + if (x < 0 && errno == EEXIST) { + srand(time(NULL) * getpid()); + ifunit = rand() % 10000; + x = ioctl(ppp_dev_fd, PPPIOCNEWUNIT, &ifunit); + } if (x < 0) error("Couldn't create new ppp unit: %m"); @@ -1790,13 +1795,10 @@ get_ppp_stats_rtnetlink(int u, struct pppd_stats *stats) } if (nlresp.nlh.nlmsg_type == NLMSG_ERROR) { - if (nlresplen < offsetof(struct nlresp, __end_err)) { - if (kernel_version >= KVERSION(4,7,0)) - error("get_ppp_stats_rtnetlink: Netlink responded with error: %s (line %d)", strerror(-nlresp.nlerr.error), __LINE__); - } else { - error("get_ppp_stats_rtnetlink: Netlink responded with an error message, but the nlmsgerr structure is incomplete (line %d).", - __LINE__); - } + if (nlresplen < offsetof(struct nlresp, __end_err)) + error("get_ppp_stats_rtnetlink: Netlink responded with an error message, but the nlmsgerr structure is incomplete (line %d).", __LINE__); + else if (kernel_version >= KVERSION(4,7,0)) + error("get_ppp_stats_rtnetlink: Netlink responded with error: %s (line %d)", strerror(-nlresp.nlerr.error), __LINE__); goto err; }