def nl_send(sk, msg):
    """Transmit Netlink message.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/nl.c#L416

    Transmits the Netlink message `msg` over the Netlink socket using the `socket.sendmsg()`. This function is based on
    `nl_send_iovec()`.

    The message is addressed to the peer as specified in the socket by either the nl_socket_set_peer_port() or
    nl_socket_set_peer_groups() function. The peer address can be overwritten by specifying an address in the `msg`
    object using nlmsg_set_dst().

    If present in the `msg`, credentials set by the nlmsg_set_creds() function are added to the control buffer of the
    message.

    Calls to this function can be overwritten by providing an alternative using the nl_cb_overwrite_send() function.

    This function triggers the `NL_CB_MSG_OUT` callback.

    ATTENTION:  Unlike `nl_send_auto()`, this function does *not* finalize the message in terms of automatically adding
    needed flags or filling out port numbers.

    Positional arguments:
    sk -- Netlink socket (nl_sock class instance).
    msg -- Netlink message (nl_msg class instance).

    Returns:
    Number of bytes sent on success or a negative error code.
    """
    cb = sk.s_cb
    if cb.cb_send_ow:
        return cb.cb_send_ow(sk, msg)
    hdr = nlmsg_hdr(msg)
    iov = hdr.bytearray[:hdr.nlmsg_len]
    return nl_send_iovec(sk, msg, iov, 1)