diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2016-03-29 13:25:31 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2016-03-29 13:25:31 +0300 |
commit | b8718a7737e0e58d404914a21747cbebf2d9c425 (patch) | |
tree | 68ec4132faa01e3690b249bbfa6a43e622818b56 /accel-pppd/ctrl | |
parent | 07ca3acb40df7668cfd0c6abbdcefc21d944d993 (diff) | |
download | accel-ppp-b8718a7737e0e58d404914a21747cbebf2d9c425.tar.gz accel-ppp-b8718a7737e0e58d404914a21747cbebf2d9c425.zip |
ipoe: do not cleanup shared=1 interfaces
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 8068983..1a50154 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -1085,20 +1085,24 @@ static void ipoe_session_finished(struct ap_session *s) if (s->ifindex == ses->serv->ifindex && strcmp(s->ifname, ses->serv->ifname)) { struct ifreq ifr; + int flags; log_info2("ipoe: rename %s to %s\n", s->ifname, ses->serv->ifname); strcpy(ifr.ifr_name, s->ifname); ioctl(sock_fd, SIOCGIFFLAGS, &ifr); - ifr.ifr_flags &= ~IFF_UP; - ioctl(sock_fd, SIOCSIFFLAGS, &ifr); + flags = ifr.ifr_flags; + if (flags & IFF_UP) { + ifr.ifr_flags &= ~IFF_UP; + ioctl(sock_fd, SIOCSIFFLAGS, &ifr); + } strcpy(ifr.ifr_newname, ses->serv->ifname); ioctl(sock_fd, SIOCSIFNAME, &ifr); strcpy(ifr.ifr_name, ses->serv->ifname); - ifr.ifr_flags |= IFF_UP; + ifr.ifr_flags = flags | IFF_UP; ioctl(sock_fd, SIOCSIFFLAGS, &ifr); } @@ -2625,10 +2629,6 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, ifname); - ((struct sockaddr_in *)&ifr.ifr_addr)->sin_family = AF_INET; - - ioctl(sock_fd, SIOCSIFADDR, &ifr, sizeof(ifr)); - if (ioctl(sock_fd, SIOCGIFHWADDR, &ifr)) { log_error("ipoe: '%s': ioctl(SIOCGIFHWADDR): %s\n", ifname, strerror(errno)); return; @@ -2636,9 +2636,19 @@ static void add_interface(const char *ifname, int ifindex, const char *opt, int ioctl(sock_fd, SIOCGIFFLAGS, &ifr); - if (ifr.ifr_flags & IFF_UP) { + if ((ifr.ifr_flags & IFF_UP) && opt_shared == 0) { + int flags = ifr.ifr_flags; + ifr.ifr_flags &= ~IFF_UP; ioctl(sock_fd, SIOCSIFFLAGS, &ifr); + + flags = ifr.ifr_flags; + + ((struct sockaddr_in *)&ifr.ifr_addr)->sin_family = AF_INET; + ((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr = 0; + ioctl(sock_fd, SIOCSIFADDR, &ifr, sizeof(ifr)); + + ifr.ifr_flags = flags; } ifr.ifr_flags |= IFF_UP; |