[Openvpn-devel,v2] resolve: store the address family in --preresolve cache entries

Message ID 20261126115908.7374-1-gert@greenie.muc.de
State New
Headers
Series [Openvpn-devel,v2] resolve: store the address family in --preresolve cache entries |

Commit Message

Gert Doering Nov. 26, 2026, 11:59 a.m. UTC
  From: Razvan Cojocaru <razvanc@mailbox.org>

get_cached_dns_entry() matches on ai_family, which do_preresolve_host()
never set. Any lookup with an explicit family missed the cache, so each
restart resolved again and appended duplicate cache entries.

Configs with an explicit address family now reuse the preresolved
addresses across reconnects, as documented, instead of resolving again
each time.

Change-Id: Iae65693f49f43a66bf6f58bbefa7c33618ebc4a7
Signed-off-by: Razvan Cojocaru <razvanc@mailbox.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2181
---

This change was reviewed on Gerrit and approved by at least one
developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2181
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Lev Stipakov <lstipakov@gmail.com>
  

Patch

diff --git a/src/openvpn/resolve.c b/src/openvpn/resolve.c
index 46a7f7b..d1b132f 100644
--- a/src/openvpn/resolve.c
+++ b/src/openvpn/resolve.c
@@ -561,6 +561,7 @@ 
         ph->ai = ai;
         ph->hostname = hostname;
         ph->servname = servname;
+        ph->ai_family = af;
         ph->flags = flags & GETADDR_CACHE_MASK;
 
         if (!c->c1.dns_cache)