summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxebd <xeb@mail.ru>2017-12-14 19:05:15 +0300
committerGitHub <noreply@github.com>2017-12-14 19:05:15 +0300
commit92925bfc047b32a6bb918fa6e01b8bb7e9216722 (patch)
tree69730ba7bc84f0eab46d96a3ca73dca5b6362313
parenta57c152927844cb511d48a9de529149d4db97f51 (diff)
parentbbf096cb5d20abbbac39bef75cacf057a7364745 (diff)
downloadaccel-ppp-92925bfc047b32a6bb918fa6e01b8bb7e9216722.tar.gz
accel-ppp-92925bfc047b32a6bb918fa6e01b8bb7e9216722.zip
Merge pull request #27 from themiron/ppp-ifname
ppp: fix interface rename if kernel returns not zero, but picked index
-rw-r--r--accel-pppd/ifcfg.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c
index a101d475..956ec6ee 100644
--- a/accel-pppd/ifcfg.c
+++ b/accel-pppd/ifcfg.c
@@ -303,7 +303,7 @@ int __export ap_session_rename(struct ap_session *ses, const char *ifname, int l
ifr.ifr_newname[len] = 0;
r = net->sock_ioctl(SIOCSIFNAME, &ifr);
- if (r && errno == EBUSY) {
+ if (r < 0 && errno == EBUSY) {
net->sock_ioctl(SIOCGIFFLAGS, &ifr);
ifr.ifr_flags &= ~IFF_UP;
net->sock_ioctl(SIOCSIFFLAGS, &ifr);
@@ -315,7 +315,7 @@ int __export ap_session_rename(struct ap_session *ses, const char *ifname, int l
up = 1;
}
- if (r) {
+ if (r < 0) {
if (!ses->ifname_rename)
ses->ifname_rename = _strdup(ifr.ifr_newname);
else
@@ -325,7 +325,7 @@ int __export ap_session_rename(struct ap_session *ses, const char *ifname, int l
if (strchr(ifr.ifr_newname, '%')) {
ifr.ifr_ifindex = ses->ifindex;
r = net->sock_ioctl(SIOCGIFNAME, &ifr);
- if (r) {
+ if (r < 0) {
log_ppp_error("failed to get new interface name: %s\n", strerror(errno));
return -1;
}