]> 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)
commit2ede682d79f0fa018e863b212f3ddcaa0652b219
treebf8f3666194ccbfc21b3173db46a18e36b390b4e
parentaf302bf0cba168e47a9f451f45f028391edf2ad7
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