From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org, Florian Westphal <fw@strlen.de>
Subject: Re: [nf-next PATCH] netfilter: nf_tables: Return info of added rules back to user space
Date: Thu, 4 May 2017 16:47:16 +0200 [thread overview]
Message-ID: <20170504144716.GC20805@orbyte.nwl.cc> (raw)
In-Reply-To: <20170504133544.GB5607@salvia>
On Thu, May 04, 2017 at 03:35:44PM +0200, Pablo Neira Ayuso wrote:
> On Thu, May 04, 2017 at 02:34:17PM +0200, Phil Sutter wrote:
> > This allows user space to reliably match kernel generated handles with
> > added rules for reference.
> >
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> > net/netfilter/nf_tables_api.c | 19 ++++++++++++++++++-
> > 1 file changed, 18 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
> > index 1c6482d2c4dcf..71bce5d024409 100644
> > --- a/net/netfilter/nf_tables_api.c
> > +++ b/net/netfilter/nf_tables_api.c
> > @@ -2142,6 +2142,7 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
> > struct nft_userdata *udata;
> > struct nft_trans *trans = NULL;
> > struct nft_expr *expr;
> > + struct sk_buff *skb2;
> > struct nft_ctx ctx;
> > struct nlattr *tmp;
> > unsigned int size, i, n, ulen = 0, usize = 0;
> > @@ -2281,8 +2282,24 @@ static int nf_tables_newrule(struct net *net, struct sock *nlsk,
> > goto err3;
> > }
> > chain->use++;
> > - return 0;
> >
> > + skb2 = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
> > + if (!skb2) {
> > + err = -ENOMEM;
> > + goto err4;
> > + }
> > + err = nf_tables_fill_rule_info(skb2, net, NETLINK_CB(skb).portid,
> > + nlh->nlmsg_seq, NFT_MSG_NEWRULE, 0,
> > + nfmsg->nfgen_family, table, chain, rule);
> > + if (err < 0)
> > + goto err5;
> > +
> > + return nlmsg_unicast(nlsk, skb2, NETLINK_CB(skb).portid);
>
> You can achieve this already via NLM_F_ECHO.
Oh, thanks for the pointer!
Cheers, Phil
prev parent reply other threads:[~2017-05-04 14:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-04 12:34 [nf-next PATCH] netfilter: nf_tables: Return info of added rules back to user space Phil Sutter
2017-05-04 13:35 ` Pablo Neira Ayuso
2017-05-04 14:47 ` Phil Sutter [this message]
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=20170504144716.GC20805@orbyte.nwl.cc \
--to=phil@nwl.cc \
--cc=fw@strlen.de \
--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).