laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34245 )
Change subject: ns2: Add VTY option to change the max write queue size for UDP ......................................................................
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 --- M src/gb/gprs_ns2.c M src/gb/gprs_ns2_internal.h M src/gb/gprs_ns2_udp.c M src/gb/gprs_ns2_vty.c 4 files changed, 58 insertions(+), 0 deletions(-)
Approvals: laforge: Looks good to me, approved fixeria: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/src/gb/gprs_ns2.c b/src/gb/gprs_ns2.c index 02d2266..4e496c1 100644 --- a/src/gb/gprs_ns2.c +++ b/src/gb/gprs_ns2.c @@ -1451,6 +1451,8 @@ 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 37b142e..7ac77e5 100644 --- a/src/gb/gprs_ns2_internal.h +++ b/src/gb/gprs_ns2_internal.h @@ -80,6 +80,8 @@ #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 @@ /*! 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 @@ 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 f24eae6..1dcc303 100644 --- a/src/gb/gprs_ns2_udp.c +++ b/src/gb/gprs_ns2_udp.c @@ -336,6 +336,7 @@ 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 @@ 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 3046fff..3132e34 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 @@ 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 @@ 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 @@ 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);