Reserve room for additional data in a Netlink message.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L407

    Reserves room for additional data at the tail of the an existing netlink message. Eventual padding required will be
    zeroed out.

    bytearray_ptr() at the start of additional data or None.

def nlmsg_reserve(n, len_, pad):
    """Reserve room for additional data in a Netlink message.

    https://github.com/thom311/libnl/blob/libnl3_2_25/lib/msg.c#L407

    Reserves room for additional data at the tail of the an existing netlink message. Eventual padding required will be
    zeroed out.

    bytearray_ptr() at the start of additional data or None.
    """
    nlmsg_len_ = n.nm_nlh.nlmsg_len
    tlen = len_ if not pad else ((len_ + (pad - 1)) & ~(pad - 1))

    if tlen + nlmsg_len_ > n.nm_size:
        return None

    buf = bytearray_ptr(n.nm_nlh.bytearray, nlmsg_len_)
    n.nm_nlh.nlmsg_len += tlen
    if tlen > len_:
        bytearray_ptr(buf, len_, tlen)[:] = bytearray(b'\0') * (tlen - len_)

    _LOGGER.debug('msg 0x%x: Reserved %d (%d) bytes, pad=%d, nlmsg_len=%d', id(n), tlen, len_, pad, n.nm_nlh.nlmsg_len)
    return buf