From: Balbir Singh Add two utility helper functions genlmsg_msg_size() and genlmsg_total_size(). These functions are derived from their netlink counterparts. Signed-off-by: Balbir Singh Cc: Jamal Hadi Cc: Shailabh Nagar Cc: Thomas Graf Cc: "David S. Miller" Cc: Jay Lan Signed-off-by: Andrew Morton --- include/net/genetlink.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+) diff -puN include/net/genetlink.h~add-genetlink-utilities-for-payload-length-calculation include/net/genetlink.h --- a/include/net/genetlink.h~add-genetlink-utilities-for-payload-length-calculation +++ a/include/net/genetlink.h @@ -171,4 +171,22 @@ static inline int genlmsg_len(const stru return (nlh->nlmsg_len - GENL_HDRLEN - NLMSG_HDRLEN); } +/** + * genlmsg_msg_size - length of genetlink message not including padding + * @payload: length of message payload + */ +static inline int genlmsg_msg_size(int payload) +{ + return GENL_HDRLEN + payload; +} + +/** + * genlmsg_total_size - length of genetlink message including padding + * @payload: length of message payload + */ +static inline int genlmsg_total_size(int payload) +{ + return NLMSG_ALIGN(genlmsg_msg_size(payload)); +} + #endif /* __NET_GENERIC_NETLINK_H */ _