summaryrefslogtreecommitdiff
path: root/accel-pppd/ifcfg.c
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-05-18 03:02:29 +0000
committerDmitry Kozlov <xeb@mail.ru>2014-05-18 03:02:29 +0000
commitd3a17940de818452970a80cb7dba7a793f8ee1e2 (patch)
tree0800f5975b6e5bd6fca886f3922e74f407aa3e9e /accel-pppd/ifcfg.c
parentad39c45f1fe5ba4f84c87de6166c55c2c176840c (diff)
downloadaccel-ppp-d3a17940de818452970a80cb7dba7a793f8ee1e2.tar.gz
accel-ppp-d3a17940de818452970a80cb7dba7a793f8ee1e2.zip
2-way interface renaming
First try to rename interface immediately and if it fails then do second try later just before bring interface up. In case single-session=replace first try to rename interface may fail because first session may be active
Diffstat (limited to 'accel-pppd/ifcfg.c')
-rw-r--r--accel-pppd/ifcfg.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index bbbcc02d..02428087 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -18,6 +18,7 @@
#include "ipdb.h"
#include "log.h"
#include "backup.h"
+#include "memdebug.h"
// from /usr/include/linux/ipv6.h
struct in6_ifreq {
@@ -63,6 +64,12 @@ void ap_session_ifup(struct ap_session *ses)
struct sockaddr_in addr;
struct ppp_t *ppp;
+ if (ses->ifname_rename) {
+ ap_session_rename(ses, ses->ifname_rename, -1);
+ _free(ses->ifname_rename);
+ ses->ifname_rename = NULL;
+ }
+
triton_event_fire(EV_SES_ACCT_START, ses);
if (ses->stop_time)
return;
@@ -246,10 +253,14 @@ void __export ap_session_rename(struct ap_session *ses, const char *ifname, int
strcpy(ifr.ifr_name, ses->ifname);
memcpy(ifr.ifr_newname, ifname, len);
ifr.ifr_newname[len] = 0;
-
- if (ioctl(sock_fd, SIOCSIFNAME, &ifr))
- log_ppp_warn("interface rename failed: %s\n", strerror(errno));
- else {
+
+ if (ioctl(sock_fd, SIOCSIFNAME, &ifr)) {
+ if (!ses->ifname_rename)
+ ses->ifname_rename = _strdup(ifr.ifr_newname);
+ else
+ log_ppp_warn("interface rename failed: %s\n", strerror(errno));
+ } else {
+ log_ppp_info2("rename interface to '%s'\n", ifr.ifr_newname);
memcpy(ses->ifname, ifname, len);
ses->ifname[len] = 0;
}