From bbd3e0eb14191962b2a7197f2f5fa0bbddde9607 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 23 Oct 2024 17:11:25 +0200 Subject: [PATCH] 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 --- host.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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; -- 2.30.2