linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netlink: add nl_set_extack_cookie_u64()
@ 2018-08-23  8:48 Johannes Berg
  2018-08-23 15:45 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Berg @ 2018-08-23  8:48 UTC (permalink / raw)
  To: linux-wireless, netdev; +Cc: Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

Add a helper function nl_set_extack_cookie_u64() to use a u64 as
the netlink extended ACK cookie, to avoid having to open-code it
in any users of the cookie.

A u64 should be sufficient for most subsystems though we allow
for up to 20 bytes right now. This also matches the cookies in
nl80211 where I intend to use this.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 include/linux/netlink.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 71f121b66ca8..dc3c21dc4ba2 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -110,6 +110,15 @@ struct netlink_ext_ack {
 	}						\
 } while (0)
 
+static inline void nl_set_extack_cookie_u64(struct netlink_ext_ack *extack,
+					    u64 cookie)
+{
+	u64 __cookie = cookie;
+
+	memcpy(extack->cookie, &__cookie, sizeof(__cookie));
+	extack->cookie_len = sizeof(__cookie);
+}
+
 extern void netlink_kernel_release(struct sock *sk);
 extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups);
 extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-23 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23  8:48 [PATCH] netlink: add nl_set_extack_cookie_u64() Johannes Berg
2018-08-23 15:45 ` David Miller
2018-08-23 16:39   ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).