]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add max_outstanding option to limit number of processing ldap_sync packets
authorNick Porter <nick@portercomputing.co.uk>
Thu, 17 Nov 2022 19:48:06 +0000 (19:48 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 24 Nov 2022 17:43:15 +0000 (17:43 +0000)
raddb/sites-available/ldap_sync
src/listen/ldap_sync/proto_ldap_sync_ldap.c
src/listen/ldap_sync/proto_ldap_sync_ldap.h

index b32ef32fbe28ac19afeb5b1025fcdb399bb6e57a..0d5ec35708467a04789cbf14d99e274243248e5d 100644 (file)
@@ -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
                }
 
                #
index 811ae27f4f86d7a1fb8440e2635fa9118356f1a4..d20beaa703891e047d6dbcc308edfa7a01818a68 100644 (file)
@@ -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);
 
        /*
index 3f4090f045eb6aff816ddb6010fc4d3b0efe9398..8a430d0208a82cca3cfa581d963aec6caf40b338 100644 (file)
@@ -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 {