diff options
author | Thomas Haller <thaller@redhat.com> | 2015-07-10 12:58:50 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-08-14 13:51:26 (GMT) |
commit | f78c3e82398a505ccf7e297b4021f23559ad8977 (patch) | |
tree | be4e16f07249b7b6ceee25d789b9526a12bd78e4 /src/nl-link-ifindex2name.c | |
parent | c38022898abbd75e0ea824a2c4edf73075dfa109 (diff) | |
download | libnl-f78c3e82398a505ccf7e297b4021f23559ad8977.zip libnl-f78c3e82398a505ccf7e297b4021f23559ad8977.tar.gz libnl-f78c3e82398a505ccf7e297b4021f23559ad8977.tar.bz2 |
socket: clear port when unable to generate local port
When running out of local ports, _nl_socket_generate_local_port_no_release()
would leave the socket with port UINT32_MAX. That means if nl_connect()
fails due to out-of-ports, it would leave the port id assigned to an
invalid port and the socket instance was not re-usable until the user
called nl_socket_set_local_port(). Fix that by resetting the local port
to zero.
Thereby, also change generate_local_port() to return zero when
running out of ports. zero is a more natural value for ~no port found~.
It also matches the port that _nl_socket_generate_local_port_no_release()
uses when failing to generate a port.
Also ensure that zero cannot be returned as valid port by generate_local_port().
Arguably, that would only be possible if (getpid() & 0x3FFFFF)
returns zero. Just be extra cautious.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'src/nl-link-ifindex2name.c')
0 files changed, 0 insertions, 0 deletions