aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/genetlink.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2011-06-20 07:40:46 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-06-22 16:09:45 -0400
commit670dc2833d144375eac36ad74111495a825a9288 (patch)
tree12d5d3a925da562a6ba0497c47f4b55c71ff545b /include/net/genetlink.h
parentc1c3daee97498f5d74bfd23531cfe23c8e14a619 (diff)
netlink: advertise incomplete dumps
Consider the following situation: * a dump that would show 8 entries, four in the first round, and four in the second * between the first and second rounds, 6 entries are removed * now the second round will not show any entry, and even if there is a sequence/generation counter the application will not know To solve this problem, add a new flag NLM_F_DUMP_INTR to the netlink header that indicates the dump wasn't consistent, this flag can also be set on the MSG_DONE message that terminates the dump, and as such above situation can be detected. To achieve this, add a sequence counter to the netlink callback struct. Of course, netlink code still needs to use this new functionality. The correct way to do that is to always set cb->seq when a dumpit callback is invoked and call nl_dump_check_consistent() for each new message. The core code will also call this function for the final MSG_DONE message. To make it usable with generic netlink, a new function genlmsg_nlhdr() is needed to obtain the netlink header from the genetlink user header. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'include/net/genetlink.h')
-rw-r--r--include/net/genetlink.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index d420f28b6d60..82d8d09faa44 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -160,6 +160,38 @@ static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq,
160} 160}
161 161
162/** 162/**
163 * genlmsg_nlhdr - Obtain netlink header from user specified header
164 * @user_hdr: user header as returned from genlmsg_put()
165 * @family: generic netlink family
166 *
167 * Returns pointer to netlink header.
168 */
169static inline struct nlmsghdr *genlmsg_nlhdr(void *user_hdr,
170 struct genl_family *family)
171{
172 return (struct nlmsghdr *)((char *)user_hdr -
173 family->hdrsize -
174 GENL_HDRLEN -
175 NLMSG_HDRLEN);
176}
177
178/**
179 * genl_dump_check_consistent - check if sequence is consistent and advertise if not
180 * @cb: netlink callback structure that stores the sequence number
181 * @user_hdr: user header as returned from genlmsg_put()
182 * @family: generic netlink family
183 *
184 * Cf. nl_dump_check_consistent(), this just provides a wrapper to make it
185 * simpler to use with generic netlink.
186 */
187static inline void genl_dump_check_consistent(struct netlink_callback *cb,
188 void *user_hdr,
189 struct genl_family *family)
190{
191 nl_dump_check_consistent(cb, genlmsg_nlhdr(user_hdr, family));
192}
193
194/**
163 * genlmsg_put_reply - Add generic netlink header to a reply message 195 * genlmsg_put_reply - Add generic netlink header to a reply message
164 * @skb: socket buffer holding the message 196 * @skb: socket buffer holding the message
165 * @info: receiver info 197 * @info: receiver info