Browse Source

LinuxEthernetTap addIps virtual function fix for SYNOLOGY builds

Joseph Henry 6 years ago
parent
commit
d8de837c60
4 changed files with 9 additions and 9 deletions
  1. 1 0
      osdep/EthernetTap.hpp
  2. 5 5
      osdep/LinuxEthernetTap.cpp
  3. 1 3
      osdep/LinuxEthernetTap.hpp
  4. 2 1
      service/OneService.cpp

+ 1 - 0
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<InetAddress> ips) = 0;
 	virtual bool removeIp(const InetAddress &ip) = 0;
 	virtual std::vector<InetAddress> ips() const = 0;
 	virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) = 0;

+ 5 - 5
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<InetAddress> ips)
+bool LinuxEthernetTap::addIps(std::vector<InetAddress> 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<InetAddress> 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)
 {

+ 1 - 3
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<InetAddress> ips);
-#endif
+	virtual bool addIps(std::vector<InetAddress> ips);
 	virtual bool removeIp(const InetAddress &ip);
 	virtual std::vector<InetAddress> ips() const;
 	virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);

+ 2 - 1
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<InetAddress>::iterator ip(newManagedIps.begin());ip!=newManagedIps.end();++ip) {
 				if (std::find(n.managedIps.begin(),n.managedIps.end(),*ip) == n.managedIps.end()) {