|
|
049c96 |
From 81112a9fc77aa269f3fa7cde80facb9b9056854f Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Wed, 17 Feb 2016 14:03:59 +0100
|
|
|
049c96 |
Subject: [PATCH] libnetlink: introduce nc_flags
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1291825
|
|
|
049c96 |
Upstream Status: commit 8e72880f6bfa3
|
|
|
049c96 |
Conflicts: Changes in context and removed code due to missing commit
|
|
|
049c96 |
892e21248cfdb ("remove unnecessary extern")
|
|
|
049c96 |
|
|
|
049c96 |
commit 8e72880f6bfa39f439b9c4a88eb84b635b991687
|
|
|
049c96 |
Author: Phil Sutter <phil@nwl.cc>
|
|
|
049c96 |
Date: Tue Nov 24 15:31:01 2015 +0100
|
|
|
049c96 |
|
|
|
049c96 |
libnetlink: introduce nc_flags
|
|
|
049c96 |
|
|
|
049c96 |
Allow for a filter to ignore certain nlmsg_flags.
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
049c96 |
---
|
|
|
049c96 |
include/libnetlink.h | 8 ++++++--
|
|
|
049c96 |
lib/libnetlink.c | 10 ++++++----
|
|
|
049c96 |
2 files changed, 12 insertions(+), 6 deletions(-)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/include/libnetlink.h b/include/libnetlink.h
|
|
|
049c96 |
index bd9bde0..058dc64 100644
|
|
|
049c96 |
--- a/include/libnetlink.h
|
|
|
049c96 |
+++ b/include/libnetlink.h
|
|
|
049c96 |
@@ -58,12 +58,16 @@ struct rtnl_dump_filter_arg
|
|
|
049c96 |
{
|
|
|
049c96 |
rtnl_filter_t filter;
|
|
|
049c96 |
void *arg1;
|
|
|
049c96 |
+ __u16 nc_flags;
|
|
|
049c96 |
};
|
|
|
049c96 |
|
|
|
049c96 |
extern int rtnl_dump_filter_l(struct rtnl_handle *rth,
|
|
|
049c96 |
const struct rtnl_dump_filter_arg *arg);
|
|
|
049c96 |
-extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
|
|
|
049c96 |
- void *arg);
|
|
|
049c96 |
+int rtnl_dump_filter_nc(struct rtnl_handle *rth,
|
|
|
049c96 |
+ rtnl_filter_t filter,
|
|
|
049c96 |
+ void *arg, __u16 nc_flags);
|
|
|
049c96 |
+#define rtnl_dump_filter(rth, filter, arg) \
|
|
|
049c96 |
+ rtnl_dump_filter_nc(rth, filter, arg, 0)
|
|
|
049c96 |
extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
|
|
|
049c96 |
unsigned groups, struct nlmsghdr *answer)
|
|
|
049c96 |
__attribute__((warn_unused_result));
|
|
|
049c96 |
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
|
|
|
049c96 |
index 424a5b6..95675be 100644
|
|
|
049c96 |
--- a/lib/libnetlink.c
|
|
|
049c96 |
+++ b/lib/libnetlink.c
|
|
|
049c96 |
@@ -234,6 +234,8 @@ int rtnl_dump_filter_l(struct rtnl_handle *rth,
|
|
|
049c96 |
while (NLMSG_OK(h, msglen)) {
|
|
|
049c96 |
int err = 0;
|
|
|
049c96 |
|
|
|
049c96 |
+ h->nlmsg_flags &= ~a->nc_flags;
|
|
|
049c96 |
+
|
|
|
049c96 |
if (nladdr.nl_pid != 0 ||
|
|
|
049c96 |
h->nlmsg_pid != rth->local.nl_pid ||
|
|
|
049c96 |
h->nlmsg_seq != rth->dump)
|
|
|
049c96 |
@@ -292,13 +294,13 @@ skip_it:
|
|
|
049c96 |
}
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
-int rtnl_dump_filter(struct rtnl_handle *rth,
|
|
|
049c96 |
+int rtnl_dump_filter_nc(struct rtnl_handle *rth,
|
|
|
049c96 |
rtnl_filter_t filter,
|
|
|
049c96 |
- void *arg1)
|
|
|
049c96 |
+ void *arg1, __u16 nc_flags)
|
|
|
049c96 |
{
|
|
|
049c96 |
const struct rtnl_dump_filter_arg a[2] = {
|
|
|
049c96 |
- { .filter = filter, .arg1 = arg1, },
|
|
|
049c96 |
- { .filter = NULL, .arg1 = NULL, },
|
|
|
049c96 |
+ { .filter = filter, .arg1 = arg1, .nc_flags = nc_flags, },
|
|
|
049c96 |
+ { .filter = NULL, .arg1 = NULL, .nc_flags = 0, },
|
|
|
049c96 |
};
|
|
|
049c96 |
|
|
|
049c96 |
return rtnl_dump_filter_l(rth, a);
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|