def nl_socket_get_local_port(sk):
if not sk.s_local.nl_pid:<EOL><INDENT>port = generate_local_port()<EOL>sk.s_flags &= ~NL_OWN_PORT<EOL>sk.s_local.nl_pid = port<EOL>return port<EOL><DEDENT>return sk.s_local.nl_pid<EOL>
https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L357.

    Also https://github.com/thom311/libnl/blob/libnl3_2_25/lib/socket.c#L338