pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-abis/+/40536?usp=email )
Change subject: ipaccess: No need to apply TCP_NODELAY manually
......................................................................
ipaccess: No need to apply TCP_NODELAY manually
This is already done by osmo_stream_srv_link_set_nodelay() and
osmo_stream_cli_set_nodelay() APIs during stream creation.
Related: OS#6637
Change-Id: Ic6cb1457998ad0c131859be04e86cc7935217361
---
M src/input/ipaccess.c
1 file changed, 37 insertions(+), 41 deletions(-)
Approvals:
laforge: Looks good to me, but someone else must approve
pespin: Looks good to me, approved
Jenkins Builder: Verified
osmith: Looks good to me, but someone else must approve
diff --git a/src/input/ipaccess.c b/src/input/ipaccess.c
index 44ec719..10dec22 100644
--- a/src/input/ipaccess.c
+++ b/src/input/ipaccess.c
@@ -624,50 +624,46 @@
int ret;
int val, idle_val, interval_val, retry_count_val, user_timeout_val;
- if (line->keepalive_num_probes) {
- /* Enable TCP keepalive to find out if the connection is gone */
- val = 1;
- ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
- if (ret < 0)
- LOGPIL(line, DLINP, LOGL_ERROR, "Failed to enable TCP keepalive: %s\n",
strerror(errno));
- else
- LOGPIL(line, DLINP, LOGL_NOTICE, "TCP Keepalive is enabled\n");
+ if (line->keepalive_num_probes == 0)
+ return;
- idle_val = line->keepalive_idle_timeout > 0 ?
- line->keepalive_idle_timeout :
- DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT;
- interval_val = line->keepalive_probe_interval > -1 ?
- line->keepalive_probe_interval :
- DEFAULT_TCP_KEEPALIVE_INTERVAL;
- retry_count_val = line->keepalive_num_probes > 0 ?
- line->keepalive_num_probes :
- DEFAULT_TCP_KEEPALIVE_RETRY_COUNT;
- user_timeout_val = 1000 * retry_count_val * (interval_val + idle_val);
- LOGPIL(line, DLINP, LOGL_NOTICE, "TCP keepalive idle_timeout=%us, interval=%us,
retry_count=%u "
- "user_timeout=%ums\n", idle_val, interval_val, retry_count_val,
user_timeout_val);
- /* The following options are not portable! */
- ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle_val, sizeof(idle_val));
- if (ret < 0) {
- LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP keepalive idle time:
%s\n",
- strerror(errno));
- }
- ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval_val,
sizeof(interval_val));
- if (ret < 0) {
- LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP keepalive interval:
%s\n",
- strerror(errno));
- }
- ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &retry_count_val,
sizeof(retry_count_val));
- if (ret < 0)
- LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP keepalive count: %s\n",
strerror(errno));
- ret = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &user_timeout_val,
sizeof(user_timeout_val));
- if (ret < 0)
- LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP user timeout: %s\n",
strerror(errno));
- }
-
+ /* Enable TCP keepalive to find out if the connection is gone */
val = 1;
- ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
+ ret = setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
if (ret < 0)
- LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP_NODELAY: %s\n",
strerror(errno));
+ LOGPIL(line, DLINP, LOGL_ERROR, "Failed to enable TCP keepalive: %s\n",
strerror(errno));
+ else
+ LOGPIL(line, DLINP, LOGL_NOTICE, "TCP Keepalive is enabled\n");
+
+ idle_val = line->keepalive_idle_timeout > 0 ?
+ line->keepalive_idle_timeout :
+ DEFAULT_TCP_KEEPALIVE_IDLE_TIMEOUT;
+ interval_val = line->keepalive_probe_interval > -1 ?
+ line->keepalive_probe_interval :
+ DEFAULT_TCP_KEEPALIVE_INTERVAL;
+ retry_count_val = line->keepalive_num_probes > 0 ?
+ line->keepalive_num_probes :
+ DEFAULT_TCP_KEEPALIVE_RETRY_COUNT;
+ user_timeout_val = 1000 * retry_count_val * (interval_val + idle_val);
+ LOGPIL(line, DLINP, LOGL_NOTICE, "TCP keepalive idle_timeout=%us, interval=%us,
retry_count=%u "
+ "user_timeout=%ums\n", idle_val, interval_val, retry_count_val,
user_timeout_val);
+ /* The following options are not portable! */
+ ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPIDLE, &idle_val, sizeof(idle_val));
+ if (ret < 0) {
+ LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP keepalive idle time:
%s\n",
+ strerror(errno));
+ }
+ ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPINTVL, &interval_val,
sizeof(interval_val));
+ if (ret < 0) {
+ LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP keepalive interval:
%s\n",
+ strerror(errno));
+ }
+ ret = setsockopt(fd, IPPROTO_TCP, TCP_KEEPCNT, &retry_count_val,
sizeof(retry_count_val));
+ if (ret < 0)
+ LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP keepalive count: %s\n",
strerror(errno));
+ ret = setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &user_timeout_val,
sizeof(user_timeout_val));
+ if (ret < 0)
+ LOGPIL(line, DLINP, LOGL_ERROR, "Failed to set TCP user timeout: %s\n",
strerror(errno));
}
/* callback of the OML listening filedescriptor */
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-abis/+/40536?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: Ic6cb1457998ad0c131859be04e86cc7935217361
Gerrit-Change-Number: 40536
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>
Gerrit-Reviewer: pespin <pespin(a)sysmocom.de>