From 8d192d7153498498ff6232209c900e67256b8036 Mon Sep 17 00:00:00 2001 From: Jacob Erlbeck Date: Tue, 7 Apr 2015 17:52:45 +0200 Subject: ns: Log when sending fails (Coverity) Currently the return value of the gprs_ns_tx family of functions is often ignored. This is not a serious issue, since the successful delivery of the messages is neither guaranteed nor acknowledged by the network layer anyway. Nevertheless this commit adds logging (level INFO) to gprs_ns_tx and gprs_ns_msgb_alloc. The definition of the latter has been moved from the header file to gprs_ns.c. Fixes: Coverity CID 1040678, 1040679, 1040680, 1040681, 1040682, 1040683, 1040684, 1040686, 1040687, 1040688, 1111545, 1240203, 1240204 Sponsored-by: On-Waves ehf --- src/gb/gprs_ns.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/gb/gprs_ns.c') diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 27968e30..827d09d7 100644 --- a/src/gb/gprs_ns.c +++ b/src/gb/gprs_ns.c @@ -131,6 +131,17 @@ static const struct rate_ctr_group_desc nsvc_ctrg_desc = { LOGP(DNS, LOGL_ERROR, "TX failed (%d) to peer %s\n", \ rc, gprs_ns_ll_str(nsvc)); +struct msgb *gprs_ns_msgb_alloc(void) +{ + struct msgb *msg = msgb_alloc_headroom(NS_ALLOC_SIZE, NS_ALLOC_HEADROOM, + "GPRS/NS"); + if (!msg) { + LOGP(DNS, LOGL_ERROR, "Failed to allocate NS message of size %d\n", + NS_ALLOC_SIZE); + } + return msg; +} + /*! \brief Lookup struct gprs_nsvc based on NSVCI * \param[in] nsi NS instance in which to search @@ -298,9 +309,17 @@ static int gprs_ns_tx(struct gprs_nsvc *nsvc, struct msgb *msg) switch (nsvc->ll) { case GPRS_NS_LL_UDP: ret = nsip_sendmsg(nsvc, msg); + if (ret < 0) + LOGP(DNS, LOGL_INFO, + "failed to send NS message via UDP: %s\n", + strerror(-ret)); break; case GPRS_NS_LL_FR_GRE: ret = gprs_ns_frgre_sendmsg(nsvc, msg); + if (ret < 0) + LOGP(DNS, LOGL_INFO, + "failed to send NS message via FR/GRE: %s\n", + strerror(-ret)); break; default: LOGP(DNS, LOGL_ERROR, "unsupported NS linklayer %u\n", nsvc->ll); -- cgit v1.2.3