summaryrefslogtreecommitdiff
path: root/accel-pppd/ifcfg.c
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2017-10-30 17:27:22 +0500
committerVladislav Grishenko <themiron@mail.ru>2017-12-05 20:39:15 +0500
commitae72e179afa46d82865aa8d459b32cc27541e4a7 (patch)
treef426671bf7ef9cecf06937f7a673f8b03b7a58bd /accel-pppd/ifcfg.c
parent71770d7a41278731f676a11ff943da735a09c5b0 (diff)
downloadaccel-ppp-xebd-ae72e179afa46d82865aa8d459b32cc27541e4a7.tar.gz
accel-ppp-xebd-ae72e179afa46d82865aa8d459b32cc27541e4a7.zip
ppp: implement per-ctrl ppp interface rename support, may be overrided by radius
Reuse exsisting radius functionality and allow set iterface name template for pppoe/pptp/l2tp, '%d' specification will be replaced automagically to the next available index by kernel. PPP interface rename allows to easy differ client's interfaces from the other ppp ones, for example, with just netfilter interface rules. Example: [pptp] ifname=pptp%d will produce pptp0, pptp1, ...
Diffstat (limited to 'accel-pppd/ifcfg.c')
-rw-r--r--accel-pppd/ifcfg.c20
1 files changed, 19 insertions, 1 deletions
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;
}