diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-07-11 14:35:58 +0400 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-07-11 14:35:58 +0400 |
commit | 5e824440c2044a443d73d53650505f55c6c4038b (patch) | |
tree | f1173bc44c8be850823b3f219f55c204d42b4b1e /accel-pppd | |
parent | ca96af9c783f0aa01d89f3226e91014a77f7624f (diff) | |
download | accel-ppp-5e824440c2044a443d73d53650505f55c6c4038b.tar.gz accel-ppp-5e824440c2044a443d73d53650505f55c6c4038b.zip |
terminate session if interface rename fails
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/ifcfg.c | 17 | ||||
-rw-r--r-- | accel-pppd/include/ap_session.h | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c index 0242808..3aff9eb 100644 --- a/accel-pppd/ifcfg.c +++ b/accel-pppd/ifcfg.c @@ -65,7 +65,10 @@ void ap_session_ifup(struct ap_session *ses) struct ppp_t *ppp; if (ses->ifname_rename) { - ap_session_rename(ses, ses->ifname_rename, -1); + if (ap_session_rename(ses, ses->ifname_rename, -1)) { + ap_session_terminate(ses, TERM_NAS_ERROR, 0); + return; + } _free(ses->ifname_rename); ses->ifname_rename = NULL; } @@ -237,7 +240,7 @@ void __export ap_session_ifdown(struct ap_session *ses) } } -void __export ap_session_rename(struct ap_session *ses, const char *ifname, int len) +int __export ap_session_rename(struct ap_session *ses, const char *ifname, int len) { struct ifreq ifr; @@ -245,8 +248,8 @@ void __export ap_session_rename(struct ap_session *ses, const char *ifname, int len = strlen(ifname); if (len >= IFNAMSIZ - 1) { - log_ppp_warn("cannot rename interface (name it too long)\n"); - return; + log_ppp_warn("cannot rename interface (name is too long)\n"); + return -1; } ifr.ifr_ifindex = ses->ifindex; @@ -257,12 +260,16 @@ void __export ap_session_rename(struct ap_session *ses, const char *ifname, int if (ioctl(sock_fd, SIOCSIFNAME, &ifr)) { if (!ses->ifname_rename) ses->ifname_rename = _strdup(ifr.ifr_newname); - else + else { log_ppp_warn("interface rename failed: %s\n", strerror(errno)); + return -1; + } } else { log_ppp_info2("rename interface to '%s'\n", ifr.ifr_newname); memcpy(ses->ifname, ifname, len); ses->ifname[len] = 0; } + + return 0; } diff --git a/accel-pppd/include/ap_session.h b/accel-pppd/include/ap_session.h index a7cc43f..f6d92d7 100644 --- a/accel-pppd/include/ap_session.h +++ b/accel-pppd/include/ap_session.h @@ -131,7 +131,7 @@ int ap_session_set_username(struct ap_session *ses, char *username); void ap_session_ifup(struct ap_session *ses); void ap_session_ifdown(struct ap_session *ses); -void ap_session_rename(struct ap_session *ses, const char *ifname, int len); +int ap_session_rename(struct ap_session *ses, const char *ifname, int len); int ap_session_read_stats(struct ap_session *ses, struct rtnl_link_stats *stats); |