All of lore.kernel.org
 help / color / mirror / Atom feed
* Question: Variable sized matchinfo
@ 2003-01-20 12:14 Patrick McHardy
  0 siblings, 0 replies; 4+ messages in thread
From: Patrick McHardy @ 2003-01-20 12:14 UTC (permalink / raw)
  To: Netfilter Development Mailinglist

Hi.

I want to write a match where it would be nice to pass a variable sized 
matchinfo to kernelspace.
Is this possible ? I want to avoid always using the largest possible 
values (2^16 + a few bytes).
The data in question is a bpf program compiled with pcap_compile ..
This is probably not the most useful match but i think it beats u32 
because bpf syntax is already well-known
and very pleasant to use.

Regards,
Patrick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* re: Question: Variable sized matchinfo
       [not found] <20030120232634.24011.21218.Mailman@kashyyyk>
@ 2003-01-21  6:40 ` Don Cohen
  2003-01-21 11:42   ` Patrick McHardy
  0 siblings, 1 reply; 4+ messages in thread
From: Don Cohen @ 2003-01-21  6:40 UTC (permalink / raw)
  To: netfilter-devel, Patrick McHardy

 > I want to write a match where it would be nice to pass a variable sized 
 > matchinfo to kernelspace.
The answer when I asked this question in connection with u32 was no.
In fact,
I asked:
  > Would it work to make that 10 into a module parm (or three) ?
Harald answered:
  unfortunately not.  The size of this structure needs to be known at
  compile time of the kernel and iptables userspace (and they have to be
  the same, obviously).

 > Is this possible ? I want to avoid always using the largest possible 
 > values (2^16 + a few bytes).
 > The data in question is a bpf program compiled with pcap_compile ..
 > This is probably not the most useful match but i think it beats u32 
 > because bpf syntax is already well-known
 > and very pleasant to use.
Thanks for the reference.  I'll read about it.  I assume you mean the
u32 I posted recently.
So far the bpf language doesn't strike me as pleasant to use compared
to the small language I made up for u32, but maybe that's just cause
I'm not used to it.  
I gather 2^16 is the maximum possible size of a bpf program.
How about supplying several different variants of your module,
one that has data size 128 bytes, another with size 1K, another 8K
and finally 64K.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question: Variable sized matchinfo
  2003-01-21  6:40 ` Don Cohen
@ 2003-01-21 11:42   ` Patrick McHardy
  2003-01-21 16:07     ` Laszlo Valko
  0 siblings, 1 reply; 4+ messages in thread
From: Patrick McHardy @ 2003-01-21 11:42 UTC (permalink / raw)
  To: Don Cohen; +Cc: netfilter-devel

Don Cohen wrote:

> > I want to write a match where it would be nice to pass a variable sized 
> > matchinfo to kernelspace.
>The answer when I asked this question in connection with u32 was no.
>In fact,
>I asked:
>  > Would it work to make that 10 into a module parm (or three) ?
>Harald answered:
>  unfortunately not.  The size of this structure needs to be known at
>  compile time of the kernel and iptables userspace (and they have to be
>  the same, obviously).
>

Oops, i probably missed that.
Anyway this doesn't seem to be real problem, you could just pass pointers
and copy_from_user the data. The probleme there is the match is not informed
if its not needed anymore, so no chance to free the memory.

>
> > Is this possible ? I want to avoid always using the largest possible 
> > values (2^16 + a few bytes).
> > The data in question is a bpf program compiled with pcap_compile ..
> > This is probably not the most useful match but i think it beats u32 
> > because bpf syntax is already well-known
> > and very pleasant to use.
>Thanks for the reference.  I'll read about it.  I assume you mean the
>u32 I posted recently.
>So far the bpf language doesn't strike me as pleasant to use compared
>to the small language I made up for u32, but maybe that's just cause
>I'm not used to it.  
>I gather 2^16 is the maximum possible size of a bpf program.
>

no they are not limited in size AFAIK. I recently portet PPP_FILTERs to 
isdn and
they chose a limit of 2^16 which sounds sane. But i missed its not 2^16 
bytes
but 2^16 * sizeof(struct sock_fprog). If you want to look at a example 
for using
sk_run_filter (matches bpf code in kernel) you can look at it at 
http://trash.net/~kaber

>How about supplying several different variants of your module,
>one that has data size 128 bytes, another with size 1K, another 8K
>and finally 64K.
>  
>

no i decided its too ugly to do stuff like this without beeing able to 
either pass a variable-sized
struct from userspace (the size-check is done by the module itself, so 
no problem there) or allocate
the memory in kernelspace myself (and free it afterwards). Both doesn't 
seem like a big problem to do,
but it's not worth it for a just-for-fun match. Another uglyness is it 
is not possible to display the bpf
code in userspace with iptables -L because its already compiled and 
optimized. IIRC you ran into the same
problem with u32.
If anyone would really like a bpf match tell me and i might reconsider.

Patrick

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question: Variable sized matchinfo
  2003-01-21 11:42   ` Patrick McHardy
@ 2003-01-21 16:07     ` Laszlo Valko
  0 siblings, 0 replies; 4+ messages in thread
From: Laszlo Valko @ 2003-01-21 16:07 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: Don Cohen, netfilter-devel

On Tue, Jan 21, 2003 at 12:42:16PM +0100, Patrick McHardy wrote:
> Oops, i probably missed that.
> Anyway this doesn't seem to be real problem, you could just pass pointers
> and copy_from_user the data. The probleme there is the match is not informed
> if its not needed anymore, so no chance to free the memory.

But consider that the pointer on the kernel-side might not look like
what it looks like on the user-side!

See my patch earlier with a sparc64 compatibility fix. Basically,
you will have to implement a thunk which translates the 32-bit userspace
pointer sent from iptables to a 64-bit kernelspace pointer. The best
solution is to avoid pointers, as the pointer translation usually involves
translating the whole struct being passed because of the field
offset differences.

Laszlo


> 
> Patrick
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-21 16:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-20 12:14 Question: Variable sized matchinfo Patrick McHardy
     [not found] <20030120232634.24011.21218.Mailman@kashyyyk>
2003-01-21  6:40 ` Don Cohen
2003-01-21 11:42   ` Patrick McHardy
2003-01-21 16:07     ` Laszlo Valko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.