pppd: Fix `ifname` option in case of multilink (#105)
authorfhost <kernelserror+github@gmail.com>
Sat, 19 Oct 2019 06:05:28 +0000 (08:05 +0200)
committerPaul Mackerras <paulus@ozlabs.org>
Sat, 19 Oct 2019 06:05:28 +0000 (17:05 +1100)
Make pppd use the unit and not the interface name to get the bundle.

pppd was looking for the default interface name (`pppX`) in the
database to retreive the bundle id on which a new link should
attach, and fails if the `ifname` option is used.

Signed-off-by: Alexis Cellier <alexis.cellier@smile.fr>
pppd/main.c
pppd/multilink.c

index 1b3f1e54bdd3250cb41fb986b89b3aaff355128e..9e9803a2c81fdce2e44f781cc98f354b557df08d 100644 (file)
@@ -743,6 +743,9 @@ set_ifunit(iskey)
        slprintf(ifname, sizeof(ifname), "%s%d", PPP_DRV_NAME, ifunit);
     info("Using interface %s", ifname);
     script_setenv("IFNAME", ifname, iskey);
+    char ifkey[32];
+    slprintf(ifkey, sizeof(ifkey), "%d", ifunit);
+    script_setenv("UNIT", ifkey, iskey);
     if (iskey) {
        create_pidfile(getpid());       /* write pid to file */
        create_linkpidfile(getpid());
index c49c4465ced8f1b65d3be54c35b71c000c0ac33b..eb4074d905b395bf52db30e605bc01f457a3c531 100644 (file)
@@ -204,7 +204,7 @@ mp_join_bundle()
                        /* make sure the string is null-terminated */
                        rec.dptr[rec.dsize-1] = 0;
                        /* parse the interface number */
-                       parse_num(rec.dptr, "IFNAME=ppp", &unit);
+                       parse_num(rec.dptr, "UNIT=", &unit);
                        /* check the pid value */
                        if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid)
                            || !process_exists(pppd_pid)
@@ -420,7 +420,7 @@ owns_unit(key, unit)
        TDB_DATA kd, vd;
        int ret = 0;
 
-       slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit);
+       slprintf(ifkey, sizeof(ifkey), "UNIT=%d", unit);
        kd.dptr = ifkey;
        kd.dsize = strlen(ifkey);
        vd = tdb_fetch(pppdb, kd);
@@ -593,4 +593,3 @@ str_to_epdisc(ep, str)
        ep->length = l;
        return 1;
 }
-