diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2023-08-29 16:24:56 +0200 |
---|---|---|
committer | laforge <laforge@osmocom.org> | 2023-08-30 09:18:35 +0000 |
commit | 3236fdffd6c1c94c350d6f7b99806a6ede12e5ce (patch) | |
tree | 922ebcd8bcec421177151d146e319702aba215e8 /src | |
parent | 8c0a2c72b0867dc72d6a8edb87a77be351f0361d (diff) |
ns2: Add VTY option to change the max write queue size for UDP
Ensure that existing binds are updated as well.
In some cases the default max length of the osmo_io txqueue could be too
small. Set it to 128 by default and add a VTY option to change it for
an NSI (program-wide).
Change-Id: I993b87fd6b83b3981f5e293f70b931075afec715
Related: SYS#6550
Diffstat (limited to 'src')
-rw-r--r-- | src/gb/gprs_ns2.c | 2 | ||||
-rw-r--r-- | src/gb/gprs_ns2_internal.h | 5 | ||||
-rw-r--r-- | src/gb/gprs_ns2_udp.c | 9 | ||||
-rw-r--r-- | src/gb/gprs_ns2_vty.c | 27 |
4 files changed, 43 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c index 02d2266a..4e496c1f 100644 --- a/src/gb/gprs_ns2.c +++ b/src/gb/gprs_ns2.c @@ -1451,6 +1451,8 @@ struct gprs_ns2_inst *gprs_ns2_instantiate(void *ctx, osmo_prim_cb cb, void *cb_ nsi->timeout[NS_TOUT_TSNS_CONFIG_RETRIES] = 3; nsi->timeout[NS_TOUT_TSNS_PROCEDURES_RETRIES] = 3; + nsi->txqueue_max_length = NS_DEFAULT_TXQUEUE_MAX_LENGTH; + return nsi; } diff --git a/src/gb/gprs_ns2_internal.h b/src/gb/gprs_ns2_internal.h index 37b142e3..7ac77e56 100644 --- a/src/gb/gprs_ns2_internal.h +++ b/src/gb/gprs_ns2_internal.h @@ -80,6 +80,8 @@ struct gprs_ns2_vc_bind; #define NS_ALLOC_SIZE 3072 #define NS_ALLOC_HEADROOM 20 +#define NS_DEFAULT_TXQUEUE_MAX_LENGTH 128 + enum ns2_timeout { NS_TOUT_TNS_BLOCK, NS_TOUT_TNS_BLOCK_RETRIES, @@ -164,6 +166,8 @@ struct gprs_ns2_inst { /*! workaround for rate counter until rate counter accepts char str as index */ uint32_t nsvc_rate_ctr_idx; uint32_t bind_rate_ctr_idx; + + uint32_t txqueue_max_length; }; @@ -450,6 +454,7 @@ int ns2_ip_count_bind(struct gprs_ns2_inst *nsi, struct osmo_sockaddr *remote); struct gprs_ns2_vc_bind *ns2_ip_get_bind_by_index(struct gprs_ns2_inst *nsi, struct osmo_sockaddr *remote, int index); +void ns2_ip_set_txqueue_max_length(struct gprs_ns2_vc_bind *bind, unsigned int max_length); /* sns */ int ns2_sns_rx(struct gprs_ns2_vc *nsvc, struct msgb *msg, struct tlv_parsed *tp); diff --git a/src/gb/gprs_ns2_udp.c b/src/gb/gprs_ns2_udp.c index f24eae68..1dcc3030 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -336,6 +336,7 @@ int gprs_ns2_ip_bind(struct gprs_ns2_inst *nsi, priv->iofd = osmo_iofd_setup(bind, rc, "NS bind", OSMO_IO_FD_MODE_RECVFROM_SENDTO, &ioops, bind); osmo_iofd_register(priv->iofd, rc); osmo_iofd_set_alloc_info(priv->iofd, 4096, 128); + osmo_iofd_set_txqueue_max_length(priv->iofd, nsi->txqueue_max_length); /* IPv4: max fragmented payload can be (13 bit) * 8 byte => 65535. * IPv6: max payload can be 65535 (RFC 2460). @@ -574,6 +575,14 @@ struct gprs_ns2_vc_bind *ns2_ip_get_bind_by_index(struct gprs_ns2_inst *nsi, return NULL; } +void ns2_ip_set_txqueue_max_length(struct gprs_ns2_vc_bind *bind, unsigned int max_length) +{ + struct priv_bind *priv = bind->priv; + OSMO_ASSERT(gprs_ns2_is_ip_bind(bind)); + + osmo_iofd_set_txqueue_max_length(priv->iofd, max_length); +} + /*! set the signalling and data weight for this bind * \param[in] bind * \param[in] signalling the signalling weight diff --git a/src/gb/gprs_ns2_vty.c b/src/gb/gprs_ns2_vty.c index 3046fffd..3132e347 100644 --- a/src/gb/gprs_ns2_vty.c +++ b/src/gb/gprs_ns2_vty.c @@ -36,6 +36,7 @@ #include <osmocom/core/fsm.h> #include <osmocom/core/linuxlist.h> #include <osmocom/core/msgb.h> +#include <osmocom/core/osmo_io.h> #include <osmocom/core/rate_ctr.h> #include <osmocom/core/select.h> #include <osmocom/core/talloc.h> @@ -595,6 +596,9 @@ static int config_write_ns(struct vty *vty) get_value_string(gprs_ns_timer_strs, i), vty_nsi->timeout[i], VTY_NEWLINE); + if (vty_nsi->txqueue_max_length != NS_DEFAULT_TXQUEUE_MAX_LENGTH) + vty_out(vty, " txqueue-max-length %u%s", vty_nsi->txqueue_max_length, VTY_NEWLINE); + ret = config_write_ns_bind(vty); if (ret) return ret; @@ -1707,6 +1711,27 @@ DEFUN(cfg_no_ns_ip_sns_default_bind, cfg_no_ns_ip_sns_default_bind_cmd, return CMD_WARNING; } +DEFUN(cfg_ns_txqueue_max_length, cfg_ns_txqueue_max_length_cmd, + "txqueue-max-length <1-4096>", + "Set the maximum length of the txqueue (for UDP)\n" + "Maximum length of the txqueue\n") +{ + struct gprs_ns2_vc_bind *bind; + uint32_t max_length = atoi(argv[0]); + vty_nsi->txqueue_max_length = max_length; + + + llist_for_each_entry(bind, &vty_nsi->binding, list) { + if (!gprs_ns2_is_ip_bind(bind)) + continue; + + ns2_ip_set_txqueue_max_length(bind, max_length); + } + + + return CMD_SUCCESS; +} + DEFUN(cfg_ns_nse_ip_sns_bind, cfg_ns_nse_ip_sns_bind_cmd, "ip-sns-bind BINDID", "IP SNS binds\n" @@ -2292,6 +2317,8 @@ int gprs_ns2_vty_init(struct gprs_ns2_inst *nsi) install_lib_element(L_NS_NODE, &cfg_ns_ip_sns_default_bind_cmd); install_lib_element(L_NS_NODE, &cfg_no_ns_ip_sns_default_bind_cmd); + install_lib_element(L_NS_NODE, &cfg_ns_txqueue_max_length_cmd); + install_node(&ns_bind_node, NULL); install_lib_element(L_NS_BIND_NODE, &cfg_ns_bind_listen_cmd); install_lib_element(L_NS_BIND_NODE, &cfg_no_ns_bind_listen_cmd); |