summaryrefslogtreecommitdiff
path: root/accel-pppd/ifcfg.c
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/ifcfg.c
parente959ea1bd262441a952ea0c807d553b4a9c38113 (diff)
parentae72e179afa46d82865aa8d459b32cc27541e4a7 (diff)
downloadaccel-ppp-509afee2c6d9d9aa39d4202323bd8052c0f5f7b9.tar.gz
accel-ppp-509afee2c6d9d9aa39d4202323bd8052c0f5f7b9.zip
Merge pull request #25 from themiron/ppp-ifname
ppp: implement per-ctrl ppp interface rename support
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 b2cb0db3..a101d475 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;
}