[dpdk-dev] [PATCH 2/3] mbuf: add a non fatal sanity check helper
Andrew Rybchenko
arybchenko at solarflare.com
Mon Sep 10 10:12:09 CEST 2018
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 <david.marchand at 6wind.com>
> ---
<...>
> 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?
<...>
More information about the dev
mailing list