]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add recv_buff option to proto_ldap_sync
authorNick Porter <nick@portercomputing.co.uk>
Wed, 16 Nov 2022 09:04:18 +0000 (09:04 +0000)
committerNick Porter <nick@portercomputing.co.uk>
Thu, 17 Nov 2022 08:36:56 +0000 (08:36 +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 8e8b874e9407b4653e94409580659266f22ef9fd..b32ef32fbe28ac19afeb5b1025fcdb399bb6e57a 100644 (file)
@@ -149,6 +149,11 @@ server ldap_sync {
                                #  SASL realm. Used for kerberos.
 #                              realm = 'example.org'
                        }
+
+                       #
+                       #  How big the kernel's receive buffer should be.
+                       #
+#                      recv_buff = 1048576
                }
 
                #
index 522224e097e116b7cabecd4a3e78cff29bd03912..b45c5df993243e7bb68fae9e4ceb8839c6163c69 100644 (file)
@@ -54,6 +54,11 @@ static CONF_PARSER const proto_ldap_sync_ldap_config[] = {
         */
        FR_LDAP_COMMON_CONF(proto_ldap_sync_ldap_t),
 
+       /*
+        *      Network tunable parameters
+        */
+       { FR_CONF_OFFSET_IS_SET("recv_buff", FR_TYPE_UINT32, proto_ldap_sync_ldap_t, recv_buff) },
+
        CONF_PARSER_TERMINATOR
 };
 
@@ -1050,6 +1055,17 @@ static void _proto_ldap_socket_open_connected(fr_connection_t *conn, UNUSED fr_c
        dir_ctx->conn = conn;
        dir_ctx->child_listen = thread->li;
 
+#ifdef SO_RCVBUF
+       if (inst->recv_buff_is_set) {
+               int opt;
+
+               opt = inst->recv_buff;
+               if (setsockopt(ldap_conn->fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(int)) < 0) {
+                       WARN("Failed setting 'recv_buff': %s", fr_syserror(errno));
+               }
+       }
+#endif
+
        /*
         *      Set the callback which will handle the results of this query
         */
@@ -1147,6 +1163,11 @@ static int mod_bootstrap(module_inst_ctx_t const *mctx)
        inst->parent = talloc_get_type_abort(dl_inst->parent->data, proto_ldap_sync_t);
        inst->cs = conf;
 
+       if (inst->recv_buff_is_set) {
+               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
+               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
+       }
+
        return 0;
 }
 
index 66ea38213d15e07ca89376ca40eca947cec69398..7ed77e5e283b81381dcf41e56b8dcffcd30932f0 100644 (file)
@@ -99,6 +99,9 @@ typedef struct {
                                                                //!< and /dev/urandom are unavailable.
 
        uint32_t                        ldap_debug;             //!< Debug flag for the SDK.
+
+       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
 } proto_ldap_sync_ldap_t;
 
 typedef struct {