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] [day] [month] [year] [list]
Date:	Mon, 31 Mar 2014 23:24:30 +0200
From:	Tom Gundersen <teg@...m.no>
To:	Daniel Borkmann <dborkman@...hat.com>
Cc:	netdev <netdev@...r.kernel.org>, Kay Sievers <kay@...y.org>
Subject: Re: [BUG?] the first bind() of an AF_PACKET socket to an interface is slow

On Mon, Mar 31, 2014 at 10:16 PM, Daniel Borkmann <dborkman@...hat.com> wrote:
> On 03/31/2014 08:43 PM, Tom Gundersen wrote:
>>
>> Hi,
>>
>> I'm observing some strange behavior using bind().
>>
>> For any given process, and any given interface, the first time I bind
>> a socket to the interface it takes a very long time. Subsequent binds
>> to the same interface in the same process are instantaneous.
>>
>> The time it takes seems independent of the interface, so also affects
>> the loopback interface, but binding to all interfaces (ifindex=0) is
>> instantaneous.
>>
>> It is also peculiar to note that the time it takes to bind is
>> seemingly randomly chosen on my machine from 9ms, 19ms, 29ms, 39ms,
>> 49ms and 59 ms, but I never observed any other values.
>>
>> The attached test program illustrates the problem, binding to
>> ifindex=0 (all) and ifindex=1 (loopback).
>>
>> Sample run:
>> # strace -f -T -ebind ./bind
>> bind(3, {sa_family=AF_PACKET, proto=0x800, if0, pkttype=0x40 /* ? */,
>> addr(6)={1328, ffffffffffff}, 20) = 0 <0.000036>
>> bind(3, {sa_family=AF_PACKET, proto=0x800, if0, pkttype=0x40 /* ? */,
>> addr(6)={1328, ffffffffffff}, 20) = 0 <0.000033>
>> bind(3, {sa_family=AF_PACKET, proto=0x800, if1, pkttype=0x40 /* ? */,
>> addr(6)={1328, ffffffffffff}, 20) = 0 <0.059706>
>> bind(3, {sa_family=AF_PACKET, proto=0x800, if1, pkttype=0x40 /* ? */,
>> addr(6)={1328, ffffffffffff}, 20) = 0 <0.000111>
>>
>>
>> Can anyone enlighten me to what is going on? Is this expected behavior
>> or a bug? Any suggestions for a work-around?
>
>
> Expected behaviour as you can save in some cases a synchronize_net() call:
>
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=902fefb82ef72a50c78cb4a20cc954b037a98d1c

Great, that explains what I need to do. Thanks!

Cheers,

Tom
--
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