From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Thomas Haller <thaller@redhat.com>
Cc: NetFilter <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH nft 2/2] netlink: add and use _nftnl_udata_buf_alloc() helper
Date: Thu, 9 Nov 2023 16:32:43 +0100 [thread overview]
Message-ID: <ZUz7my1Gawv5RSb4@calendula> (raw)
In-Reply-To: <86486aabb07912a51263c68c8cf45f338081fe5a.camel@redhat.com>
On Thu, Nov 09, 2023 at 04:19:29PM +0100, Thomas Haller wrote:
> On Thu, 2023-11-09 at 16:14 +0100, Pablo Neira Ayuso wrote:
> > On Wed, Nov 08, 2023 at 07:24:25PM +0100, Thomas Haller wrote:
> > > We don't want to handle allocation errors, but crash via
> > > memory_allocation_error().
> > > Also, we usually just allocate NFT_USERDATA_MAXLEN buffers.
> > >
> > > Add a helper for that and use it.
> > >
> > > Signed-off-by: Thomas Haller <thaller@redhat.com>
> > > ---
> > > include/netlink.h | 3 +++
> > > src/mnl.c | 16 ++++------------
> > > src/netlink.c | 7 ++-----
> > > src/netlink_linearize.c | 4 +---
> > > 4 files changed, 10 insertions(+), 20 deletions(-)
> > >
> > > diff --git a/include/netlink.h b/include/netlink.h
> > > index 6766d7e8563f..15cbb332c8dd 100644
> > > --- a/include/netlink.h
> > > +++ b/include/netlink.h
> > > @@ -260,4 +260,7 @@ struct nft_expr_loc *nft_expr_loc_find(const
> > > struct nftnl_expr *nle,
> > >
> > > struct dl_proto_ctx *dl_proto_ctx(struct rule_pp_ctx *ctx);
> > >
> > > +#define _nftnl_udata_buf_alloc() \
> > > + memory_allocation_check(nftnl_udata_buf_alloc(NFT_USERDATA
> > > _MAXLEN))
> >
> > Add a wrapper function, no macro.
> >
>
> Hi,
>
> memory_allocation_error() is itself a macro, as it uses
> __FILE__,__LINE__
In this case above, __FILE__ and __LINE__ does not provide much
information?
nftnl_expr_alloc() returns NULL when support for an expression is
missing in libnftnl, that provides a hint on that, this is very rare
and it can only happen when developing support for new expressions.
Maybe simply say __func__ instead to know what function has failed
when performing the memory allocation is a hint that is fine enough.
> This is also a macro, to preserve those parameters.
>
> Thomas
>
next prev parent reply other threads:[~2023-11-09 15:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-08 18:24 [PATCH nft 1/2] utils: add memory_allocation_check() helper Thomas Haller
2023-11-08 18:24 ` [PATCH nft 2/2] netlink: add and use _nftnl_udata_buf_alloc() helper Thomas Haller
2023-11-09 15:14 ` Pablo Neira Ayuso
2023-11-09 15:19 ` Thomas Haller
2023-11-09 15:32 ` Pablo Neira Ayuso [this message]
2023-11-09 16:48 ` Thomas Haller
2023-11-09 19:12 ` Pablo Neira Ayuso
2023-11-09 15:24 ` [PATCH nft 1/2] utils: add memory_allocation_check() helper Pablo Neira Ayuso
2023-11-09 17:02 ` Thomas Haller
2023-11-15 8:52 ` Florian Westphal
2023-11-15 9:06 ` Thomas Haller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZUz7my1Gawv5RSb4@calendula \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=thaller@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.