Thomas Graf wrote:
+/*
+ * Process one packet of messages.
+ * Malformed skbs with wrong lengths of messages are discarded silently.
+ */
+int netlink_process_skb(struct sk_buff *skb,
+ int (*process_msg)(struct sk_buff *skb,
+ struct nlmsghdr *nlh,
+ int *err))
+{
+ int err;
+ struct nlmsghdr * nlh;
+
+ while (skb->len >= NLMSG_SPACE(0)) {
While you're at it, change that to NLMSG_LENGTH(0) or even to
NLMSG_ALIGN(sizeof(*nlh)) to make it more readable. NLMSG_SPACE()
represents the total size of a netlink message in the byte stream
including the padding to payload in order to enforce proper
alignement for successive netlink message header.
They are all the same thing. They all return 16 bytes which is the size
of a netlink header. If you and someone else think that those are more
readable, I'm ok with it, whatever. I just stole that piece of code as
is from current checkings done in xfrm and rtnetlink.
--
Pablo
|