X-Git-Url: http://git.ozlabs.org/?p=ppp.git;a=blobdiff_plain;f=pppd%2Fsys-linux.c;h=46e1ed419f4b494fb3d6f4781fdc0120ca808fab;hp=b4a435d2a99368bdb48316c798961f1be8f08147;hb=a3f379befd11934466271aaca76b2809ae8595d0;hpb=6edf252483b30dbcdcc5059f01831455365d5b6e diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index b4a435d..46e1ed4 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -73,12 +73,12 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include @@ -643,6 +643,21 @@ static int make_ppp_unit() } if (x < 0) error("Couldn't create new ppp unit: %m"); + + if (x == 0 && req_ifname[0] != '\0') { + struct ifreq ifr; + char t[MAXIFNAMELEN]; + memset(&ifr, 0, sizeof(struct ifreq)); + slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit); + strncpy(ifr.ifr_name, t, IF_NAMESIZE); + strncpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE); + x = ioctl(sock_fd, SIOCSIFNAME, &ifr); + if (x < 0) + error("Couldn't rename interface %s to %s: %m", t, req_ifname); + else + info("Renamed interface %s to %s", t, req_ifname); + } + return x; }