From b5b335a6f844a21ac23e260b6deb8f69bdc61129 Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Thu, 16 Feb 2017 16:41:26 -0800 Subject: [PATCH] Route re-add patch for linux build on Synology devices --- make-linux.mk | 4 ++++ osdep/LinuxEthernetTap.cpp | 2 ++ service/OneService.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/make-linux.mk b/make-linux.mk index 29d19830f..68f865bf3 100644 --- a/make-linux.mk +++ b/make-linux.mk @@ -41,6 +41,10 @@ ifeq ($(ZT_ENABLE_CLUSTER),1) DEFS+=-DZT_ENABLE_CLUSTER endif +ifeq ($(ZT_SYNOLOGY), 1) + DEFS+=-D__SYNOLOGY__ +endif + ifeq ($(ZT_TRACE),1) DEFS+=-DZT_TRACE endif diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp index e336bb67d..55a6d9f68 100644 --- a/osdep/LinuxEthernetTap.cpp +++ b/osdep/LinuxEthernetTap.cpp @@ -221,8 +221,10 @@ bool LinuxEthernetTap::addIp(const InetAddress &ip) return false; std::vector allIps(ips()); +#ifndef __SYNOLOGY__ if (std::binary_search(allIps.begin(),allIps.end(),ip)) return true; +#endif // Remove and reconfigure if address is the same but netmask is different for(std::vector::iterator i(allIps.begin());i!=allIps.end();++i) { diff --git a/service/OneService.cpp b/service/OneService.cpp index aa90798fd..dc3e0ed1b 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -1088,12 +1088,17 @@ public: } } for(std::vector::iterator ip(newManagedIps.begin());ip!=newManagedIps.end();++ip) { +#ifdef __SYNOLOGY__ + if (!n.tap->addIp(*ip)) + fprintf(stderr,"ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString().c_str()); +#else if (std::find(n.managedIps.begin(),n.managedIps.end(),*ip) == n.managedIps.end()) { + if (!n.tap->addIp(*ip)) fprintf(stderr,"ERROR: unable to add ip address %s" ZT_EOL_S, ip->toString().c_str()); } +#endif } - n.managedIps.swap(newManagedIps); }