Skip to content

Commit

Permalink
Linux build fixes, and new route code seems to work.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamierymenko committed Nov 14, 2020
1 parent 5ea7ef6 commit 4aab912
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
12 changes: 6 additions & 6 deletions osdep/LinuxNetLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "../node/Constants.hpp"

#define ZT_NETLINK_TRACE
//#define ZT_NETLINK_TRACE

#ifdef __LINUX__

Expand Down Expand Up @@ -357,7 +357,7 @@ void LinuxNetLink::_routeAdded(struct nlmsghdr *nlp)

if (wecare) {
Mutex::Lock rl(_routes_m);
_routes[target].insert(r);
_routes[r.target].insert(r);
}

#ifdef ZT_NETLINK_TRACE
Expand Down Expand Up @@ -445,7 +445,7 @@ void LinuxNetLink::_routeDeleted(struct nlmsghdr *nlp)

if (wecare) {
Mutex::Lock rl(_routes_m);
_routes[target].erase(r);
_routes[r.target].erase(r);
}

#ifdef ZT_NETLINK_TRACE
Expand Down Expand Up @@ -1145,12 +1145,12 @@ void LinuxNetLink::removeAddress(const InetAddress &addr, const char *iface)
bool LinuxNetLink::routeIsSet(const InetAddress &target, const InetAddress &via, const InetAddress &src, const char *ifname)
{
Mutex::Lock rl(_routes_m);
const std::set<Route> &rs = _routes[target];
for(std::set<Route>::const_iterator ri(rs.begin());ri!=rs.end();++ri) {
const std::set<LinuxNetLink::Route> &rs = _routes[target];
for(std::set<LinuxNetLink::Route>::const_iterator ri(rs.begin());ri!=rs.end();++ri) {
if ((ri->via == via)&&(ri->src == src)) {
if (ifname) {
Mutex::Lock ifl(_if_m);
const iface_entry *ife = _interfaces.get(rs->ifidx);
const iface_entry *ife = _interfaces.get(ri->ifidx);
if ((ife)&&(!strncmp(ife->ifacename,ifname,IFNAMSIZ)))
return true;
} else {
Expand Down
4 changes: 3 additions & 1 deletion osdep/LinuxNetLink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#ifdef __LINUX__

#include <vector>
#include <map>
#include <set>

#include <sys/socket.h>
#include <asm/types.h>
Expand Down Expand Up @@ -123,7 +125,7 @@ class LinuxNetLink

uint32_t _seq;

std::map< InetAddress,std::set<Route> > _routes;
std::map< InetAddress,std::set<LinuxNetLink::Route> > _routes;
Mutex _routes_m;

struct iface_entry {
Expand Down
2 changes: 1 addition & 1 deletion osdep/ManagedRoute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ bool ManagedRoute::sync()
#ifdef __LINUX__ // ----------------------------------------------------------

const char *const devptr = (_via) ? (const char *)0 : _device;
if (!LinuxNetLink::getInstance().routeIsSet(leftt,_via,_src,devptr)) {
if ((leftt)&&(!LinuxNetLink::getInstance().routeIsSet(leftt,_via,_src,devptr))) {
_applied[leftt] = false; // boolean unused
LinuxNetLink::getInstance().addRoute(leftt, _via, _src, devptr);
}
Expand Down

0 comments on commit 4aab912

Please sign in to comment.