]> git.ozlabs.org Git - ppp.git/commitdiff
Merge branch 'master' of https://github.com/gburgessiv/ppp
authorPaul Mackerras <paulus@ozlabs.org>
Sat, 18 Mar 2017 11:24:25 +0000 (22:24 +1100)
committerPaul Mackerras <paulus@ozlabs.org>
Sat, 18 Mar 2017 11:24:25 +0000 (22:24 +1100)
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
pppd/fsm.c
pppd/main.c
pppd/options.c
pppd/plugins/rp-pppoe/pppoe-discovery.c
pppd/plugins/rp-pppoe/pppoe.h
pppd/pppd.8
pppd/pppd.h
pppd/sys-linux.c
pppstats/pppstats.c
scripts/plog

index c200cc3a84387cefc952bdd37bac6650bf32161d..e9bd34f0e8f48fd0da69e4ffea3349691975f435 100644 (file)
@@ -468,7 +468,7 @@ fsm_rconfreq(f, id, inp, len)
        f->nakloops = 0;
 
     } else {
-       /* we sent CONFACK or CONFREJ */
+       /* we sent CONFNAK or CONFREJ */
        if (f->state != ACKRCVD)
            f->state = REQSENT;
        if( code == CONFNAK )
index aef9e84775922a59cf6fb960d6f3aea53914ad7a..76b67d2485b71ce4dc11c6a9cd7ecfd2293f21d9 100644 (file)
 static const char rcsid[] = RCSID;
 
 /* interface vars */
-char ifname[32];               /* Interface name */
+char ifname[MAXIFNAMELEN];     /* Interface name */
 int ifunit;                    /* Interface unit number */
 
 struct channel *the_channel;
@@ -297,13 +297,6 @@ struct protent *protocols[] = {
     NULL
 };
 
-/*
- * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
- */
-#if !defined(PPP_DRV_NAME)
-#define PPP_DRV_NAME   "ppp"
-#endif /* !defined(PPP_DRV_NAME) */
-
 int
 main(argc, argv)
     int argc;
@@ -736,8 +729,11 @@ void
 set_ifunit(iskey)
     int iskey;
 {
-    info("Using interface %s%d", PPP_DRV_NAME, ifunit);
-    slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
+    if (req_ifname[0] != '\0')
+       slprintf(ifname, sizeof(ifname), "%s", req_ifname);
+    else
+       slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
+    info("Using interface %s", ifname);
     script_setenv("IFNAME", ifname, iskey);
     if (iskey) {
        create_pidfile(getpid());       /* write pid to file */
index c06a2b4ad8ed4560501dfeb61902946c14ea7d96..177488ca681392c3971e432642c7e97a0638a894 100644 (file)
@@ -114,6 +114,7 @@ char        linkname[MAXPATHLEN];   /* logical name for link */
 bool   tune_kernel;            /* may alter kernel settings */
 int    connect_delay = 1000;   /* wait this many ms after connect script */
 int    req_unit = -1;          /* requested interface unit */
+char   req_ifname[MAXIFNAMELEN];       /* requested interface name */
 bool   multilink = 0;          /* Enable multilink operation */
 char   *bundle_name = NULL;    /* bundle name for multilink */
 bool   dump_options;           /* print out option values */
@@ -284,6 +285,10 @@ option_t general_options[] = {
       "PPP interface unit number to use if possible",
       OPT_PRIO | OPT_LLIMIT, 0, 0 },
 
+    { "ifname", o_string, req_ifname,
+      "Set PPP interface name",
+      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN },
+
     { "dump", o_bool, &dump_options,
       "Print out option values after parsing all options", 1 },
     { "dryrun", o_bool, &dryrun,
index 3d3bf4eecc816c59aad3aee24b94944150593147..55037dffb02322e6d92cf099270b5e41739f46b4 100644 (file)
@@ -9,6 +9,7 @@
  *
  */
 
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -55,6 +56,14 @@ void die(int status)
        exit(status);
 }
 
+void error(char *fmt, ...)
+{
+    va_list pvar;
+    va_start(pvar, fmt);
+    vfprintf(stderr, fmt, pvar);
+    va_end(pvar);
+}
+
 /* Initialize frame types to RFC 2516 values.  Some broken peers apparently
    use different frame types... sigh... */
 
index 9ab2eee3914c3718daa055375f32095beaa8a8f5..c4aaa6e68856e8506643a6c30c86177070af1fd7 100644 (file)
 #include <sys/socket.h>
 #endif
 
+/* This has to be included before Linux 4.8's linux/in.h
+ * gets dragged in. */
+#include <netinet/in.h>
+
 /* Ugly header files on some Linux boxes... */
 #if defined(HAVE_LINUX_IF_H)
 #include <linux/if.h>
@@ -84,8 +88,6 @@ typedef unsigned long UINT32_t;
 #include <linux/if_ether.h>
 #endif
 
-#include <netinet/in.h>
-
 #ifdef HAVE_NETINET_IF_ETHER_H
 #include <sys/types.h>
 
@@ -98,7 +100,6 @@ typedef unsigned long UINT32_t;
 #endif
 
 
-
 /* Ethernet frame types according to RFC 2516 */
 #define ETH_PPPOE_DISCOVERY 0x8863
 #define ETH_PPPOE_SESSION   0x8864
index c508d277df3aa5539dd3c0d94787d97f71709956..06e945fce998080090da52837d1d3b69306c19a7 100644 (file)
@@ -1079,7 +1079,13 @@ under Linux and FreeBSD 2.2.8 and later.
 .TP
 .B unit \fInum
 Sets the ppp unit number (for a ppp0 or ppp1 etc interface name) for outbound
-connections.
+connections.  If the unit is already in use a dynamically allocated number will
+be used.
+.TP
+.B ifname \fIstring
+Set the ppp interface name for outbound connections.  If the interface name is
+already in use, or if the name cannot be used for any other reason, pppd will
+terminate.
 .TP
 .B unset \fIname
 Remove a variable from the environment variable for scripts that are
index 247fa153739b387d217719e6ac1beb8bf407d708..1a1bf0b99582fa323cb0ee587d79c248642a7896 100644 (file)
 #define MAXARGS                1       /* max # args to a command */
 #define MAXNAMELEN     256     /* max length of hostname or name for auth */
 #define MAXSECRETLEN   256     /* max length of password or secret */
+#define MAXIFNAMELEN   32      /* max length of interface name; or use IFNAMSIZ, can we
+                                  always include net/if.h? */
+
+/*
+ * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
+ * Where should PPP_DRV_NAME come from? Do we include it here?
+ */
+#if !defined(PPP_DRV_NAME)
+#define PPP_DRV_NAME   "ppp"
+#endif /* !defined(PPP_DRV_NAME) */
 
 /*
  * Option descriptor structure.
@@ -318,6 +328,7 @@ extern bool tune_kernel;    /* May alter kernel settings as necessary */
 extern int     connect_delay;  /* Time to delay after connect script */
 extern int     max_data_rate;  /* max bytes/sec through charshunt */
 extern int     req_unit;       /* interface unit number to use */
+extern char    req_ifname[MAXIFNAMELEN]; /* interface name to use */
 extern bool    multilink;      /* enable multilink operation */
 extern bool    noendpoint;     /* don't send or accept endpt. discrim. */
 extern char    *bundle_name;   /* bundle name for multilink */
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;
 }
 
index 6367988eb96bf03c588b6228ee0c0fdf115f0fbb..46cb9c24942b5e6869fef31f463b514daefb99ba 100644 (file)
@@ -88,7 +88,6 @@ int   aflag;                  /* print absolute values, not deltas */
 int    dflag;                  /* print data rates, not bytes */
 int    interval, count;
 int    infinite;
-int    unit;
 int    s;                      /* socket or /dev/ppp file descriptor */
 int    signalled;              /* set if alarm goes off "early" */
 char   *progname;
@@ -449,6 +448,7 @@ main(argc, argv)
 {
     int c;
 #ifdef STREAMS
+    int unit;
     char *dev;
 #endif
 
@@ -506,11 +506,6 @@ main(argc, argv)
     if (argc > 0)
        interface = argv[0];
 
-    if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
-       fprintf(stderr, "%s: invalid interface '%s' specified\n",
-               progname, interface);
-    }
-
 #ifndef STREAMS
     {
        struct ifreq ifr;
@@ -535,6 +530,11 @@ main(argc, argv)
     }
 
 #else  /* STREAMS */
+    if (sscanf(interface, PPP_DRV_NAME "%d", &unit) != 1) {
+       fprintf(stderr, "%s: invalid interface '%s' specified\n",
+               progname, interface);
+    }
+
 #ifdef __osf__
     dev = "/dev/streams/ppp";
 #else
index 84d2c7340cc64cd4f86ffa9af87504c8055b9c03..7cb53346413d7b52e8ecc6757be0e990bb4beecd 100644 (file)
@@ -3,5 +3,5 @@
 if [ -s /var/log/ppp.log ]; then
   exec tail "$@" /var/log/ppp.log
 else
-  exec tail "$@" /var/log/syslog | grep ' \(pppd\|chat\)\['
+  exec grep ' \(pppd\|chat\)\[' /var/log/syslog | tail "$@"
 fi