Close Menu
    What's Hot

    YouTube Unblocked Proxy: Overview, Benefits, and Real-World Use Cases

    April 7, 2026

    Linux Kernel Release Frequency Statistics 2026

    April 7, 2026

    How To Use The SSH Login Command

    April 7, 2026
    Facebook X (Twitter) Instagram
    Command Linux
    • About
    • Man Pages
    • Arch Linux
    • Statistics
    • How to
      • Q&A
    • OS
      • Windows
    • Blog
      • Featured
    • MORE
      • Easter Eggs
      • IP Address
    • Write For Us
    • Contact Us
    Command Linux
    Home - man page - NETLINK

    NETLINK

    WillieBy WillieFebruary 4, 2026Updated:March 27, 2026No Comments2 Mins Read

    NAME

    netlink – Netlink macros  

    SYNOPSIS

    #include <asm/types.h>
    
    #include <linux/netlink.h> int NLMSG_ALIGN(size_t len);
    int NLMSG_LENGTH(size_t len);
    int NLMSG_SPACE(size_t len);
    void *NLMSG_DATA(struct nlmsghdr *nlh);
    struct nlmsghdr *NLMSG_NEXT(struct nlmsghdr *nlh, int len);
    int NLMSG_OK(struct nlmsghdr *nlh, int len);
    int NLMSG_PAYLOAD(struct nlmsghdr *nlh, int len);
     

    DESCRIPTION

    <linux/netlink.h> defines several standard macros to access or create a netlink datagram. They are similar in spirit to the macros defined in cmsg(3) for auxiliary data. The buffer passed to and from a netlink socket should be accessed using only these macros.
    NLMSG_ALIGN()
    Round the length of a netlink message up to align it properly.
    NLMSG_LENGTH()
    Given the payload length, len, this macro returns the aligned length to store in the nlmsg_len field of the nlmsghdr.
    NLMSG_SPACE()
    Return the number of bytes that a netlink message with payload of len would occupy.
    NLMSG_DATA()
    Return a pointer to the payload associated with the passed nlmsghdr.
    NLMSG_NEXT() Get the next nlmsghdr in a multipart message. The caller must check if the current nlmsghdr didn’t have the NLMSG_DONE set—this function doesn’t return NULL on end. The len argument is an lvalue containing the remaining length of the message buffer. This macro decrements it by the length of the message header.
    NLMSG_OK()
    Return true if the netlink message is not truncated and is in a form suitable for parsing.
    NLMSG_PAYLOAD()
    Return the length of the payload associated with the nlmsghdr.
     

    CONFORMING TO

    These macros are nonstandard Linux extensions.  

    NOTES

    It is often better to use netlink via libnetlink than via the low-level kernel interface.

    COLOPHON

    This page is part of release 3.74 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at http://www.kernel.org/doc/man-pages/.

    Willie
    • Website

    Willie has over 15 years of experience in Linux system administration and DevOps. After managing infrastructure for startups and enterprises alike, he founded Command Linux to share the practical knowledge he wished he had when starting out. He oversees content strategy and contributes guides on server management, automation, and security.

    Related Posts

    E2FREEFRAG

    April 7, 2026

    Net::DNS::RR::DHCID

    April 7, 2026

    LOGROTATE

    April 7, 2026

    EVP_MD_CTX_destroy

    April 7, 2026
    Top Posts

    GHC

    February 3, 2026

    sensors

    January 22, 2026

    Linux VPN server Deployment Statistics 2026

    February 20, 2026

    UPOWER

    March 16, 2026
    • Home
    • Contact Us
    • Privacy Policy
    • Terms of Use

    Type above and press Enter to search. Press Esc to cancel.