From 56371803b11c557e07ae968bef34b178b518139d Mon Sep 17 00:00:00 2001 From: fhost Date: Sat, 19 Oct 2019 08:05:28 +0200 Subject: [PATCH] pppd: Fix `ifname` option in case of multilink (#105) 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 --- pppd/main.c | 3 +++ pppd/multilink.c | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pppd/main.c b/pppd/main.c index 1b3f1e5..9e9803a 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -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()); diff --git a/pppd/multilink.c b/pppd/multilink.c index c49c446..eb4074d 100644 --- a/pppd/multilink.c +++ b/pppd/multilink.c @@ -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; } - -- 2.39.2