From 782b75a64ed3d5cfdeac1a90ace557488d12c6e2 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 20 Jan 2020 21:27:51 -0800 Subject: [PATCH] Linux build fixes --- go/native/CoreTests.cpp | 4 ++-- node/AES.cpp | 2 +- node/Hashtable.hpp | 1 + node/Identity.hpp | 2 +- node/OS.hpp | 2 +- osdep/LinuxEthernetTap.cpp | 2 +- osdep/NeighborDiscovery.cpp | 7 ++++--- root/root.cpp | 1 + 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/go/native/CoreTests.cpp b/go/native/CoreTests.cpp index add6f9c5b..4acbb3903 100644 --- a/go/native/CoreTests.cpp +++ b/go/native/CoreTests.cpp @@ -45,6 +45,8 @@ using namespace ZeroTier; +static volatile uint8_t foo = 0; + #define KNOWN_GOOD_IDENTITY_0 "8e4df28b72:0:ac3d46abe0c21f3cfe7a6c8d6a85cfcffcb82fbd55af6a4d6350657c68200843fa2e16f9418bbd9702cae365f2af5fb4c420908b803a681d4daef6114d78a2d7:bd8dd6e4ce7022d2f812797a80c6ee8ad180dc4ebf301dec8b06d1be08832bddd63a2f1cfa7b2c504474c75bdc8898ba476ef92e8e2d0509f8441985171ff16e" #define KNOWN_BAD_IDENTITY_0 "9e4df28b72:0:ac3d46abe0c21f3cfe7a6c8d6a85cfcffcb82fbd55af6a4d6350657c68200843fa2e16f9418bbd9702cae365f2af5fb4c420908b803a681d4daef6114d78a2d7:bd8dd6e4ce7022d2f812797a80c6ee8ad180dc4ebf301dec8b06d1be08832bddd63a2f1cfa7b2c504474c75bdc8898ba476ef92e8e2d0509f8441985171ff16e" @@ -147,7 +149,6 @@ extern "C" int ZT_TestCrypto() { static uint8_t buf1[16384],buf2[16384],buf3[16384]; static char hexbuf[1024]; - volatile unsigned char *dummy = (volatile unsigned char *)&(buf1[100]); for(int i=0;i<3;++i) { Utils::getSecureRandom(buf1,64); @@ -385,7 +386,6 @@ extern "C" int ZT_TestCrypto() std::cout << "[crypto] Benchmarking asymmetric crypto..." ZT_EOL_S; { uint8_t pub[128],priv[128],hash[128],sig[128]; - volatile uint8_t foo = 0; Utils::getSecureRandom(hash,sizeof(hash)); C25519::generate(pub,priv); diff --git a/node/AES.cpp b/node/AES.cpp index f3b8ad571..59e39b46b 100644 --- a/node/AES.cpp +++ b/node/AES.cpp @@ -380,7 +380,7 @@ void AES::_gmacSW(const uint8_t iv[12],const uint8_t *in,unsigned int len,uint8_ #ifdef ZT_AES_AESNI -static ZT_ALWAYS_INLINE inline __m128i _mult_block_aesni(__m128i shuf,__m128i h,__m128i y) +static ZT_ALWAYS_INLINE __m128i _mult_block_aesni(__m128i shuf,__m128i h,__m128i y) { y = _mm_shuffle_epi8(y,shuf); __m128i t1 = _mm_clmulepi64_si128(h,y,0x00); diff --git a/node/Hashtable.hpp b/node/Hashtable.hpp index 122e57c2a..e262abfc0 100644 --- a/node/Hashtable.hpp +++ b/node/Hashtable.hpp @@ -17,6 +17,7 @@ #include "Constants.hpp" #include +#include #include #include diff --git a/node/Identity.hpp b/node/Identity.hpp index 7e7361ec2..87edc1b02 100644 --- a/node/Identity.hpp +++ b/node/Identity.hpp @@ -380,7 +380,7 @@ public: _hasPrivate = true; memcpy(&_priv,data + ZT_ADDRESS_LENGTH + 1 + ZT_IDENTITY_P384_COMPOUND_PUBLIC_KEY_SIZE + 1,ZT_IDENTITY_P384_COMPOUND_PRIVATE_KEY_SIZE); privlen = data[ZT_ADDRESS_LENGTH + 1 + ZT_IDENTITY_P384_COMPOUND_PUBLIC_KEY_SIZE + 1 + ZT_IDENTITY_P384_COMPOUND_PRIVATE_KEY_SIZE]; - if (len < (privlen + (ZT_ADDRESS_LENGTH + 1 + ZT_IDENTITY_P384_COMPOUND_PUBLIC_KEY_SIZE + 1 + ZT_IDENTITY_P384_COMPOUND_PRIVATE_KEY_SIZE + 1))) + if (len < (int)(privlen + (ZT_ADDRESS_LENGTH + 1 + ZT_IDENTITY_P384_COMPOUND_PUBLIC_KEY_SIZE + 1 + ZT_IDENTITY_P384_COMPOUND_PRIVATE_KEY_SIZE + 1))) return -1; return (int)(privlen + (unsigned int)(ZT_ADDRESS_LENGTH + 1 + ZT_IDENTITY_P384_COMPOUND_PUBLIC_KEY_SIZE + 1 + ZT_IDENTITY_P384_COMPOUND_PRIVATE_KEY_SIZE + 1)); } else if (privlen == 0) { diff --git a/node/OS.hpp b/node/OS.hpp index a9ca171d9..e1694b170 100644 --- a/node/OS.hpp +++ b/node/OS.hpp @@ -117,7 +117,7 @@ #endif #if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 800)) || defined(__clang__) -#define ZT_ALWAYS_INLINE __attribute__((always_inline)) +#define ZT_ALWAYS_INLINE __attribute__((always_inline)) inline #ifndef restrict #define restrict __restrict__ #endif diff --git a/osdep/LinuxEthernetTap.cpp b/osdep/LinuxEthernetTap.cpp index f68362a86..3f490bed8 100644 --- a/osdep/LinuxEthernetTap.cpp +++ b/osdep/LinuxEthernetTap.cpp @@ -415,7 +415,7 @@ void LinuxEthernetTap::scanMulticastGroups(std::vector &added,st mcastmac = f; ++fno; } - if ((devname)&&(!strcmp(devname,_dev.c_str()))&&(mcastmac)&&(Utils::unhex(mcastmac,mac,6) == 6)) + if ((devname)&&(!strcmp(devname,_dev.c_str()))&&(mcastmac)&&(Utils::unhex(mcastmac,strlen(mcastmac),mac,6) == 6)) newGroups.push_back(MulticastGroup(MAC(mac,6),0)); } } diff --git a/osdep/NeighborDiscovery.cpp b/osdep/NeighborDiscovery.cpp index 8f229642e..c09933d67 100644 --- a/osdep/NeighborDiscovery.cpp +++ b/osdep/NeighborDiscovery.cpp @@ -15,7 +15,8 @@ #include "NeighborDiscovery.hpp" #include "OSUtils.hpp" -#include +#include +#include namespace ZeroTier { @@ -175,8 +176,8 @@ void NeighborDiscovery::remove(const sockaddr_storage &address) sockaddr_storage NeighborDiscovery::processIncomingND(const uint8_t *nd, unsigned int len, const sockaddr_storage &localIp, uint8_t *response, unsigned int &responseLen, MAC &responseDest) { - assert(sizeof(_neighbor_solicitation) == 28); - assert(sizeof(_neighbor_advertisement) == 32); + // assert(sizeof(_neighbor_solicitation) == 28); + // assert(sizeof(_neighbor_advertisement) == 32); const uint64_t now = OSUtils::now(); sockaddr_storage ip = {0}; diff --git a/root/root.cpp b/root/root.cpp index d88e0c7b8..9ba7eddda 100644 --- a/root/root.cpp +++ b/root/root.cpp @@ -92,6 +92,7 @@ #include #include #include +#include #include #include #include