Browse Source

LinuxEthernetTap addIps virtual function fix for SYNOLOGY builds

pull/2/head
Joseph Henry 7 years ago
parent
commit
d8de837c60
  1. 1
      osdep/EthernetTap.hpp
  2. 10
      osdep/LinuxEthernetTap.cpp
  3. 4
      osdep/LinuxEthernetTap.hpp
  4. 3
      service/OneService.cpp

1
osdep/EthernetTap.hpp

@ -45,6 +45,7 @@ public:
virtual void setEnabled(bool en) = 0; virtual void setEnabled(bool en) = 0;
virtual bool enabled() const = 0; virtual bool enabled() const = 0;
virtual bool addIp(const InetAddress &ip) = 0; virtual bool addIp(const InetAddress &ip) = 0;
virtual bool addIps(std::vector<InetAddress> ips) = 0;
virtual bool removeIp(const InetAddress &ip) = 0; virtual bool removeIp(const InetAddress &ip) = 0;
virtual std::vector<InetAddress> ips() const = 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; virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) = 0;

10
osdep/LinuxEthernetTap.cpp

@ -261,10 +261,9 @@ static bool ___removeIp(const std::string &_dev,const InetAddress &ip)
return true; return true;
} }
#ifdef __SYNOLOGY__ bool LinuxEthernetTap::addIps(std::vector<InetAddress> ips)
bool LinuxEthernetTap::addIpSyn(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 filepath = "/etc/sysconfig/network-scripts/ifcfg-"+_dev;
std::string cfg_contents = "DEVICE="+_dev+"\nBOOTPROTO=static"; std::string cfg_contents = "DEVICE="+_dev+"\nBOOTPROTO=static";
int ip4=0,ip6=0,ip4_tot=0,ip6_tot=0; 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()); 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++){ for(int i=0; i<(int)ips.size(); i++){
LinuxNetLink::getInstance().addAddress(ips[i], _dev.c_str()); LinuxNetLink::getInstance().addAddress(ips[i], _dev.c_str());
} }
return true; return true;
}
#endif // __SYNOLOGY__ #endif // __SYNOLOGY__
return false;
}
bool LinuxEthernetTap::addIp(const InetAddress &ip) bool LinuxEthernetTap::addIp(const InetAddress &ip)
{ {

4
osdep/LinuxEthernetTap.hpp

@ -46,9 +46,7 @@ public:
virtual void setEnabled(bool en); virtual void setEnabled(bool en);
virtual bool enabled() const; virtual bool enabled() const;
virtual bool addIp(const InetAddress &ip); virtual bool addIp(const InetAddress &ip);
#ifdef __SYNOLOGY__ virtual bool addIps(std::vector<InetAddress> ips);
bool addIpSyn(std::vector<InetAddress> ips);
#endif
virtual bool removeIp(const InetAddress &ip); virtual bool removeIp(const InetAddress &ip);
virtual std::vector<InetAddress> ips() const; virtual std::vector<InetAddress> ips() const;
virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); virtual void put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len);

3
service/OneService.cpp

@ -1715,8 +1715,9 @@ public:
} }
} }
#ifdef __SYNOLOGY__ #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); fprintf(stderr,"ERROR: unable to add ip addresses to ifcfg" ZT_EOL_S);
}
#else #else
for(std::vector<InetAddress>::iterator ip(newManagedIps.begin());ip!=newManagedIps.end();++ip) { 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()) { if (std::find(n.managedIps.begin(),n.managedIps.end(),*ip) == n.managedIps.end()) {

Loading…
Cancel
Save