diff --git a/go/native/GoGlue.cpp b/go/native/GoGlue.cpp index 741141856..06ae19336 100644 --- a/go/native/GoGlue.cpp +++ b/go/native/GoGlue.cpp @@ -108,12 +108,12 @@ extern "C" int goPathLookupFunc(ZT_GoNode *,uint64_t,int,int *,uint8_t [16],int extern "C" void goStateObjectPutFunc(ZT_GoNode *,int,const uint64_t [2],const void *,int); extern "C" int goStateObjectGetFunc(ZT_GoNode *,int,const uint64_t [2],void *,unsigned int); extern "C" void goDNSResolverFunc(ZT_GoNode *,const uint8_t *,int,const char *,uintptr_t); -extern "C" int goVirtualNetworkConfigFunc(ZT_GoNode *,ZT_GoTap *,uint64_t,int,const ZT_VirtualNetworkConfig *); +extern "C" void goVirtualNetworkConfigFunc(ZT_GoNode *,ZT_GoTap *,uint64_t,int,const ZT_VirtualNetworkConfig *); extern "C" void goZtEvent(ZT_GoNode *,int,const void *); extern "C" void goHandleTapAddedMulticastGroup(ZT_GoNode *,ZT_GoTap *,uint64_t,uint64_t,uint32_t); extern "C" void goHandleTapRemovedMulticastGroup(ZT_GoNode *,ZT_GoTap *,uint64_t,uint64_t,uint32_t); -static int ZT_GoNode_VirtualNetworkConfigFunction( +static void ZT_GoNode_VirtualNetworkConfigFunction( ZT_Node *node, void *uptr, void *tptr, @@ -122,7 +122,7 @@ static int ZT_GoNode_VirtualNetworkConfigFunction( enum ZT_VirtualNetworkConfigOperation op, const ZT_VirtualNetworkConfig *cfg) { - return goVirtualNetworkConfigFunc(reinterpret_cast(uptr),reinterpret_cast(*nptr),nwid,op,cfg); + goVirtualNetworkConfigFunc(reinterpret_cast(uptr),reinterpret_cast(*nptr),nwid,op,cfg); } static void ZT_GoNode_VirtualNetworkFrameFunction( diff --git a/go/pkg/zerotier/network.go b/go/pkg/zerotier/network.go index c2c3cd566..132cf63d6 100644 --- a/go/pkg/zerotier/network.go +++ b/go/pkg/zerotier/network.go @@ -19,7 +19,6 @@ import ( "net" "strconv" "sync" - "time" ) // NetworkID is a network's 64-bit unique ID @@ -70,9 +69,6 @@ type NetworkConfig struct { // Status is a status code indicating this network's authorization status Status int - // LastUpdated is the time this network's configuration was last updated from the controller - LastUpdated time.Time - // Type is this network's type Type int @@ -80,34 +76,19 @@ type NetworkConfig struct { MTU int // CanBridge is true if this network is allowed to bridge in other devices with different Ethernet addresses - CanBridge bool + Bridge bool - // AllowsBroadcast is true if the broadcast (ff:ff:ff:ff:ff:ff) address works (excluding IPv4 ARP which is handled via a special path) - AllowsBroadcast bool + // BroadcastEnabled is true if the broadcast (ff:ff:ff:ff:ff:ff) address works (excluding IPv4 ARP which is handled via a special path) + BroadcastEnabled bool - // IPs are static IPs assigned by the network controller to this device - IPs []net.IPNet + // Network configuration revision number according to network controller + NetconfRevision uint64 + + // AssignedAddresses are static IPs assigned by the network controller to this device + AssignedAddresses []net.IPNet // Routes are static routes assigned by the network controller to this device Routes []Route - - // MulticastSubscriptions are this device's current multicast subscriptions - MulticastSubscriptions []MulticastGroup - - // Enabled is true if this network's tap device is enabled - Enabled bool - - // TapDeviceType is a human-readable description of this network's tap device type - TapDeviceType string - - // TapDevicePort is the OS-specific virtual device name (if applicable) - TapDevicePort string - - // TapErrorCode is an implementation-specific error code from the tap device (0 for no error) - TapErrorCode int - - // TapError is a human-readable description of this tap device's error state or an empty string if there is no error - TapError string } // Network is a currently joined network @@ -125,11 +106,7 @@ func (n *Network) ID() NetworkID { return n.id } // Config returns a copy of this network's current configuration func (n *Network) Config() NetworkConfig { n.configLock.RLock() - n.tapLock.RLock() - defer n.tapLock.RUnlock() defer n.configLock.RUnlock() - n.config.Enabled = n.tap.Enabled() - n.config.TapErrorCode, n.config.TapError = n.tap.Error() return n.config } diff --git a/go/pkg/zerotier/node.go b/go/pkg/zerotier/node.go index 449df4a3b..febbbaa0c 100644 --- a/go/pkg/zerotier/node.go +++ b/go/pkg/zerotier/node.go @@ -348,7 +348,7 @@ func goDNSResolverFunc(gn unsafe.Pointer, dnsRecordTypes unsafe.Pointer, numDNSR } //export goVirtualNetworkConfigFunc -func goVirtualNetworkConfigFunc(gn, tapP unsafe.Pointer, nwid C.uint64_t, op C.int, conf unsafe.Pointer) C.int { +func goVirtualNetworkConfigFunc(gn, tapP unsafe.Pointer, nwid C.uint64_t, op C.int, conf unsafe.Pointer) { nodesByUserPtrLock.RLock() node := nodesByUserPtr[uintptr(gn)] nodesByUserPtrLock.RUnlock() diff --git a/include/ZeroTierCore.h b/include/ZeroTierCore.h index 2c51f4f0e..b92424779 100644 --- a/include/ZeroTierCore.h +++ b/include/ZeroTierCore.h @@ -687,17 +687,7 @@ enum ZT_VirtualNetworkStatus /** * Netconf master exists, but this virtual network does not */ - ZT_NETWORK_STATUS_NOT_FOUND = 3, - - /** - * Initialization of network failed or other internal error - */ - ZT_NETWORK_STATUS_PORT_ERROR = 4, - - /** - * ZeroTier core version too old - */ - ZT_NETWORK_STATUS_CLIENT_TOO_OLD = 5 + ZT_NETWORK_STATUS_NOT_FOUND = 3 }; /** @@ -1098,15 +1088,6 @@ typedef struct */ unsigned int mtu; - /** - * If nonzero, the network this port belongs to indicates DHCP availability - * - * This is a suggestion. The underlying implementation is free to ignore it - * for security or other reasons. This is simply a netconf parameter that - * means 'DHCP is available on this network.' - */ - int dhcp; - /** * If nonzero, this port is allowed to bridge to other networks * @@ -1120,11 +1101,6 @@ typedef struct */ int broadcastEnabled; - /** - * If the network is in PORT_ERROR state, this is the (negative) error code most recently reported - */ - int portError; - /** * Revision number as reported by controller or 0 if still waiting for config */ @@ -1409,12 +1385,8 @@ typedef void ZT_Node; * This should not call multicastSubscribe() or other network-modifying * methods, as this could cause a deadlock in multithreaded or interrupt * driven environments. - * - * This must return 0 on success. It can return any OS-dependent error code - * on failure, and this results in the network being placed into the - * PORT_ERROR state. */ -typedef int (*ZT_VirtualNetworkConfigFunction)( +typedef void (*ZT_VirtualNetworkConfigFunction)( ZT_Node *, /* Node */ void *, /* User ptr */ void *, /* Thread ptr */ diff --git a/node/Network.cpp b/node/Network.cpp index ed30f963c..8e3732833 100644 --- a/node/Network.cpp +++ b/node/Network.cpp @@ -548,8 +548,7 @@ Network::Network(const RuntimeEnvironment *renv,void *tPtr,uint64_t nwid,void *u _portInitialized(false), _lastConfigUpdate(0), _destroyed(false), - _netconfFailure(NETCONF_FAILURE_NONE), - _portError(0) + _netconfFailure(NETCONF_FAILURE_NONE) { for(int i=0;inode->configureVirtualNetworkPort(tPtr,_id,&_uPtr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp); + RR->node->configureVirtualNetworkPort(tPtr,_id,&_uPtr,ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp); _portInitialized = true; } } @@ -991,7 +990,7 @@ int Network::setConfiguration(void *tPtr,const NetworkConfig &nconf,bool saveToD _externalConfig(&ctmp); } - _portError = RR->node->configureVirtualNetworkPort(tPtr,_id,&_uPtr,(oldPortInitialized) ? ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE : ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp); + RR->node->configureVirtualNetworkPort(tPtr,_id,&_uPtr,(oldPortInitialized) ? ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_CONFIG_UPDATE : ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_UP,&ctmp); if (saveToDisk) { try { @@ -1311,8 +1310,6 @@ void Network::_requestConfiguration(void *tPtr) ZT_VirtualNetworkStatus Network::_status() const { - if (_portError) - return ZT_NETWORK_STATUS_PORT_ERROR; switch(_netconfFailure) { case NETCONF_FAILURE_ACCESS_DENIED: return ZT_NETWORK_STATUS_ACCESS_DENIED; @@ -1321,7 +1318,7 @@ ZT_VirtualNetworkStatus Network::_status() const case NETCONF_FAILURE_NONE: return ((_config) ? ZT_NETWORK_STATUS_OK : ZT_NETWORK_STATUS_REQUESTING_CONFIGURATION); default: - return ZT_NETWORK_STATUS_PORT_ERROR; + return ZT_NETWORK_STATUS_REQUESTING_CONFIGURATION; } } @@ -1336,7 +1333,6 @@ void Network::_externalConfig(ZT_VirtualNetworkConfig *ec) const ec->status = _status(); ec->type = (_config) ? (_config.isPrivate() ? ZT_NETWORK_TYPE_PRIVATE : ZT_NETWORK_TYPE_PUBLIC) : ZT_NETWORK_TYPE_PRIVATE; ec->mtu = (_config) ? _config.mtu : ZT_DEFAULT_MTU; - ec->dhcp = 0; std::vector
ab; for(unsigned int i=0;i<_config.specialistCount;++i) { if ((_config.specialists[i] & ZT_NETWORKCONFIG_SPECIALIST_TYPE_ACTIVE_BRIDGE) != 0) @@ -1344,7 +1340,6 @@ void Network::_externalConfig(ZT_VirtualNetworkConfig *ec) const } ec->bridge = (std::find(ab.begin(),ab.end(),RR->identity.address()) != ab.end()) ? 1 : 0; ec->broadcastEnabled = (_config) ? (_config.enableBroadcast() ? 1 : 0) : 0; - ec->portError = _portError; ec->netconfRevision = (_config) ? (unsigned long)_config.revision : 0; ec->assignedAddressCount = 0; diff --git a/node/Network.hpp b/node/Network.hpp index c352c2b21..7e0fb362e 100644 --- a/node/Network.hpp +++ b/node/Network.hpp @@ -459,7 +459,6 @@ private: NETCONF_FAILURE_NOT_FOUND, NETCONF_FAILURE_INIT_FAILED } _netconfFailure; - int _portError; // return value from port config callback Hashtable _memberships; diff --git a/node/Node.hpp b/node/Node.hpp index fdfcb6201..3302fa903 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -176,7 +176,7 @@ public: } ZT_ALWAYS_INLINE void postEvent(void *tPtr,ZT_Event ev,const void *md = (const void *)0) { _cb.eventCallback(reinterpret_cast(this),_uPtr,tPtr,ev,md); } - ZT_ALWAYS_INLINE int configureVirtualNetworkPort(void *tPtr,uint64_t nwid,void **nuptr,ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nc) { return _cb.virtualNetworkConfigFunction(reinterpret_cast(this),_uPtr,tPtr,nwid,nuptr,op,nc); } + ZT_ALWAYS_INLINE void configureVirtualNetworkPort(void *tPtr,uint64_t nwid,void **nuptr,ZT_VirtualNetworkConfigOperation op,const ZT_VirtualNetworkConfig *nc) { _cb.virtualNetworkConfigFunction(reinterpret_cast(this),_uPtr,tPtr,nwid,nuptr,op,nc); } ZT_ALWAYS_INLINE bool online() const { return _online; } ZT_ALWAYS_INLINE int stateObjectGet(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2],void *const data,const unsigned int maxlen) { return _cb.stateGetFunction(reinterpret_cast(this),_uPtr,tPtr,type,id,data,maxlen); } ZT_ALWAYS_INLINE void stateObjectPut(void *const tPtr,ZT_StateObjectType type,const uint64_t id[2],const void *const data,const unsigned int len) { _cb.statePutFunction(reinterpret_cast(this),_uPtr,tPtr,type,id,data,(int)len); }