From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 058C61041 for ; Mon, 10 Sep 2018 10:12:47 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us4.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id E678CBC005E; Mon, 10 Sep 2018 08:12:41 +0000 (UTC) Received: from [192.168.38.17] (91.220.146.112) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 10 Sep 2018 01:12:38 -0700 To: David Marchand , CC: , , , References: <20180910054547.18494-1-david.marchand@6wind.com> <20180910054547.18494-3-david.marchand@6wind.com> From: Andrew Rybchenko Message-ID: <86b2ae63-f193-03ce-457d-387b785fb884@solarflare.com> Date: Mon, 10 Sep 2018 11:12:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20180910054547.18494-3-david.marchand@6wind.com> Content-Language: en-US X-Originating-IP: [91.220.146.112] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ocex03.SolarFlarecom.com (10.20.40.36) X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24084.005 X-TM-AS-Result: No-13.266500-4.000000-10 X-TMASE-MatchedRID: 8+bhjh9TQnGhGvK1s4lxDSa1MaKuob8PC/ExpXrHizwUnhXZChKvF9/Z UmGP9YkbUpd9fEj7LqJLTmvmHr3PYqDUMTFlJZ9NJhFEQZiq2ZRYN1akkye0qAv/nTOPQovsQ0U kLoLY8eYkDxz1Ll/sl3Q/i9gZ2sbzgVDJ+NS/WkDJ1E39jKDimAXXmzqmsIi7InzOyTDR1uvr1+ wlUpROxatN5frKt6F/5minEW8VR3plZ48frA+ismg4D2QV/2zL6r3HCixfuKcML9Wb3Qh/hVTNq f3EQ8oxYnP+cq2mFg5XmxqYx7OZlsZXUijhl2l8GQlUVP2iPcwtlZY1WAfRjdmGo8tT/VtV3SlE gVuyN9tvuYnoduGWEZGTpe1iiCJq71zr0FZRMbBWdFebWIc3VmxlRJiH4397+Ug/m+4C0mxkLGT ujUk5RtaznwNdyxqpmKOZILhxmBgoJAB7N1QxcFBByZ5AVpC6wwTklQGXFCv9/G+Hwx0QsBYbYW GDiUEb X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--13.266500-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24084.005 X-MDID: 1536567162-WMM9hT9pCYa9 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH 2/3] mbuf: add a non fatal sanity check helper X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Sep 2018 08:12:48 -0000 On 09/10/2018 08:45 AM, David Marchand wrote: > Let's add a little helper that does the same as rte_mbuf_sanity_check but > without the panic. > > Signed-off-by: David Marchand > --- <...> > diff --git a/lib/librte_mbuf/rte_mbuf.h b/lib/librte_mbuf/rte_mbuf.h > index a50b05c64..e12a4c765 100644 > --- a/lib/librte_mbuf/rte_mbuf.h > +++ b/lib/librte_mbuf/rte_mbuf.h > @@ -977,6 +977,29 @@ rte_mbuf_ext_refcnt_update(struct rte_mbuf_ext_shared_info *shinfo, > void > rte_mbuf_sanity_check(const struct rte_mbuf *m, int is_header); > > +/** > + * Sanity checks on a mbuf. > + * > + * Almost like rte_mbuf_sanity_check(), but this function gives the reason > + * if corruption is detected rather than panic. > + * > + * @param m > + * The mbuf to be checked. > + * @param is_header > + * True if the mbuf is a packet header, false if it is a sub-segment > + * of a packet (in this case, some fields like nb_segs are not checked) > + * @param reason > + * A reference to a string pointer where to store the reason why a mbuf is > + * considered invalid. > + * @return > + * - 0 if no issue has been found, reason is left untouched. > + * - -1 if a problem is detected, reason then points to a string describing > + * the reason why the mbuf is deemed invalid. > + */ > +__rte_experimental > +int rte_mbuf_check(const struct rte_mbuf *m, int is_header, > + const char **reason); > + May be it would be better to return reason as return value and if it is NULL everything is OK? <...>