host: fix peer routes on a node acting as gateway master
authorFelix Fietkau <nbd@nbd.name>
Wed, 23 Oct 2024 15:11:25 +0000 (17:11 +0200)
committerFelix Fietkau <nbd@nbd.name>
Wed, 23 Oct 2024 15:11:29 +0000 (17:11 +0200)
When acting as a gateway for a peer, add its addresses as allowed ips locally

Signed-off-by: Felix Fietkau <nbd@nbd.name>
host.h

diff --git a/host.h b/host.h
index 56d359c7e0580aa9df5243c6bc7ce29c97487416..536c24d80d095103a4a903971c11c594287eec4b 100644 (file)
--- 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;