pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-mgw/+/36631?usp=email )
Change subject: Fix IuUP RTP hdr seqnr field not incremented ......................................................................
Fix IuUP RTP hdr seqnr field not incremented
Previous commit add osmo_io changed mgcp_udp_send() implementation from "return sendto()", which is documented as: "return the number of bytes sent. Otherwise, -1 shall be returned"
to "return mgcp_udp_send_msg()", which in turn calls "return osmo_iofd_sendto_msgb()", and which is documented as: "\returns 0 in case of success (takes msgb ownership), -1 on error (doesn't take msgb ownership)."
So successful return code changed from >0 (bytes sent) to ==0, but forgot to update mgcp_send_iuup() return code path check (and also some related function documentation calling mgcp_udp_send()".
This commit fixes all the related aspects of that return code change.
Fixes: 352b967d1bee4b3bc51ecc383306bad0fc5b7fbf Change-Id: I154e1e41cd02fd4d9b88ad98fc7c4d657246c589 --- M src/libosmo-mgcp/mgcp_iuup.c M src/libosmo-mgcp/mgcp_network.c M src/libosmo-mgcp/mgcp_osmux.c 3 files changed, 35 insertions(+), 10 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-mgw refs/changes/31/36631/1
diff --git a/src/libosmo-mgcp/mgcp_iuup.c b/src/libosmo-mgcp/mgcp_iuup.c index 7531e42..d6f164d 100644 --- a/src/libosmo-mgcp/mgcp_iuup.c +++ b/src/libosmo-mgcp/mgcp_iuup.c @@ -468,7 +468,7 @@ struct rtp_hdr *hdr = (struct rtp_hdr *)msgb_data(msg); int buflen = msgb_length(msg); char *dest_name; - int len; + int rc;
OSMO_ASSERT(conn_src); OSMO_ASSERT(conn_dst); @@ -514,16 +514,16 @@ /* Forward a copy of the RTP data to a debug ip/port */ forward_data_tap(rtp_end->rtp, &conn_src->tap_out, msg);
- len = mgcp_udp_send(rtp_end->rtp, &rtp_end->addr, (char *)hdr, buflen); + rc = mgcp_udp_send(rtp_end->rtp, &rtp_end->addr, (char *)hdr, buflen);
- if (len <= 0) - return len; + if (rc < 0) + return rc;
rtpconn_rate_ctr_add(conn_dst, endp, RTP_PACKETS_TX_CTR, 1); - rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, len); + rtpconn_rate_ctr_add(conn_dst, endp, RTP_OCTETS_TX_CTR, buflen); rtp_state->alt_rtp_tx_sequence++;
- return len; + return 0; }
/* Received TNL primitive from IuUP layer FSM, transmit it further down to the diff --git a/src/libosmo-mgcp/mgcp_network.c b/src/libosmo-mgcp/mgcp_network.c index 1fc2c56..58d85df 100644 --- a/src/libosmo-mgcp/mgcp_network.c +++ b/src/libosmo-mgcp/mgcp_network.c @@ -1062,7 +1062,7 @@ * \param[in] addr destination ip-address. * \param[in] buf buffer that holds the data to be send. * \param[in] len length of the data to be sent. - * \returns bytes sent, -1 on error. */ + * \returns 0 in case of success, -1 on error. */ int mgcp_udp_send(struct osmo_io_fd *iofd, const struct osmo_sockaddr *addr, const char *buf, int len) { struct msgb *msg = msgb_alloc_c(iofd, len, "mgcp_udp_send"); @@ -1077,7 +1077,7 @@ /*! send RTP dummy packet (to keep NAT connection open). * \param[in] endp mcgp endpoint that holds the RTP connection. * \param[in] conn associated RTP connection. - * \returns bytes sent, -1 on error. */ + * \returns 0 in case of success, -1 on error. */ int mgcp_send_dummy(struct mgcp_endpoint *endp, struct mgcp_conn_rtp *conn) { int rc; @@ -1113,7 +1113,7 @@ rc = mgcp_udp_send(conn->end.rtcp, &rtcp_addr, rtp_dummy_payload, sizeof(rtp_dummy_payload));
- if (rc >= 0) + if (rc == 0) return rc;
failed: diff --git a/src/libosmo-mgcp/mgcp_osmux.c b/src/libosmo-mgcp/mgcp_osmux.c index df91dbc..f8383d6 100644 --- a/src/libosmo-mgcp/mgcp_osmux.c +++ b/src/libosmo-mgcp/mgcp_osmux.c @@ -695,7 +695,7 @@
/*! send RTP dummy packet to OSMUX connection port. * \param[in] conn associated RTP connection - * \returns bytes sent, -1 on error */ + * \returns 0 in case of success, -1 on error */ int osmux_send_dummy(struct mgcp_conn_rtp *conn) { char ipbuf[INET6_ADDRSTRLEN];