naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone
Blob Blame History Raw
From 81112a9fc77aa269f3fa7cde80facb9b9056854f Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Wed, 17 Feb 2016 14:03:59 +0100
Subject: [PATCH] libnetlink: introduce nc_flags

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1291825
Upstream Status: commit 8e72880f6bfa3
Conflicts: Changes in context and removed code due to missing commit
           892e21248cfdb ("remove unnecessary extern")

commit 8e72880f6bfa39f439b9c4a88eb84b635b991687
Author: Phil Sutter <phil@nwl.cc>
Date:   Tue Nov 24 15:31:01 2015 +0100

    libnetlink: introduce nc_flags

    Allow for a filter to ignore certain nlmsg_flags.

    Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 include/libnetlink.h |  8 ++++++--
 lib/libnetlink.c     | 10 ++++++----
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/libnetlink.h b/include/libnetlink.h
index bd9bde0..058dc64 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -58,12 +58,16 @@ struct rtnl_dump_filter_arg
 {
 	rtnl_filter_t filter;
 	void *arg1;
+	__u16 nc_flags;
 };
 
 extern int rtnl_dump_filter_l(struct rtnl_handle *rth,
 			      const struct rtnl_dump_filter_arg *arg);
-extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
-			    void *arg);
+int rtnl_dump_filter_nc(struct rtnl_handle *rth,
+			rtnl_filter_t filter,
+			void *arg, __u16 nc_flags);
+#define rtnl_dump_filter(rth, filter, arg) \
+	rtnl_dump_filter_nc(rth, filter, arg, 0)
 extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
 		     unsigned groups, struct nlmsghdr *answer)
 	__attribute__((warn_unused_result));
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 424a5b6..95675be 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -234,6 +234,8 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
 			while (NLMSG_OK(h, msglen)) {
 				int err = 0;
 
+				h->nlmsg_flags &= ~a->nc_flags;
+
 				if (nladdr.nl_pid != 0 ||
 				    h->nlmsg_pid != rth->local.nl_pid ||
 				    h->nlmsg_seq != rth->dump)
@@ -292,13 +294,13 @@ skip_it:
 	}
 }
 
-int rtnl_dump_filter(struct rtnl_handle *rth,
+int rtnl_dump_filter_nc(struct rtnl_handle *rth,
 		     rtnl_filter_t filter,
-		     void *arg1)
+		     void *arg1, __u16 nc_flags)
 {
 	const struct rtnl_dump_filter_arg a[2] = {
-		{ .filter = filter, .arg1 = arg1, },
-		{ .filter = NULL,   .arg1 = NULL, },
+		{ .filter = filter, .arg1 = arg1, .nc_flags = nc_flags, },
+		{ .filter = NULL,   .arg1 = NULL, .nc_flags = 0, },
 	};
 
 	return rtnl_dump_filter_l(rth, a);
-- 
1.8.3.1