]> granicus.if.org Git - libnl/commitdiff
lib/socket: don't fail if no more local ports can be assigned in nl_socket_alloc
authorThomas Haller <thaller@redhat.com>
Wed, 9 Apr 2014 10:08:51 +0000 (12:08 +0200)
committerThomas Haller <thaller@redhat.com>
Tue, 6 May 2014 12:33:54 +0000 (14:33 +0200)
By failing inside of nl_socket_alloc(), the user can not even work around
when running out of local ports. This patch changes that if there are no more
local ports, we set the port to UINT32_MAX. This is a consistent behavior
to calling nl_socket_set_local_port(sk, 0).

In general, since nl_socket_set_local_port() does not restict the generated
ports in any way we cannot assume to have a valid port. So the check in
the constructor was harmful and users who ever encountered it (because they
created 1024 libnl3 sockets) could not even work around it.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
lib/socket.c

index 959b122e69202e663a12520c320e3e2e3d6b678f..eb4a9785fc698f168d32ba7743239ce9ca557e79 100644 (file)
@@ -126,10 +126,6 @@ static struct nl_sock *__alloc_socket(struct nl_cb *cb)
        sk->s_peer.nl_family = AF_NETLINK;
        sk->s_seq_expect = sk->s_seq_next = time(0);
        sk->s_local.nl_pid = generate_local_port();
-       if (sk->s_local.nl_pid == UINT32_MAX) {
-               nl_socket_free(sk);
-               return NULL;
-       }
 
        return sk;
 }