netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, eric@regit.org
Subject: Re: [PATCH nft 3/3] src: add nft_ctx_netlink_init()
Date: Fri, 1 Sep 2017 12:50:49 +0200	[thread overview]
Message-ID: <20170901105049.GN20614@orbyte.nwl.cc> (raw)
In-Reply-To: <20170901101733.GA5539@salvia>

Hi Pablo,

On Fri, Sep 01, 2017 at 12:17:33PM +0200, Pablo Neira Ayuso wrote:
> On Fri, Sep 01, 2017 at 12:14:07PM +0200, Pablo Neira Ayuso wrote:
> > Add these two new functions to set up netlink sockets in the global
> > context structure.
> 
> We can alternatively call this nft_ctx_netlink_auto() if prefer.
> 
> I'm just trying to skip the type/flag field for nft_ctx_alloc().
> 
> Does this look acceptable to you to have this extra API to request
> libnftables to deal with IO details too?

I think we could do it in a simpler way:

| /* create an mnl netlink socket object */
| struct mnl_socket *netlink_open_sock(void);
| 
| /* create nft context, optionally passing mnl socket object returned
|  * from netlink_open_sock()
|  * Calling nft_ctx_new(NULL) is equivalent to calling
|  * nft_ctx_new(netlink_open_sock())
|  */
| static struct nft_ctx *nft_ctx_new(struct mnl_socket *nf_sock);

This way we allow the application to control mnl_socket object, provide
a simple API for applications which don't need that and at the same time
always have ctx->nf_sock point to the socket so we can further simplify
things.

What do you think?

Cheers, Phil

  reply	other threads:[~2017-09-01 10:50 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-01 10:14 [PATCH nft 1/3] src: move nf_sock into nft_ctx structure Pablo Neira Ayuso
2017-09-01 10:14 ` [PATCH nft 2/3] netlink: remove nfsock_open() Pablo Neira Ayuso
2017-09-01 10:14 ` [PATCH nft 3/3] src: add nft_ctx_netlink_init() Pablo Neira Ayuso
2017-09-01 10:17   ` Pablo Neira Ayuso
2017-09-01 10:50     ` Phil Sutter [this message]
2017-09-01 10:58       ` Pablo Neira Ayuso
2017-09-01 11:20         ` Phil Sutter
2017-09-01 12:28     ` Florian Westphal
2017-09-01 17:50 ` [PATCH nft 1/3] src: move nf_sock into nft_ctx structure Pablo Neira Ayuso

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=20170901105049.GN20614@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=eric@regit.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).