summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2024-10-23 15:11:25 +0000
committerFelix Fietkau2024-10-23 15:11:29 +0000
commitbbd3e0eb14191962b2a7197f2f5fa0bbddde9607 (patch)
tree12999a772eb37308727b2519375eb443582e4440
parentd22d7db581d5fd9648d59ede4c8e4005eb977568 (diff)
host: fix peer routes on a node acting as gateway
When acting as a gateway for a peer, add its addresses as allowed ips locally Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--host.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/host.h b/host.h
index 56d359c..536c24d 100644
--- a/host.h
+++ b/host.h
@@ -98,13 +98,19 @@ static inline bool
network_host_uses_peer_route(struct network_host *host, struct network *net,
struct network_peer *peer)
{
- if (&host->peer == peer || host == net->net_config.local_host)
+ struct network_host *peer_host = container_of(peer, struct network_host, peer);
+
+ if (host == peer_host || host == net->net_config.local_host)
return false;
if (net->net_config.local_host->gateway &&
!strcmp(net->net_config.local_host->gateway, network_peer_name(peer)))
return true;
+ if (peer_host->gateway &&
+ !strcmp(peer_host->gateway, network_host_name(net->net_config.local_host)))
+ return true;
+
if (!host->gateway)
return false;