ppp: - fix multilink ppp with custom ifnames, patch by George Kashperko <george@znau...
authorJo-Philipp Wich <jow@openwrt.org>
Mon, 12 Nov 2012 19:13:45 +0000 (19:13 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Mon, 12 Nov 2012 19:13:45 +0000 (19:13 +0000)
SVN-Revision: 34171

package/network/services/ppp/Makefile
package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch [new file with mode: 0644]
package/network/services/ppp/patches/330-retain_foreign_default_routes.patch
package/network/services/ppp/patches/340-populate_default_gateway.patch
package/network/services/ppp/patches/400-simplify_kernel_checks.patch
package/network/services/ppp/patches/403-no_wtmp.patch

index fc4ccd4ba2c184fd448f6b316490278d5b620f1d..de9974d02946ea40d8214744866bf29fbf1eab68 100644 (file)
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
 
 PKG_NAME:=ppp
 PKG_VERSION:=2.4.5
 
 PKG_NAME:=ppp
 PKG_VERSION:=2.4.5
-PKG_RELEASE:=6
+PKG_RELEASE:=7
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/ppp/
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=ftp://ftp.samba.org/pub/ppp/
diff --git a/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch b/package/network/services/ppp/patches/321-multilink_support_custom_iface_names.patch
new file mode 100644 (file)
index 0000000..ed04886
--- /dev/null
@@ -0,0 +1,146 @@
+From: George Kashperko <george@znau.edu.ua>
+
+Make mlppp support more generic interface naming other than pppX
+Signed-off-by: George Kashperko <george@znau.edu.ua>
+---
+ pppd/multilink.c |   55 +++++++++++++++++++++++++++++++++------------
+ pppd/sys-linux.c |   12 +++++++++
+ 2 files changed, 53 insertions(+), 14 deletions(-)
+--- a/pppd/multilink.c
++++ b/pppd/multilink.c
+@@ -56,7 +56,8 @@ static void iterate_bundle_links __P((vo
+ static int get_default_epdisc __P((struct epdisc *));
+ static int parse_num __P((char *str, const char *key, int *valp));
+-static int owns_unit __P((TDB_DATA pid, int unit));
++static int parse_str __P((char *str, const char *key, char *buf, int buflen));
++static int owns_link __P((TDB_DATA pid, char *ifname));
+ #define set_ip_epdisc(ep, addr) do {  \
+       ep->length = 4;                 \
+@@ -197,35 +198,38 @@ mp_join_bundle()
+       key.dptr = bundle_id;
+       key.dsize = p - bundle_id;
+       pid = tdb_fetch(pppdb, key);
++
+       if (pid.dptr != NULL) {
++              char tmp[IFNAMSIZ];
++
+               /* bundle ID exists, see if the pppd record exists */
+               rec = tdb_fetch(pppdb, pid);
++
+               if (rec.dptr != NULL && rec.dsize > 0) {
+                       /* make sure the string is null-terminated */
+                       rec.dptr[rec.dsize-1] = 0;
+-                      /* parse the interface number */
+-                      parse_num(rec.dptr, "IFNAME=ppp", &unit);
++
+                       /* check the pid value */
+                       if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid)
++                          || !parse_str(rec.dptr, "IFNAME=", tmp, sizeof(tmp))
++                          || !parse_num(rec.dptr, "IFUNIT=", &unit)
+                           || !process_exists(pppd_pid)
+-                          || !owns_unit(pid, unit))
++                          || !owns_link(pid, tmp))
+                               unit = -1;
+                       free(rec.dptr);
+               }
+               free(pid.dptr);
+-      }
+-      if (unit >= 0) {
+               /* attach to existing unit */
+-              if (bundle_attach(unit)) {
++              if (unit >= 0 && bundle_attach(unit)) {
+                       set_ifunit(0);
+                       script_setenv("BUNDLE", bundle_id + 7, 0);
+                       make_bundle_links(1);
+                       unlock_db();
+-                      info("Link attached to %s", ifname);
++                      info("Link attached to %s", tmp);
+                       return 1;
++                      /* attach failed because bundle doesn't exist */
+               }
+-              /* attach failed because bundle doesn't exist */
+       }
+       /* we have to make a new bundle */
+@@ -408,22 +412,45 @@ parse_num(str, key, valp)
+       return 0;
+ }
++static int
++parse_str(str, key, buf, buflen)
++     char *str;
++     const char *key;
++     char *buf;
++     int buflen;
++{
++      char *p, *endp;
++      int i;
++
++      p = strstr(str, key);
++      if (p) {
++              p += strlen(key);
++              while (--buflen && *p != 0 && *p != ';')
++                      *(buf++) = *(p++);
++              *buf = 0;
++              return 1;
++      }
++      return 0;
++}
++
+ /*
+- * Check whether the pppd identified by `key' still owns ppp unit `unit'.
++ * Check whether the pppd identified by `key' still owns ppp link `ifname'.
+  */
+ static int
+-owns_unit(key, unit)
++owns_link(key, ifname)
+      TDB_DATA key;
+-     int unit;
++     char *ifname;
+ {
+-      char ifkey[32];
++      char ifkey[7 + IFNAMSIZ];
+       TDB_DATA kd, vd;
+       int ret = 0;
+-      slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit);
++      slprintf(ifkey, sizeof(ifkey), "IFNAME=%s", ifname);
++
+       kd.dptr = ifkey;
+       kd.dsize = strlen(ifkey);
+       vd = tdb_fetch(pppdb, kd);
++
+       if (vd.dptr != NULL) {
+               ret = vd.dsize == key.dsize
+                       && memcmp(vd.dptr, key.dptr, vd.dsize) == 0;
+--- a/pppd/sys-linux.c
++++ b/pppd/sys-linux.c
+@@ -700,6 +700,16 @@ void cfg_bundle(int mrru, int mtru, int 
+       add_fd(ppp_dev_fd);
+ }
++static void
++setenv_ifunit(void)
++{
++#ifdef USE_TDB
++      char tmp[11];
++      slprintf(tmp, sizeof(tmp), "%d", ifunit);
++      script_setenv("IFUNIT", tmp, 0);
++#endif
++}
++
+ /*
+  * make_new_bundle - create a new PPP unit (i.e. a bundle)
+  * and connect our channel to it.  This should only get called
+@@ -718,6 +728,8 @@ void make_new_bundle(int mrru, int mtru,
+       /* set the mrru and flags */
+       cfg_bundle(mrru, mtru, rssn, tssn);
++
++      setenv_ifunit();
+ }
+ /*
index 0d7fff9b4bf3d1f473b8df8eceda9ea51f295b4a..6d93b0492288ddcb83199bbb2ca6f684a929e93f 100644 (file)
@@ -12,7 +12,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
 
 --- a/pppd/sys-linux.c
 +++ b/pppd/sys-linux.c
 
 --- a/pppd/sys-linux.c
 +++ b/pppd/sys-linux.c
-@@ -1743,6 +1743,7 @@ int cifdefaultroute (int unit, u_int32_t
+@@ -1755,6 +1755,7 @@ int cifdefaultroute (int unit, u_int32_t
        SIN_ADDR(rt.rt_genmask) = 0L;
      }
  
        SIN_ADDR(rt.rt_genmask) = 0L;
      }
  
index 9a0284eb23329fffbfd8697f20353f75ee1c91a0..1c6d9ac0dd4cbba6646bd7347a0a41040bdc9761 100644 (file)
@@ -13,7 +13,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
 
 --- a/pppd/sys-linux.c
 +++ b/pppd/sys-linux.c
 
 --- a/pppd/sys-linux.c
 +++ b/pppd/sys-linux.c
-@@ -1697,6 +1697,9 @@ int sifdefaultroute (int unit, u_int32_t
+@@ -1709,6 +1709,9 @@ int sifdefaultroute (int unit, u_int32_t
      memset (&rt, 0, sizeof (rt));
      SET_SA_FAMILY (rt.rt_dst, AF_INET);
  
      memset (&rt, 0, sizeof (rt));
      SET_SA_FAMILY (rt.rt_dst, AF_INET);
  
@@ -23,7 +23,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
      rt.rt_dev = ifname;
  
      if (kernel_version > KVERSION(2,1,0)) {
      rt.rt_dev = ifname;
  
      if (kernel_version > KVERSION(2,1,0)) {
-@@ -1704,7 +1707,7 @@ int sifdefaultroute (int unit, u_int32_t
+@@ -1716,7 +1719,7 @@ int sifdefaultroute (int unit, u_int32_t
        SIN_ADDR(rt.rt_genmask) = 0L;
      }
  
        SIN_ADDR(rt.rt_genmask) = 0L;
      }
  
index ec82576cbc7813bc64c3b949e133cae41667a11d..4494abac2e3c844a61642684dd1153d1d7612773 100644 (file)
@@ -29,7 +29,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
  
  #define MAX_IFS               100
  
  
  #define MAX_IFS               100
  
-@@ -1438,11 +1438,12 @@ int ccp_fatal_error (int unit)
+@@ -1450,11 +1450,12 @@ int ccp_fatal_error (int unit)
   *
   * path_to_procfs - find the path to the proc file system mount point
   */
   *
   * path_to_procfs - find the path to the proc file system mount point
   */
