diff options
author | Jakub Kicinski <kuba@kernel.org> | 2022-08-26 06:09:32 +0300 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2022-08-30 13:20:43 +0300 |
commit | 45dca15759643806660e9285e6af8a1ba3c76c82 (patch) | |
tree | 8103714a8db796c0ebe105ecb4fc9fd99c60bade /include/linux/netlink.h | |
parent | 690252f19f0e486abb8590b3a7a03d4e065d93d4 (diff) | |
download | linux-45dca15759643806660e9285e6af8a1ba3c76c82.tar.xz |
netlink: add helpers for extack attr presence checking
Being able to check attribute presence and set extack
if not on one line is handy, add helpers.
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'include/linux/netlink.h')
-rw-r--r-- | include/linux/netlink.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 1619221c415c..d51e041d2242 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) { |