From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Rybchenko Subject: Re: [PATCH 2/3] mbuf: add a non fatal sanity check helper Date: Mon, 10 Sep 2018 11:33:44 +0300 Message-ID: <8d525334-f770-7627-4023-c61aa92f4655@solarflare.com> References: <20180910054547.18494-1-david.marchand@6wind.com> <20180910054547.18494-3-david.marchand@6wind.com> <86b2ae63-f193-03ce-457d-387b785fb884@solarflare.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Cc: , "Lu, Wenzhuo" , "Wu, Jingjing" , "Iremonger, Bernard" To: David Marchand , Olivier Matz Return-path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [67.231.154.164]) by dpdk.org (Postfix) with ESMTP id AB64D11A4 for ; Mon, 10 Sep 2018 10:34:17 +0200 (CEST) In-Reply-To: Content-Language: en-US List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 09/10/2018 11:24 AM, David Marchand wrote: > On Mon, Sep 10, 2018 at 10:12 AM, Andrew Rybchenko > wrote: >> +/** >> + * 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? > This was what I had done with my first attempt. > But given the name "rte_mbuf_check", having a int (used as a bool) > returned makes sense to me. Yes, good point. > So no strong opinion here. Me too.