@@ -44,7 +44,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
      struct mntent *mntent;
      FILE *fp;
  
      struct mntent *mntent;
      FILE *fp;
  
-@@ -1464,6 +1465,7 @@ static char *path_to_procfs(const char *
+@@ -1476,6 +1477,7 @@ static char *path_to_procfs(const char *
            fclose (fp);
        }
      }
            fclose (fp);
        }
      }
@@ -52,7 +52,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
  
      strlcpy(proc_path + proc_path_len, tail,
            sizeof(proc_path) - proc_path_len);
  
      strlcpy(proc_path + proc_path_len, tail,
            sizeof(proc_path) - proc_path_len);
-@@ -2116,15 +2118,19 @@ int ppp_available(void)
+@@ -2128,15 +2130,19 @@ int ppp_available(void)
      int    my_version, my_modification, my_patch;
      int osmaj, osmin, ospatch;
  
      int    my_version, my_modification, my_patch;
      int osmaj, osmin, ospatch;
  
@@ -72,7 +72,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
  
        /* XXX should get from driver */
        driver_version = 2;
  
        /* XXX should get from driver */
        driver_version = 2;
-@@ -2185,6 +2191,7 @@ int ppp_available(void)
+@@ -2197,6 +2203,7 @@ int ppp_available(void)
  
      if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
        ok = 0;
  
      if (ok && ((ifr.ifr_hwaddr.sa_family & ~0xFF) != ARPHRD_PPP))
        ok = 0;
