diff options
author | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-10-12 16:39:38 +0200 |
---|---|---|
committer | Pau Espin Pedrol <pespin@sysmocom.de> | 2020-10-12 16:39:58 +0200 |
commit | 23ac586522c3f6e4abc89dd29ea449d6f2445abc (patch) | |
tree | cfa1b4b9912fb818f463f4a64ae37e784cf5b622 | |
parent | de50b201167b717e69053c57c42ea26c35cfe5db (diff) |
Set TCP NODELAY sockopt to GSUP cli and srv connections
GSUP is message based on top of IPA, and hence TCP. We don't want to
have Nagle algorithm enabled, since we are interested in having messages
sent as quickly as possible and there's no need for lower layers to wait
for more data (because we send all the message data at once).
Related: OS#4499
Change-Id: I4653b95ef0d4e1184f81f28408e9eb5d665206ec
-rw-r--r-- | src/gsup_server.c | 17 | ||||
-rw-r--r-- | src/gsupclient/gsup_client.c | 16 |
2 files changed, 33 insertions, 0 deletions
diff --git a/src/gsup_server.c b/src/gsup_server.c index 830a5a7..756473a 100644 --- a/src/gsup_server.c +++ b/src/gsup_server.c @@ -18,6 +18,8 @@ */ #include <errno.h> +#include <netinet/tcp.h> +#include <netinet/in.h> #include <osmocom/core/msgb.h> #include <osmocom/core/logging.h> @@ -352,6 +354,19 @@ void osmo_gsup_server_add_conn(struct llist_head *clients, llist_add(&conn->list, &prev_conn->list); } +static void update_fd_settings(int fd) +{ + int ret; + int val; + + /*TODO: Set keepalive settings here. See OS#4312 */ + + val = 1; + ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); + if (ret < 0) + LOGP(DLGSUP, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); +} + /* a client has connected to the server socket and we have accept()ed it */ static int osmo_gsup_server_accept_cb(struct ipa_server_link *link, int fd) { @@ -376,6 +391,8 @@ static int osmo_gsup_server_accept_cb(struct ipa_server_link *link, int fd) LOGP(DLGSUP, LOGL_INFO, "New GSUP client %s:%d (IND=%u)\n", conn->conn->addr, conn->conn->port, conn->auc_3g_ind); + update_fd_settings(fd); + /* request the identity of the client */ rc = ipa_ccm_send_id_req(fd); if (rc < 0) diff --git a/src/gsupclient/gsup_client.c b/src/gsupclient/gsup_client.c index 4f76efc..4041366 100644 --- a/src/gsupclient/gsup_client.c +++ b/src/gsupclient/gsup_client.c @@ -31,6 +31,8 @@ #include <errno.h> #include <string.h> +#include <netinet/tcp.h> +#include <netinet/in.h> static void start_test_procedure(struct osmo_gsup_client *gsupc); @@ -129,6 +131,19 @@ static void gsup_client_oap_register(struct osmo_gsup_client *gsupc) client_send(gsupc, IPAC_PROTO_EXT_OAP, msg_tx); } +static void update_fd_settings(int fd) +{ + int ret; + int val; + + /*TODO: Set keepalive settings here. See OS#4312 */ + + val = 1; + ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); + if (ret < 0) + LOGP(DLGSUP, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n", strerror(errno)); +} + static void gsup_client_updown_cb(struct ipa_client_conn *link, int up) { struct osmo_gsup_client *gsupc = link->data; @@ -139,6 +154,7 @@ static void gsup_client_updown_cb(struct ipa_client_conn *link, int up) gsupc->is_connected = up; if (up) { + update_fd_settings(link->ofd->fd); start_test_procedure(gsupc); if (gsupc->oap_state.state == OSMO_OAP_INITIALIZED) |