pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-hlr/+/20577 )

Change subject: Set TCP NODELAY sockopt to GSUP cli and srv connections
......................................................................

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
---
M src/gsup_server.c
M src/gsupclient/gsup_client.c
2 files changed, 33 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  laforge: Looks good to me, but someone else must approve
  daniel: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



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 @@
        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 @@
        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 @@
        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 @@
        gsupc->is_connected = up;

        if (up) {
+               update_fd_settings(link->ofd->fd);
                start_test_procedure(gsupc);

                if (gsupc->oap_state.state == OSMO_OAP_INITIALIZED)

--
To view, visit https://gerrit.osmocom.org/c/osmo-hlr/+/20577
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-hlr
Gerrit-Branch: master
Gerrit-Change-Id: I4653b95ef0d4e1184f81f28408e9eb5d665206ec
Gerrit-Change-Number: 20577
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <[email protected]>
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: neels <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to