Skip to content
  • Mike Maloney's avatar
    packet: add PACKET_FANOUT_FLAG_UNIQUEID to assign new fanout group id. · 4a69a864
    Mike Maloney authored
    
    
    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: default avatarMike Maloney <maloney@google.com>
    Acked-by: default avatarWillem de Bruijn <willemb@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    4a69a864