From: Felix Fietkau Date: Wed, 23 Oct 2024 15:11:25 +0000 (+0200) Subject: host: fix peer routes on a node acting as gateway X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;p=project%2Funetd.git 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 --- 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;