@@ -80,7 +80,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
  
  /*
   *  This is the PPP device. Validate the version of the driver at this
  
  /*
   *  This is the PPP device. Validate the version of the driver at this
-@@ -2678,6 +2685,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
+@@ -2690,6 +2697,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
      }
  #endif /* TIOCGPTN */
  
      }
  #endif /* TIOCGPTN */
  
@@ -88,7 +88,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
      if (sfd < 0) {
        /* the old way - scan through the pty name space */
        for (i = 0; i < 64; ++i) {
      if (sfd < 0) {
        /* the old way - scan through the pty name space */
        for (i = 0; i < 64; ++i) {
-@@ -2696,6 +2704,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
+@@ -2708,6 +2716,7 @@ get_pty(master_fdp, slave_fdp, slave_nam
            }
        }
      }
            }
        }
      }
index 71233200e75c12ed5398d006d56a5ba43aa2d82f..e8e76252c01d7ace72159b265498e5ad61b79bf3 100644 (file)
@@ -7,7 +7,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
 
 --- a/pppd/sys-linux.c
 +++ b/pppd/sys-linux.c
 
 --- a/pppd/sys-linux.c
 +++ b/pppd/sys-linux.c
-@@ -2254,6 +2254,7 @@ int ppp_available(void)
+@@ -2266,6 +2266,7 @@ int ppp_available(void)
  
  void logwtmp (const char *line, const char *name, const char *host)
  {
  
  void logwtmp (const char *line, const char *name, const char *host)
  {
@@ -15,7 +15,7 @@ Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
      struct utmp ut, *utp;
      pid_t  mypid = getpid();
  #if __GLIBC__ < 2
      struct utmp ut, *utp;
      pid_t  mypid = getpid();
  #if __GLIBC__ < 2
-@@ -2319,6 +2320,7 @@ void logwtmp (const char *line, const ch
+@@ -2331,6 +2332,7 @@ void logwtmp (const char *line, const ch
        close (wtmp);
      }
  #endif
        close (wtmp);
      }
  #endif