From patchwork Tue Apr 7 15:52:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacob Erlbeck X-Patchwork-Id: 458707 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (unknown [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 3D5F714027F for ; Wed, 8 Apr 2015 01:53:55 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 1741F2C59; Tue, 7 Apr 2015 15:53:54 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org Received: from ganesha.gnumonks.org (ganesha.gnumonks.org [213.95.27.120]) by lists.osmocom.org (Postfix) with ESMTP id 8D5152C4B for ; Tue, 7 Apr 2015 15:53:52 +0000 (UTC) Received: from mail.sysmocom.de ([144.76.43.93]) by ganesha.gnumonks.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1YfVoz-00073A-6R for openbsc@lists.osmocom.org; Tue, 07 Apr 2015 17:53:52 +0200 Received: from sysmocom-tmp.am93.sysmocom.de (ip5b41c286.dynamic.kabel-deutschland.de [91.65.194.134]) by mail.sysmocom.de (Postfix) with ESMTPSA id 820A0BBF01; Tue, 7 Apr 2015 15:53:03 +0000 (UTC) From: Jacob Erlbeck To: openbsc@lists.osmocom.org Subject: [PATCH 3/3] ns: Log when sending fails (Coverity) Date: Tue, 7 Apr 2015 17:52:45 +0200 Message-Id: <1428421965-3534-3-git-send-email-jerlbeck@sysmocom.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1428421965-3534-1-git-send-email-jerlbeck@sysmocom.de> References: <1428421965-3534-1-git-send-email-jerlbeck@sysmocom.de> X-Spam-Score: 0.9 (/) X-Spam-Report: SpamASsassin versoin 3.3.1 on ganesha.gnumonks.org summary: Content analysis details: (0.9 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 2.7 DNS_FROM_AHBL_RHSBL RBL: Envelope sender listed in dnsbl.ahbl.org 0.1 TW_TR BODY: Odd Letter Triples with TR -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0074] X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" 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 --- include/osmocom/gprs/gprs_ns.h | 10 ++++------ src/gb/gprs_ns.c | 19 +++++++++++++++++++ src/gb/libosmogb.map | 1 + 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/include/osmocom/gprs/gprs_ns.h b/include/osmocom/gprs/gprs_ns.h index e77ca42..d5a605d 100644 --- a/include/osmocom/gprs/gprs_ns.h +++ b/include/osmocom/gprs/gprs_ns.h @@ -23,6 +23,9 @@ "Alive Timer (Tns-alive) timeout\n" \ "Alive Timer (Tns-alive) number of retries\n" +#define NS_ALLOC_SIZE 2048 +#define NS_ALLOC_HEADROOM 20 + enum ns_timeout { NS_TOUT_TNS_BLOCK, NS_TOUT_TNS_BLOCK_RETRIES, @@ -186,12 +189,7 @@ void gprs_ns_ll_copy(struct gprs_nsvc *nsvc, struct gprs_nsvc *other); /* Clear the link layer info (will never match a real link then) */ void gprs_ns_ll_clear(struct gprs_nsvc *nsvc); -#define NS_ALLOC_SIZE 2048 -#define NS_ALLOC_HEADROOM 20 -static inline struct msgb *gprs_ns_msgb_alloc(void) -{ - return msgb_alloc_headroom(NS_ALLOC_SIZE, NS_ALLOC_HEADROOM, "GPRS/NS"); -} +struct msgb *gprs_ns_msgb_alloc(void); enum signal_ns { S_NS_RESET, diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c index 27968e3..827d09d 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); diff --git a/src/gb/libosmogb.map b/src/gb/libosmogb.map index a21a7ac..43ebbf8 100644 --- a/src/gb/libosmogb.map +++ b/src/gb/libosmogb.map @@ -57,6 +57,7 @@ gprs_ns_vty_init; gprs_ns_ll_str; gprs_ns_ll_copy; gprs_ns_ll_clear; +gprs_ns_msgb_alloc; gprs_nsvc_create; gprs_nsvc_delete;