From: Nick Porter Date: Wed, 16 Nov 2022 09:04:18 +0000 (+0000) Subject: Add recv_buff option to proto_ldap_sync X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43ec6d7d3fa542893d61499e327a4ca87400a6d9;p=thirdparty%2Ffreeradius-server.git Add recv_buff option to proto_ldap_sync --- diff --git a/raddb/sites-available/ldap_sync b/raddb/sites-available/ldap_sync index 8e8b874e940..b32ef32fbe2 100644 --- a/raddb/sites-available/ldap_sync +++ b/raddb/sites-available/ldap_sync @@ -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 } # diff --git a/src/listen/ldap_sync/proto_ldap_sync_ldap.c b/src/listen/ldap_sync/proto_ldap_sync_ldap.c index 522224e097e..b45c5df9932 100644 --- a/src/listen/ldap_sync/proto_ldap_sync_ldap.c +++ b/src/listen/ldap_sync/proto_ldap_sync_ldap.c @@ -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; } diff --git a/src/listen/ldap_sync/proto_ldap_sync_ldap.h b/src/listen/ldap_sync/proto_ldap_sync_ldap.h index 66ea38213d1..7ed77e5e283 100644 --- a/src/listen/ldap_sync/proto_ldap_sync_ldap.h +++ b/src/listen/ldap_sync/proto_ldap_sync_ldap.h @@ -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 {