All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] libnetlink: add rtattr_for_each_nested() iteration macro
@ 2020-08-19 10:29 Johannes Berg
  2020-08-19 10:29 ` [PATCH 2/2] genl: ctrl: support dumping netlink policy Johannes Berg
  0 siblings, 1 reply; 5+ messages in thread
From: Johannes Berg @ 2020-08-19 10:29 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

This is useful for iterating elements in a nested attribute,
if they're not parsed with a strict length limit or such.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
---
 include/libnetlink.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index e27516f7648f..0d4a9f29afbd 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -284,4 +284,9 @@ int rtnl_from_file(FILE *, rtnl_listen_filter_t handler,
  * messages from dump file */
 #define NLMSG_TSTAMP	15
 
+#define rtattr_for_each_nested(attr, nest) \
+	for ((attr) = (void *)RTA_DATA(nest); \
+	     RTA_OK(attr, RTA_PAYLOAD(nest) - ((char *)(attr) - (char *)RTA_DATA((nest)))); \
+	     (attr) = RTA_TAIL((attr)))
+
 #endif /* __LIBNETLINK_H__ */
-- 
2.26.2


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

end of thread, other threads:[~2020-08-24 16:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-19 10:29 [PATCH 1/2] libnetlink: add rtattr_for_each_nested() iteration macro Johannes Berg
2020-08-19 10:29 ` [PATCH 2/2] genl: ctrl: support dumping netlink policy Johannes Berg
2020-08-24  1:45   ` David Ahern
2020-08-24  7:54     ` Johannes Berg
2020-08-24 16:54       ` David Ahern

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.