From a55253f43834ddb1de28c6e9b1d8d5b9a71552a9 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Thu, 14 Apr 2022 18:13:30 +0200 Subject: [PATCH] client: Add 'wqueue max-length <0-4294967295>' VTY command This allows setting a suitable write-queue max length per client. The desired value can be different based on a lot of variables, like memory availabilty, network and CPU load, input/output link state, etc. Related: SYS#5921 Change-Id: I4e9d5d836ddda215f9e7a075aa8e10d2d3854dd2 --- include/osmo-pcap/osmo_pcap_client.h | 2 ++ src/osmo_client_core.c | 2 +- src/osmo_client_vty.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/include/osmo-pcap/osmo_pcap_client.h b/include/osmo-pcap/osmo_pcap_client.h index 887d422..5bc203a 100644 --- a/include/osmo-pcap/osmo_pcap_client.h +++ b/include/osmo-pcap/osmo_pcap_client.h @@ -32,6 +32,8 @@ struct rate_ctr_group; +#define WQUEUE_MAXLEN_DEFAULT 1000 + enum { CLIENT_CTR_CONNECT, CLIENT_CTR_BYTES, diff --git a/src/osmo_client_core.c b/src/osmo_client_core.c index 8209afe..4bb4b4e 100644 --- a/src/osmo_client_core.c +++ b/src/osmo_client_core.c @@ -341,7 +341,7 @@ void osmo_client_conn_init(struct osmo_pcap_client_conn *conn, { conn->client = client; conn->tls_verify = true; - osmo_wqueue_init(&conn->wqueue, 1000); + osmo_wqueue_init(&conn->wqueue, WQUEUE_MAXLEN_DEFAULT); conn->wqueue.bfd.fd = -1; } diff --git a/src/osmo_client_vty.c b/src/osmo_client_vty.c index 7458f85..8e21d67 100644 --- a/src/osmo_client_vty.c +++ b/src/osmo_client_vty.c @@ -104,6 +104,10 @@ static void write_client_conn_data( if (conn->protocol != PROTOCOL_OSMOPCAP) vty_out(vty, "%s protocol %s%s", indent, get_value_string(osmopcap_protocol_names, conn->protocol), VTY_NEWLINE); + + if (conn->wqueue.max_length != WQUEUE_MAXLEN_DEFAULT) + vty_out(vty, "%s wqueue max-length %u%s", indent, + conn->wqueue.max_length, VTY_NEWLINE); } static int config_write_server(struct vty *vty) @@ -518,6 +522,18 @@ DEFUN(cfg_client_protocol, return CMD_SUCCESS; } +DEFUN(cfg_wqueue_maxlength, + cfg_wqueue_maxlength_cmd, + "wqueue max-length <1-4294967295>", + "Configure the write-queue used for transfer\n" + "Configure the maximum amount of packets to be stored in the write-queue\n" + "Maximum amount of packets before dropping starts\n") +{ + struct osmo_pcap_client_conn *conn = get_conn(vty); + + conn->wqueue.max_length = atoi(argv[0]); + return CMD_SUCCESS; +} int vty_client_init(void) { @@ -535,6 +551,7 @@ int vty_client_init(void) install_element(CLIENT_NODE, &cfg_server_port_cmd); install_element(CLIENT_NODE, &cfg_source_ip_cmd); install_element(CLIENT_NODE, &cfg_protocol_cmd); + install_element(CLIENT_NODE, &cfg_wqueue_maxlength_cmd); install_element(CLIENT_NODE, &cfg_enable_tls_cmd); install_element(CLIENT_NODE, &cfg_disable_tls_cmd);