From: Martin KaFai Lau <martin.lau@linux.dev>
To: Brad Cowie <brad@faucet.nz>
Cc: andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org,
coreteam@netfilter.org, daniel@iogearbox.net,
davem@davemloft.net, john.fastabend@gmail.com, jolsa@kernel.org,
kuba@kernel.org, lorenzo@kernel.org, memxor@gmail.com,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
pabeni@redhat.com, pablo@netfilter.org, sdf@google.com,
song@kernel.org
Subject: Re: [PATCH bpf-next] net: netfilter: Make ct zone id configurable for bpf ct helper functions
Date: Thu, 11 Apr 2024 17:45:29 -0700 [thread overview]
Message-ID: <c0cef1f9-64db-49a2-8c64-3eb9e5092a0f@linux.dev> (raw)
In-Reply-To: <20240411022933.2946226-1-brad@faucet.nz>
On 4/10/24 7:29 PM, Brad Cowie wrote:
> On Sat, 6 Apr 2024 at 09:01, Martin KaFai Lau <martin.lau@linux.dev> wrote:
>> How about the other fields (flags and dir) in the "struct nf_conntrack_zone" and
>> would it be useful to have values other than the default?
>
> Good question, it would probably be useful to make these configurable
> as well. My reason for only adding ct zone id was to avoid changing
> the size of bpf_ct_opts (NF_BPF_CT_OPTS_SZ).
>
> I would be interested in some opinions here on if it's acceptable to
> increase the size of bpf_ct_opts, if so, should I also add back some
> reserved options to the struct for future use?
I think the reserved[2] was there for the padding reason.
It should be the first time there is a __sz increase. May be worth to explore
how it should work.
The opts_len check will need to check == old_size or == new_size. Only use the
new fields if it is new_size.
There is
enum {
NF_BPF_CT_OPTS_SZ = 12,
};
This enum probably needs to update with the new size also. NF_BPF_CT_OPTS_SZ
should be under CO-RE and its enum value will be updated with the running kernel.
The bpf prog has its own struct bpf_ct_opts during compilation (from vmlinux.h
or defined a local one), so may be the bpf prog can do something like this:
#include "vmlinux.h"
struct bpf_ct_opts___newer {
s32 netns_id;
s32 error;
u8 l4proto;
u8 dir;
u8 reserved[2];
u32 new_field; /* for example */
} __attribute__((preserve_access_index));
SEC("tc")
int run_in_older_kernel(struct __sk_buff *ctx)
{
struct bpf_ct_opts___newer opts = {};
/* min of the running kernel opts size or the
* local ___newer opts size
*/
bpf_skb_ct_lookup(ctx, &tup, sizeof(tup.ipv4), &opts,
min(NF_BPF_CT_OPTS_SZ, sizeof(opts));
}
>
>> Can it actually test an alloc and lookup of a non default zone id?
>
> Yes, I have a test written now and will include this in my v2 submission.
>
>> Please also separate the selftest into another patch.
>
> Will do.
>
prev parent reply other threads:[~2024-04-12 0:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-29 4:14 [PATCH bpf-next] net: netfilter: Make ct zone id configurable for bpf ct helper functions Brad Cowie
2024-04-05 20:01 ` Martin KaFai Lau
2024-04-11 2:29 ` Brad Cowie
2024-04-12 0:45 ` Martin KaFai Lau [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=c0cef1f9-64db-49a2-8c64-3eb9e5092a0f@linux.dev \
--to=martin.lau@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brad@faucet.nz \
--cc=coreteam@netfilter.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=lorenzo@kernel.org \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=sdf@google.com \
--cc=song@kernel.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).