pespin has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/41665?usp=email )
Change subject: stream: Log failure to apply NODELAY sockopt ......................................................................
stream: Log failure to apply NODELAY sockopt
Failing to apply NODLEAY if asked to will close the fd after accepting it. Log the error so users understand why the client is rejected after the connection is opened.
Change-Id: I14feff9ad0fefcd0d30d88073408dd598e7dd067 --- M src/stream.c M src/stream_srv.c 2 files changed, 16 insertions(+), 1 deletion(-)
Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified osmith: Looks good to me, approved
diff --git a/src/stream.c b/src/stream.c index 339dd6a..e2aaf59 100644 --- a/src/stream.c +++ b/src/stream.c @@ -182,10 +182,22 @@ #ifdef HAVE_LIBSCTP case IPPROTO_SCTP: rc = setsockopt(fd, IPPROTO_SCTP, SCTP_NODELAY, &on, sizeof(on)); + if (rc < 0) { + char errbuf[256]; + strerror_r(errno, errbuf, sizeof(errbuf)); + LOGP(DLINP, LOGL_ERROR, "setsockopt(IPPROTO_SCTP, SCTP_NODELAY, %u) failed: %d (%s)\n", + on, errno, errbuf); + } break; #endif case IPPROTO_TCP: rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on)); + if (rc < 0) { + char errbuf[256]; + strerror_r(errno, errbuf, sizeof(errbuf)); + LOGP(DLINP, LOGL_ERROR, "setsockopt(IPPROTO_TCP, TCP_NODELAY, %u) failed: %d (%s)\n", + on, errno, errbuf); + } break; default: rc = -1; diff --git a/src/stream_srv.c b/src/stream_srv.c index 695a46f..6f86cfd 100644 --- a/src/stream_srv.c +++ b/src/stream_srv.c @@ -172,8 +172,11 @@
if (link->flags & OSMO_STREAM_SRV_F_NODELAY) { ret = stream_setsockopt_nodelay(sock_fd, link->proto, 1); - if (ret < 0) + if (ret < 0) { + LOGSLNK(link, LOGL_ERROR, "stream_setsockopt_nodelay: failed setsockopt err=%d\n", + errno); goto error_close_socket; + } }
if (link->ip_dscp > 0) {