[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220824045024.1107161-3-kuba@kernel.org>
Date: Tue, 23 Aug 2022 21:50:20 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, edumazet@...gle.com, pabeni@...hat.com,
mkubecek@...e.cz, johannes@...solutions.net,
Jakub Kicinski <kuba@...nel.org>
Subject: [PATCH net-next 2/6] netlink: add helper for extack attr presence checking
Being able to check attribute presence and set extack
if not on one line is handy, add a helper.
Signed-off-by: Jakub Kicinski <kuba@...nel.org>
---
include/linux/netlink.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 24f9fece7599..d20007ad7e26 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -139,6 +139,17 @@ struct netlink_ext_ack {
} \
} while (0)
+#define NL_REQ_ATTR_CHECK(extack, nest, tb, type) ({ \
+ struct nlattr **__tb = (tb); \
+ u32 __attr = (type); \
+ int __retval; \
+ \
+ __retval = !__tb[__attr]; \
+ if (__retval) \
+ NL_SET_ERR_ATTR_MISS((extack), (nest), __attr); \
+ __retval; \
+})
+
static inline void nl_set_extack_cookie_u64(struct netlink_ext_ack *extack,
u64 cookie)
{
--
2.37.2
Powered by blists - more mailing lists