From: Nick Porter Date: Thu, 17 Nov 2022 19:48:06 +0000 (+0000) Subject: Add max_outstanding option to limit number of processing ldap_sync packets X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=481e54cf73039d05790e0bf92bfc596d7201d040;p=thirdparty%2Ffreeradius-server.git Add max_outstanding option to limit number of processing ldap_sync packets --- diff --git a/raddb/sites-available/ldap_sync b/raddb/sites-available/ldap_sync index b32ef32fbe2..0d5ec357084 100644 --- a/raddb/sites-available/ldap_sync +++ b/raddb/sites-available/ldap_sync @@ -154,6 +154,14 @@ server ldap_sync { # How big the kernel's receive buffer should be. # # recv_buff = 1048576 + + # + # Maximum number of updates to have outstanding + # When this number is reached, no more are read, potentially + # causing the receive buffer to fill which will cause the + # change notifications to queue up on the LDAP server + # +# max_outstanding = 65536 } # diff --git a/src/listen/ldap_sync/proto_ldap_sync_ldap.c b/src/listen/ldap_sync/proto_ldap_sync_ldap.c index 811ae27f4f8..d20beaa7038 100644 --- a/src/listen/ldap_sync/proto_ldap_sync_ldap.c +++ b/src/listen/ldap_sync/proto_ldap_sync_ldap.c @@ -58,6 +58,7 @@ static CONF_PARSER const proto_ldap_sync_ldap_config[] = { * Network tunable parameters */ { FR_CONF_OFFSET_IS_SET("recv_buff", FR_TYPE_UINT32, proto_ldap_sync_ldap_t, recv_buff) }, + { FR_CONF_OFFSET("max_outstanding", FR_TYPE_UINT32, proto_ldap_sync_ldap_t, max_outstanding), .dflt = "65536" }, CONF_PARSER_TERMINATOR }; @@ -592,6 +593,13 @@ static ssize_t proto_ldap_child_mod_read(fr_listen_t *li, UNUSED void **packet_c fr_assert(conn); + /* + * If there are already too many outstanding requests just return. + * This will (potentially) cause the TCP buffer to fill and push the + * backpressure back to the LDAP server. + */ + if (fr_network_listen_outstanding(thread->nr, li) >= thread->inst->max_outstanding) return 0; + tree = talloc_get_type_abort(conn->uctx, fr_rb_tree_t); /* diff --git a/src/listen/ldap_sync/proto_ldap_sync_ldap.h b/src/listen/ldap_sync/proto_ldap_sync_ldap.h index 3f4090f045e..8a430d0208a 100644 --- a/src/listen/ldap_sync/proto_ldap_sync_ldap.h +++ b/src/listen/ldap_sync/proto_ldap_sync_ldap.h @@ -103,6 +103,8 @@ typedef struct { uint32_t recv_buff; //!< How big the kernel's recive buffer should be bool recv_buff_is_set; //!< Whether we were provided with a recv_buff + + uint32_t max_outstanding; //!< Maximun number of outstanding packets. } proto_ldap_sync_ldap_t; typedef struct {