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
13 #include <netinet/in.h>
19 @@ -56,7 +57,8 @@ static void iterate_bundle_links __P((vo
21 static int get_default_epdisc __P((struct epdisc *));
22 static int parse_num __P((char *str, const char *key, int *valp));
23 -static int owns_unit __P((TDB_DATA pid, int unit));
24 +static int parse_str __P((char *str, const char *key, char *buf, int buflen));
25 +static int owns_link __P((TDB_DATA pid, char *ifname));
27 #define set_ip_epdisc(ep, addr) do { \
29 @@ -197,35 +199,38 @@ mp_join_bundle()
31 key.dsize = p - bundle_id;
32 pid = tdb_fetch(pppdb, key);
34 if (pid.dptr != NULL) {
37 /* bundle ID exists, see if the pppd record exists */
38 rec = tdb_fetch(pppdb, pid);
40 if (rec.dptr != NULL && rec.dsize > 0) {
41 /* make sure the string is null-terminated */
42 rec.dptr[rec.dsize-1] = 0;
43 - /* parse the interface number */
44 - parse_num(rec.dptr, "IFNAME=ppp", &unit);
46 /* check the pid value */
47 if (!parse_num(rec.dptr, "PPPD_PID=", &pppd_pid)
48 + || !parse_str(rec.dptr, "IFNAME=", tmp, sizeof(tmp))
49 + || !parse_num(rec.dptr, "IFUNIT=", &unit)
50 || !process_exists(pppd_pid)
51 - || !owns_unit(pid, unit))
52 + || !owns_link(pid, tmp))
60 /* attach to existing unit */
61 - if (bundle_attach(unit)) {
62 + if (unit >= 0 && bundle_attach(unit)) {
64 script_setenv("BUNDLE", bundle_id + 7, 0);
67 - info("Link attached to %s", ifname);
68 + info("Link attached to %s", tmp);
70 + /* attach failed because bundle doesn't exist */
72 - /* attach failed because bundle doesn't exist */
75 /* we have to make a new bundle */
76 @@ -408,22 +413,45 @@ parse_num(str, key, valp)
81 +parse_str(str, key, buf, buflen)
90 + p = strstr(str, key);
93 + while (--buflen && *p != 0 && *p != ';')
102 - * Check whether the pppd identified by `key' still owns ppp unit `unit'.
103 + * Check whether the pppd identified by `key' still owns ppp link `ifname'.
106 -owns_unit(key, unit)
107 +owns_link(key, ifname)
113 + char ifkey[7 + IFNAMSIZ];
117 - slprintf(ifkey, sizeof(ifkey), "IFNAME=ppp%d", unit);
118 + slprintf(ifkey, sizeof(ifkey), "IFNAME=%s", ifname);
121 kd.dsize = strlen(ifkey);
122 vd = tdb_fetch(pppdb, kd);
124 if (vd.dptr != NULL) {
125 ret = vd.dsize == key.dsize
126 && memcmp(vd.dptr, key.dptr, vd.dsize) == 0;
127 --- a/pppd/sys-linux.c
128 +++ b/pppd/sys-linux.c
129 @@ -686,6 +686,16 @@ void cfg_bundle(int mrru, int mtru, int
138 + slprintf(tmp, sizeof(tmp), "%d", ifunit);
139 + script_setenv("IFUNIT", tmp, 0);
144 * make_new_bundle - create a new PPP unit (i.e. a bundle)
145 * and connect our channel to it. This should only get called
146 @@ -704,6 +714,8 @@ void make_new_bundle(int mrru, int mtru,
148 /* set the mrru and flags */
149 cfg_bundle(mrru, mtru, rssn, tssn);