lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 15 Apr 2014 09:30:49 -0700
From:	Chema Gonzalez <chema@...gle.com>
To:	Daniel Borkmann <dborkman@...hat.com>
Cc:	David Miller <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>, netdev@...r.kernel.org,
	ast@...mgrid.com
Subject: Re: [PATCH] filter: added BPF random opcode

On Tue, Apr 15, 2014 at 12:24 AM, Daniel Borkmann <dborkman@...hat.com> wrote:
> Hi Chema,
>
> [cc'ing Alexei as well]
>
> note, net-next is still closed, so you might need to resend this later
> on again when it opens up.
I will. Thanks!

> On 04/15/2014 01:02 AM, Chema Gonzalez wrote:
>> diff --git a/tools/net/bpf_exp.l b/tools/net/bpf_exp.l
>> index bf7be77..804256f 100644
>> --- a/tools/net/bpf_exp.l
>> +++ b/tools/net/bpf_exp.l
>> @@ -92,6 +92,7 @@ extern void yyerror(const char *str);
>>   "#"?("cpu")   { return K_CPU; }
>>   "#"?("vlan_tci") { return K_VLANT; }
>>   "#"?("vlan_pr")       { return K_VLANP; }
>> +"#"?("random") { return K_RAND; }
>
>
> Thanks for also updating bpf_asm ! :)
bpf_asm was key in ensuring this worked. In fact, we should modify the
Makefile so that it relies on the local filter.h before the
/usr/include/ one (my Ubuntu Precise /usr/include/linux/filter.h does
not define BPF_MOD, BPF_XOR, SKF_AD_VLAN_TAG, SKF_AD_VLAN_TAG_PRESENT,
or SKF_AD_PAY_OFFSET).

> I think using just "rnd" is cleaner here.
I think using always random (in fact I may s/K_RAND/K_RANDOM/g) allows
easier grepping.

>> diff --git a/tools/net/icmp_random.bpf b/tools/net/icmp_random.bpf
>> new file mode 100644
>> index 0000000..b9adcbf
>> --- /dev/null
>> +++ b/tools/net/icmp_random.bpf
>> @@ -0,0 +1,12 @@
>> +# icmp random packet sampling, 1 in 4
>> +ldh [12]
>> +jne #0x800, drop
>> +ldb [23]
>> +jneq #1, drop
>> +# get a random uint32 number
>> +ld random
>> +mod #4
>> +jneq #1, drop
>> +ret #-1
>> +drop: ret #0
>> +
>>
>
> This example should rather go into Documentation/networking/filter.txt's
> example section, rather than tools/net/ .
I'll add it there.

Now, I'd like to add a new directory for BPF programs (tools/net/bpf/
?). It allows playing with bpf_asm.

-Chema
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