summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorxebd <xeb@mail.ru>2017-12-06 11:35:30 +0300
committerGitHub <noreply@github.com>2017-12-06 11:35:30 +0300
commit509afee2c6d9d9aa39d4202323bd8052c0f5f7b9 (patch)
tree844b22995b624dde84f33ea6bdb94839743219d5 /accel-pppd
parente959ea1bd262441a952ea0c807d553b4a9c38113 (diff)
parentae72e179afa46d82865aa8d459b32cc27541e4a7 (diff)
downloadaccel-ppp-xebd-509afee2c6d9d9aa39d4202323bd8052c0f5f7b9.tar.gz
accel-ppp-xebd-509afee2c6d9d9aa39d4202323bd8052c0f5f7b9.zip
Merge pull request #25 from themiron/ppp-ifname
ppp: implement per-ctrl ppp interface rename support
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/accel-ppp.conf3
-rw-r--r--accel-pppd/accel-ppp.conf.516
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c4
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c4
-rw-r--r--accel-pppd/ctrl/pptp/pptp.c4
-rw-r--r--accel-pppd/ifcfg.c20
6 files changed, 49 insertions, 2 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 7ab2efd..146585e 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -70,6 +70,7 @@ unit-cache=1
[pptp]
verbose=1
#echo-interval=30
+#ifname=pptp%d
[pppoe]
verbose=1
@@ -81,6 +82,7 @@ called-sid=mac
#tr101=1
#padi-limit=0
#ip-pool=pppoe
+#ifname=pppoe%d
#sid-uppercase=0
#vlan-mon=eth0,10-200
#vlan-timeout=60
@@ -103,6 +105,7 @@ verbose=1
#dataseq=allow
#reorder-timeout=0
#ip-pool=l2tp
+#ifname=l2tp%d
[ipoe]
verbose=1
diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5
index c8c8ce1..e566d47 100644
--- a/accel-pppd/accel-ppp.conf.5
+++ b/accel-pppd/accel-ppp.conf.5
@@ -462,6 +462,11 @@ Specifies maximum number of echo-requests may be sent without valid echo-reply,
Timeout waiting reply from client in seconds (default 5).
.TP
.BI "mppe=" deny|allow|prefer|require
+.TP
+.BI "ifname=" ifname
+If this option is given ppp interface will be renamed using
+.B ifname
+as a template, i.e pptp%d => pptp0.
.SH [pppoe]
.br
Configuration of PPPoE module.
@@ -522,6 +527,11 @@ Specifies whether to handle TR101 tags.
Specifies overall limit of PADI packets to reply in 1 second period (default 0 - unlimited). Rate of per-mac PADI packets is limited to no more than 1 packet per second.
.TP
.BI "mppe=" deny|allow|prefer|require
+.TP
+.BI "ifname=" ifname
+If this option is given ppp interface will be renamed using
+.B ifname
+as a template, i.e pppoe%d => pppoe0.
.SH [l2tp]
.br
Configuration of L2TP module.
@@ -572,7 +582,6 @@ is greater of zero then l2tp module will produce verbose logging.
.TP
.BI "mppe=" deny|allow|prefer|require
.TP
-.TP
.BI "secret=" string
Specifies secret to connect to server.
.TP
@@ -609,6 +618,11 @@ reply (SCCRP). Default value is 0.
.BI "ppp-max-mtu=" n
Set the maximun MTU value that can be negociated for PPP over L2TP
sessions. Default value is 1420.
+.TP
+.BI "ifname=" ifname
+If this option is given ppp interface will be renamed using
+.B ifname
+as a template, i.e l2tp%d => l2tp0.
.SH [radius]
.br
Configuration of RADIUS module.
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index a44d31d..55881b8 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -94,6 +94,7 @@ static int conf_mppe = MPPE_UNSET;
static int conf_dataseq = L2TP_DATASEQ_ALLOW;
static int conf_reorder_timeout = 0;
static const char *conf_ip_pool;
+static const char *conf_ifname;
static unsigned int stat_conn_starting;
static unsigned int stat_conn_active;
@@ -1796,6 +1797,8 @@ static int l2tp_session_start_data_channel(struct l2tp_sess_t *sess)
goto err;
}
}
+ if (conf_ifname)
+ sess->ppp.ses.ifname_rename = _strdup(conf_ifname);
sess->ppp.ses.ctrl = &sess->ctrl;
sess->apses_state = APSTATE_INIT;
@@ -4928,6 +4931,7 @@ static void load_config(void)
}
conf_ip_pool = conf_get_opt("l2tp", "ip-pool");
+ conf_ifname = conf_get_opt("l2tp", "ifname");
switch (iprange_check_activation()) {
case IPRANGE_DISABLED:
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index c572176..4f99354 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -98,6 +98,7 @@ int conf_padi_limit = 0;
int conf_mppe = MPPE_UNSET;
int conf_sid_uppercase = 0;
static const char *conf_ip_pool;
+static const char *conf_ifname;
enum {CSID_MAC, CSID_IFNAME, CSID_IFNAME_MAC};
static int conf_called_sid;
static int conf_cookie_timeout;
@@ -407,6 +408,8 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
if (conf_ip_pool)
conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
+ if (conf_ifname)
+ conn->ppp.ses.ifname_rename = _strdup(conf_ifname);
triton_context_register(&conn->ctx, conn);
@@ -2009,6 +2012,7 @@ static void load_config(void)
}
conf_ip_pool = conf_get_opt("pppoe", "ip-pool");
+ conf_ifname = conf_get_opt("pppoe", "ifname");
conf_called_sid = CSID_MAC;
opt = conf_get_opt("pppoe", "called-sid");
diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c
index fa48687..88b3759 100644
--- a/accel-pppd/ctrl/pptp/pptp.c
+++ b/accel-pppd/ctrl/pptp/pptp.c
@@ -61,6 +61,7 @@ static int conf_echo_failure = 3;
static int conf_verbose = 0;
static int conf_mppe = MPPE_UNSET;
static const char *conf_ip_pool;
+static const char *conf_ifname;
static mempool_t conn_pool;
@@ -705,6 +706,8 @@ static int pptp_connect(struct triton_md_handler_t *h)
if (conf_ip_pool)
conn->ppp.ses.ipv4_pool_name = _strdup(conf_ip_pool);
+ if (conf_ifname)
+ conn->ppp.ses.ifname_rename = _strdup(conf_ifname);
triton_context_register(&conn->ctx, &conn->ppp.ses);
triton_md_register_handler(&conn->ctx, &conn->hnd);
@@ -781,6 +784,7 @@ static void load_config(void)
}
conf_ip_pool = conf_get_opt("pptp", "ip-pool");
+ conf_ifname = conf_get_opt("pptp", "ifname");
switch (iprange_check_activation()) {
case IPRANGE_DISABLED:
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index b2cb0db..a101d47 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -321,7 +321,25 @@ int __export ap_session_rename(struct ap_session *ses, const char *ifname, int l
else
log_ppp_warn("interface rename to %s failed: %s\n", ifr.ifr_newname, strerror(errno));
} else {
- log_ppp_info2("rename interface to '%s'\n", ifr.ifr_newname);
+ /* required since 2.6.27 */
+ if (strchr(ifr.ifr_newname, '%')) {
+ ifr.ifr_ifindex = ses->ifindex;
+ r = net->sock_ioctl(SIOCGIFNAME, &ifr);
+ if (r) {
+ log_ppp_error("failed to get new interface name: %s\n", strerror(errno));
+ return -1;
+ }
+ len = strnlen(ifr.ifr_name, IFNAMSIZ);
+ if (len >= IFNAMSIZ) {
+ log_ppp_error("cannot rename interface (name is too long)\n");
+ return -1;
+ }
+ ifr.ifr_name[len] = 0;
+ ifname = ifr.ifr_name;
+ } else
+ ifname = ifr.ifr_newname;
+
+ log_ppp_info2("rename interface to '%s'\n", ifname);
memcpy(ses->ifname, ifname, len);
ses->ifname[len] = 0;
}