Thread (19 messages) flat view 19 messages, 5 authors, 2014-07-29

Re: [PATCH net-next] net: filter: rename 'struct sk_filter' to 'struct bpf_prog'

From: Alexei Starovoitov <hidden>
Date: 2014-07-25 19:02:15
Also in: lkml, netfilter-devel

On Fri, Jul 25, 2014 at 11:58 AM, Alexei Starovoitov [off-list ref] wrote:
On Fri, Jul 25, 2014 at 11:50 AM, Willem de Bruijn [off-list ref] wrote:
quoted
On Fri, Jul 25, 2014 at 2:43 PM, Alexei Starovoitov [off-list ref] wrote:
quoted
On Fri, Jul 25, 2014 at 11:32 AM, Willem de Bruijn [off-list ref] wrote:
quoted
quoted
quoted
This follows a convention in include/uapi/linux/netfilter/*.h that
likely predates the introduction of uapi. A search for "Used
internally by the kernel" shows many more examples. I should not have
included filter.h, however. The common behavior when using pointers
to kernel-internal structures is to have a forward declaration. I suggest
making that change, instead of changing to void *. This avoids having
to add casts where xt_bpf_info is used in net/netfilter/xt_bpf.c:
that will not avoid typecast.
Either 'void *' approach or extra 'struct sk_filter;' approach, both need
type casts to 'struct bpf_prog' in xt_bpf.c
(because of SK_RUN_FILTER macro)
Therefore I prefer extra 'struct sk_filter;' approach.
I hadn't noticed that your patch makes the same change that I
proposed. Nothing in userspace should touch that pointer, so it is
fine to change its type to struct bpf_prog* at the same time. No need
for typecasts.
really? I don't think it's a good idea to expose kernel struct type
to user space. How is it even going to compile?
a forward declaration.
quoted
#include <linux/filter.h> brings different files in kernel and in user space.
struct bpf_prog is undefined in user space and compiler will complain.
Adding 'struct bpf_prog;' will be ugly.
imo the lesser evil is adding 'struct sk_filter;' and doing type casts
in kernel.
but the exact same argument applies to sk_filter. If that struct is
renamed everywhere else, then the result will only be more confusing.
A forward declaration is the standard workaround to all such cases in
include/uapi/linux/netfilter. See for instance xt_connlimit.h. This is
sufficient to allow userspace build to succeed, without exposing any
kernel structure detail. If you don't even want to leak the name, then
let's make it void *. Keeping a declaration for sk_filter, while
sk_filter is renamed everywhere else is the least good option, in my
opinion.
well, since you the author of this bit and you're ok with 'void *', I'm ok
with it too :) Just typecast in kernel is still needed because of
SK_RUN_FILTER() macro...
just tried with 'void *', actually all three type casts are needed...
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help