nlmsg_len and NLMSG_ALIGN

Joel Cunningham joel.cunningham at me.com
Mon May 9 09:48:20 PDT 2016


Hi,

I'm working on gaining an understanding of the libnl implementation and one thing I've found confusing is the usage of the nlmsg_len member of struct nlmsghdr.  It's my understanding that this member represents the currently reserved/used space in the struct nlmsgmdr, including padding.

Throughout the libnl code, various places use nlmsg_len with NLMSG_ALIGN wrapped around it and other places without.  If nlmsg_len is supposed to already include the padding, why use NLMSG_ALIGN?

Here are a couple of examples of each:

With NLMSG_ALIGN:
nlmsg_next
nlmsg_tail
nla_nest_end
nla_reserve

Without:
nlmsg_reserve (assignment of buf)
nl_send
genlmsg_len

Thanks,

Joel


More information about the libnl mailing list