diff --git a/osdep/EthernetTap.hpp b/osdep/EthernetTap.hpp index 26503de0e..e39b41509 100644 --- a/osdep/EthernetTap.hpp +++ b/osdep/EthernetTap.hpp @@ -45,6 +45,7 @@ public: virtual void setEnabled(bool en) = 0; virtual bool enabled() const = 0; virtual bool addIp(const InetAddress &ip) = 0; + virtual bool addIps(std::vector ips) = 0; virtual bool removeIp(const InetAddress &ip) = 0; virtual std::vector ips() const = 0; virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) = 0; diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp index 06a87bdcb..b340561ed 100644 --- a/osdep/LinuxEthernetTap.cpp +++ b/osdep/LinuxEthernetTap.cpp @@ -261,10 +261,9 @@ static bool ___removeIp(const std::string &_dev,const InetAddress &ip) return true; } -#ifdef __SYNOLOGY__ -bool LinuxEthernetTap::addIpSyn(std::vector ips) +bool LinuxEthernetTap::addIps(std::vector ips) { - // Here we fill out interface config (ifcfg-dev) to prevent it from being killed +#ifdef __SYNOLOGY__ std::string filepath = "/etc/sysconfig/network-scripts/ifcfg-"+_dev; std::string cfg_contents = "DEVICE="+_dev+"\nBOOTPROTO=static"; int ip4=0,ip6=0,ip4_tot=0,ip6_tot=0; @@ -292,13 +291,14 @@ bool LinuxEthernetTap::addIpSyn(std::vector ips) } } OSUtils::writeFile(filepath.c_str(), cfg_contents.c_str(), cfg_contents.length()); - // Finaly, add IPs + // Finally, add IPs for(int i=0; i<(int)ips.size(); i++){ LinuxNetLink::getInstance().addAddress(ips[i], _dev.c_str()); } return true; -} #endif // __SYNOLOGY__ + return false; +} bool LinuxEthernetTap::addIp(const InetAddress &ip) { diff --git a/osdep/LinuxEthernetTap.hpp b/osdep/LinuxEthernetTap.hpp index 3660fb39f..7503c5231 100644 --- a/osdep/LinuxEthernetTap.hpp +++ b/osdep/LinuxEthernetTap.hpp @@ -46,9 +46,7 @@ public: virtual void setEnabled(bool en); virtual bool enabled() const; virtual bool addIp(const InetAddress &ip); -#ifdef __SYNOLOGY__ - bool addIpSyn(std::vector ips); -#endif + virtual bool addIps(std::vector ips); virtual bool removeIp(const InetAddress &ip); virtual std::vector ips() const; virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); diff --git a/service/OneService.cpp b/service/OneService.cpp index 77b60b37e..f3ec3e665 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1715,8 +1715,9 @@ public: } } #ifdef __SYNOLOGY__ - if (!n.tap->addIpSyn(newManagedIps)) + if (!n.tap->addIps(newManagedIps)) { fprintf(stderr,"ERROR: unable to add ip addresses to ifcfg" ZT_EOL_S); + } #else for(std::vector::iterator ip(newManagedIps.begin());ip!=newManagedIps.end();++ip) { if (std::find(n.managedIps.begin(),n.managedIps.end(),*ip) == n.managedIps.end()) {