[PATCH v2] remove automatic port id generation

Thomas Haller thaller at redhat.com
Fri Jun 26 08:48:22 PDT 2015


On Wed, 2015-06-17 at 15:49 +0200, Julien Courtat wrote:
> Since kernel can automatically set a unique portid to each socket any
> application would bind with, there is no use to keep the portid 
> generation
> procedure made of 22 bits for the pid and 10 bits left for a pseudo
> random value.
> Remove this procedure and let kernel choose a port id for the socket.
> It is still possible for an application to set the port id manually 
> via
> nl_socket_set_local_port().
> 
> Signed-off-by: Julien Courtat <julien.courtat at 6wind.com>
> ---

Hi Julien,

The patch removes generate_local_port() entirely. I think that is too
much because it changes behavior in the following case:

    sk = nl_socket_alloc();
    port = nl_socket_get_local_port(sk);
    /* do something with port... */
    nl_connect(sk, NETLINK_...);

Calling nl_socket_get_local_port() before connecting the socket already
assigns a port. While it is not a good idea to do that, I'd rather not
change behavior without strong reason.

So I would restore some parts that you deleted from lib/socket.c.
(you don't have to send a v3 if we agree on that).




Regarding the part in lib/nl.c:
The question still stands whether it is safe to do the change it(?).
But I think yes. AFAIS, netlink_autobind() is in kernel for a ~very~
long time.



Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20150626/46cc8220/attachment.sig>


More information about the libnl mailing list