laforge submitted this change.

View Change

Approvals: pespin: Looks good to me, but someone else must approve fixeria: Looks good to me, approved Jenkins Builder: Verified
src/stream.c: Use sctp_assoc_id 'canary' to detect misisng sinfo

sctp_rcvinfo() has a successful return path that does *not* fill
the caller-provided sinfo structure. This would be highly unexpected
as we cannot determine the stream_id and PPID then.

Our osmo_io code path already handles that situation correctly
by logging a related error message. The non-osmo-io path however
would silently hide that error.

See also: https://github.com/sctp/lksctp-tools/issues/37

Change-Id: Idf9c0fa4db65ab6ea34a9cb2011400aadf3dd54e
---
M src/stream.c
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/stream.c b/src/stream.c
index f8cbed6..5033f4c 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -279,8 +279,14 @@
int flags = 0;
int ret;

+ /* Canary to detect if kernel returns sinfo; see https://github.com/sctp/lksctp-tools/issues/37 */
+ sinfo.sinfo_assoc_id = 0;
+
ret = sctp_recvmsg(fd, msg->tail, msgb_tailroom(msg), NULL, NULL, &sinfo, &flags);
- return stream_sctp_recvmsg_trailer(log_pfx, msg, ret, &sinfo, flags);
+ if (sinfo.sinfo_assoc_id)
+ return stream_sctp_recvmsg_trailer(log_pfx, msg, ret, &sinfo, flags);
+ else
+ return stream_sctp_recvmsg_trailer(log_pfx, msg, ret, NULL, flags);
}

/*! wrapper for osmo_io asynchronous recvmsg response */

To view, visit change 38004. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Change-Id: Idf9c0fa4db65ab6ea34a9cb2011400aadf3dd54e
Gerrit-Change-Number: 38004
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge@osmocom.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>