]> git.baikalelectronics.ru Git - kernel.git/commit
packet: add PACKET_FANOUT_FLAG_UNIQUEID to assign new fanout group id.
authorMike Maloney <maloney@google.com>
Fri, 21 Apr 2017 14:56:11 +0000 (10:56 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Apr 2017 16:46:00 +0000 (12:46 -0400)
commite7a4d7bb14dba26f5336db3a9f96b92bdc4df300
treebf8f3666194ccbfc21b3173db46a18e36b390b4e
parente5a2bc349eed5820c85b9c20167426d7bdb7ad91
packet: add PACKET_FANOUT_FLAG_UNIQUEID to assign new fanout group id.

Fanout uses a per net global namespace. A process that intends to create
a new fanout group can accidentally join an existing group. It is not
possible to detect this.

Add socket option PACKET_FANOUT_FLAG_UNIQUEID.  When specified the
supplied fanout group id must be set to 0, and the kernel chooses an id
that is not already in use.  This is an ephemeral flag so that
other sockets can be added to this group using setsockopt, but NOT
specifying this flag.  The current getsockopt(..., PACKET_FANOUT, ...)
can be used to retrieve the new group id.

We assume that there are not a lot of fanout groups and that this is not
a high frequency call.

The method assigns ids starting at zero and increases until it finds an
unused id.  It keeps track of the last assigned id, and uses it as a
starting point to find new ids.

Signed-off-by: Mike Maloney <maloney@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/uapi/linux/if_packet.h
net/packet/af_packet.c