From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Song Liu <song@kernel.org>
Cc: bpf <bpf@vger.kernel.org>, Networking <netdev@vger.kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"David S . Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
pablo@netfilter.org, fw@strlen.de,
netfilter-devel@vger.kernel.org, lorenzo.bianconi@redhat.com,
"Jesper Dangaard Brouer" <brouer@redhat.com>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>
Subject: Re: [PATCH v2 bpf-next 3/4] net: netfilter: add bpf_ct_set_nat_info kfunc helper
Date: Wed, 7 Sep 2022 11:01:03 +0200 [thread overview]
Message-ID: <Yxhdz47DZiL8V4JE@lore-desk> (raw)
In-Reply-To: <CAPhsuW5P=K7463Ka0CGxFD0BGChrEffbeO6UqReDtr80osDJLg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2195 bytes --]
> On Mon, Sep 5, 2022 at 6:15 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> >
> > Introduce bpf_ct_set_nat_info kfunc helper in order to set source and
> > destination nat addresses/ports in a new allocated ct entry not inserted
> > in the connection tracking table yet.
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> > ---
> > net/netfilter/nf_conntrack_bpf.c | 49 +++++++++++++++++++++++++++++++-
> > 1 file changed, 48 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/netfilter/nf_conntrack_bpf.c b/net/netfilter/nf_conntrack_bpf.c
> > index 1cd87b28c9b0..85b8c7ee00af 100644
> > --- a/net/netfilter/nf_conntrack_bpf.c
> > +++ b/net/netfilter/nf_conntrack_bpf.c
> > @@ -14,6 +14,7 @@
> > #include <net/netfilter/nf_conntrack.h>
> > #include <net/netfilter/nf_conntrack_bpf.h>
> > #include <net/netfilter/nf_conntrack_core.h>
> > +#include <net/netfilter/nf_nat.h>
> >
> > /* bpf_ct_opts - Options for CT lookup helpers
> > *
> > @@ -134,7 +135,6 @@ __bpf_nf_ct_alloc_entry(struct net *net, struct bpf_sock_tuple *bpf_tuple,
> >
> > memset(&ct->proto, 0, sizeof(ct->proto));
> > __nf_ct_set_timeout(ct, timeout * HZ);
> > - ct->status |= IPS_CONFIRMED;
> >
> > out:
> > if (opts->netns_id >= 0)
> > @@ -339,6 +339,7 @@ struct nf_conn *bpf_ct_insert_entry(struct nf_conn___init *nfct_i)
> > struct nf_conn *nfct = (struct nf_conn *)nfct_i;
> > int err;
> >
> > + nfct->status |= IPS_CONFIRMED;
> > err = nf_conntrack_hash_check_insert(nfct);
> > if (err < 0) {
> > nf_conntrack_free(nfct);
> > @@ -424,6 +425,51 @@ int bpf_ct_change_status(struct nf_conn *nfct, u32 status)
> > return nf_ct_change_status_common(nfct, status);
> > }
>
> Why do we need the above two changes in this patch?
nf_nat_setup_info() does not really add the nat info in the connection tracking
entry if it is already confirmed (it just returns NF_ACCEPT). I moved
IPS_CONFIRMED in bpf_ct_insert_entry() since we can run bpf_ct_set_nat_info()
just if the entry has not inserted in the table yet.
Regards,
Lorenzo
>
> Thanks,
> Song
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2022-09-07 9:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-05 13:14 [PATCH v2 bpf-next 0/4] Introduce bpf_ct_set_nat_info kfunc helper Lorenzo Bianconi
2022-09-05 13:14 ` [PATCH v2 bpf-next 1/4] bpf: Add support for per-parameter trusted args Lorenzo Bianconi
2022-09-06 21:27 ` Song Liu
2022-09-05 13:14 ` [PATCH v2 bpf-next 2/4] selftests/bpf: Extend KF_TRUSTED_ARGS test for __ref annotation Lorenzo Bianconi
2022-09-06 21:30 ` Song Liu
2022-09-05 13:14 ` [PATCH v2 bpf-next 3/4] net: netfilter: add bpf_ct_set_nat_info kfunc helper Lorenzo Bianconi
2022-09-06 21:36 ` Song Liu
2022-09-07 9:01 ` Lorenzo Bianconi [this message]
2022-09-07 4:27 ` Alexei Starovoitov
2022-09-07 4:39 ` Kumar Kartikeya Dwivedi
2022-09-07 5:15 ` Alexei Starovoitov
2022-09-07 5:51 ` Kumar Kartikeya Dwivedi
2022-09-07 17:33 ` Alexei Starovoitov
2022-09-07 18:12 ` Kumar Kartikeya Dwivedi
2022-09-05 13:14 ` [PATCH v2 bpf-next 4/4] selftests/bpf: add tests for bpf_ct_set_nat_info kfunc Lorenzo Bianconi
2022-09-06 21:54 ` Song Liu
2022-09-07 10:47 ` Lorenzo Bianconi
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=Yxhdz47DZiL8V4JE@lore-desk \
--to=lorenzo@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=song@kernel.org \
--cc=toke@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 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).