[PATCH] <autofs-5.1.9> do_reconnect: expiry check of dclist BEFORE lookup using it

Patrick Cernko <[email protected]> Sat, 28 Feb 2026 10:24:14 +0100
Newsgroups org.kernel.vger.autofs
Organization Gemeinsame Einrichtungen der MPIs KL und SB
Message-ID <[email protected]>
Hi autofs developers, hi Ian,

this patch changes the behavior when to refresh LDAP SRV records. The 
documentation states:

> The server list returned from an SRV RR lookup is refreshed according to the minimum ttl found in the SRV RR records or after one hour, whichever is less.

But the code in fact does not do any refreshing as long as at least one 
server in the dclist still responds.

This issue became obvious in our setup, when we had to disable the first 
two servers: autofs continued to contact ldap-a and ldap-b, running in 
timeouts (~5sec) and finally got an answer from ldap-c. But due to the 
timeouts every mount took >10sec resulting in slow responsiveness for 
the whole system. Changing the SRV records (with TTLs of 7200) did not 
help. As a workaround we had to signal all client's automount processes 
with HUP.

The change invalidates the dclist if expired. This forces autofs to do a 
new SRV record lookup before doing the LDAP lookup.

Best regards,
-- 
Patrick Cernko <[email protected]> +49 681 9325 5815
Joint Scientific IT and Technical Service
Max-Planck-Institute für Informatik & Softwaresysteme



 From a67f4898c7da327297edb45cda55a21f87b2246b Mon Sep 17 00:00:00 2001
From: Patrick Cernko <[email protected]>
Date: Thu, 2 Oct 2025 12:21:08 +0200
Subject: [PATCH 2/2] do_reconnect: expiry check of dclist BEFORE lookup 
using
  it

Signed-off-by: Patrick Cernko <[email protected]>
---
  modules/lookup_ldap.c | 18 ++++++++++--------
  1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 53416c6f..45a37543 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -1155,17 +1155,11 @@ static int do_reconnect(unsigned logopt,
  		return ret;
  	}

-	if (ctxt->dclist) {
-		dcrv = find_dc_server(logopt, conn, ctxt->dclist->uri, ctxt);
-		if (dcrv == NSS_STATUS_SUCCESS) {
-			ldapinit_mutex_unlock();
-			return dcrv;
-		}
-	}
-
  	uris_mutex_lock(ctxt);
  	if (ctxt->dclist) {
  		if (!conn->ldap || ctxt->dclist->expire < monotonic_time(NULL)) {
+                        debug(logopt, MODPREFIX
+                              "dclist expired, removing it to force new 
lookup");
  			free_dclist(ctxt->dclist);
  			ctxt->dclist = NULL;
  		}
@@ -1176,6 +1170,14 @@ static int do_reconnect(unsigned logopt,
  	}
  	uris_mutex_unlock(ctxt);

+	if (ctxt->dclist) {
+		dcrv = find_dc_server(logopt, conn, ctxt->dclist->uri, ctxt);
+		if (dcrv == NSS_STATUS_SUCCESS) {
+			ldapinit_mutex_unlock();
+			return dcrv;
+		}
+	}
+
  	if (!ctxt->uri)
  		goto find_server;

-- 
2.47.3
smime.p7s (application/pkcs7-signature, 4.8 KB) - not displayed