]> git.ozlabs.org Git - ppp.git/blobdiff - pppd/sys-linux.c
Merge branch 'master' of https://github.com/gburgessiv/ppp
[ppp.git] / pppd / sys-linux.c
index b4a435d2a99368bdb48316c798961f1be8f08147..46e1ed419f4b494fb3d6f4781fdc0120ca808fab 100644 (file)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/time.h>
-#include <sys/errno.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/utsname.h>
 #include <sys/sysmacros.h>
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <syslog.h>
@@ -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;
 }