1 From: George Kashperko <george@znau.edu.ua>
3 Make mlppp support more generic interface naming other than pppX
4 Signed-off-by: George Kashperko <george@znau.edu.ua>
6 pppd/multilink.c | 55 +++++++++++++++++++++++++++++++++------------
7 pppd/sys-linux.c | 12 +++++++++
8 2 files changed, 53 insertions(+), 14 deletions(-)
10 +++ b/pppd/multilink.c
11 @@ -56,7 +56,8 @@ static void iterate_bundle_links __P((vo
13 static int get_default_epdisc __P((struct epdisc *));
14 static int parse_num __P((char *str, const char *key, int *valp));
15 -static int owns_unit __P((TDB_DATA pid, int unit));
16 +static int parse_str __P((char *str, const char *key, char *buf, int buflen));
17 +static int owns_link __P((TDB_DATA pid, char *ifname));
19 #define set_ip_epdisc(ep, addr) do { \
21 @@ -197,35 +198,38 @@ mp_join_bundle()
23 key.dsize = p - bundle_id;
24 pid = tdb_fetch(pppdb, key);
26 if (pid.dptr != NULL) {
29 /* bundle ID exists, see if the pppd record exists */
30 rec = tdb_fetch(pppdb, pid);
32 if (rec.dptr != NULL && rec.dsize > 0) {
33 /* make sure the string is null-terminated */
34 rec.dptr[rec.dsize-1] = 0;
35 - /* parse the interface number */
36 - parse_num(rec.dptr, "IFNAME=ppp", &unit);
38 /* check the pid value */
39 if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid)
40 + || !parse_str(rec.dptr, "IFNAME=", tmp, sizeof(tmp))
41 + || !parse_num(rec.dptr, "IFUNIT=", &unit)
42 || !process_exists(pppd_pid)
43 - || !owns_unit(pid, unit))
44 + || !owns_link(pid, tmp))
52 /* attach to existing unit */
53 - if (bundle_attach(unit)) {
54 + if (unit >= 0 && bundle_attach(unit)) {
56 script_setenv("BUNDLE", bundle_id + 7, 0);
59 - info("Link attached to %s", ifname);
60 + info("Link attached to %s", tmp);
62 + /* attach failed because bundle doesn't exist */
64 - /* attach failed because bundle doesn't exist */
67 /* we have to make a new bundle */
68 @@ -408,22 +412,45 @@ parse_num(str, key, valp)
73 +parse_str(str, key, buf, buflen)
82 + p = strstr(str, key);
85 + while (--buflen && *p != 0 && *p != ';')
94 - * Check whether the pppd identified by `key' still owns ppp unit `unit'.
95 + * Check whether the pppd identified by `key' still owns ppp link `ifname'.
99 +owns_link(key, ifname)
105 + char ifkey[7 + IFNAMSIZ];
109 - slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit);
110 + slprintf(ifkey, sizeof(ifkey), "IFNAME=%s", ifname);
113 kd.dsize = strlen(ifkey);
114 vd = tdb_fetch(pppdb, kd);
116 if (vd.dptr != NULL) {
117 ret = vd.dsize == key.dsize
118 && memcmp(vd.dptr, key.dptr, vd.dsize) == 0;
119 --- a/pppd/sys-linux.c
120 +++ b/pppd/sys-linux.c
121 @@ -698,6 +698,16 @@ void cfg_bundle(int mrru, int mtru, int
130 + slprintf(tmp, sizeof(tmp), "%d", ifunit);
131 + script_setenv("IFUNIT", tmp, 0);
136 * make_new_bundle - create a new PPP unit (i.e. a bundle)
137 * and connect our channel to it. This should only get called
138 @@ -716,6 +726,8 @@ void make_new_bundle(int mrru, int mtru,
140 /* set the mrru and flags */
141 cfg_bundle(mrru, mtru, rssn, tssn);