]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
libnetlink: introduce nc_flags
authorPhil Sutter <phil@nwl.cc>
Tue, 24 Nov 2015 14:31:01 +0000 (15:31 +0100)
committerStephen Hemminger <shemming@brocade.com>
Sun, 29 Nov 2015 19:47:29 +0000 (11:47 -0800)
Allow for a filter to ignore certain nlmsg_flags.

Signed-off-by: Phil Sutter <phil@nwl.cc>
include/libnetlink.h
lib/libnetlink.c

index 2280c39c670a4797672ec3d08b60b4476a13cbb6..431189e20d48e50ef9d65463cc8bd9a14c04699d 100644 (file)
@@ -60,11 +60,16 @@ struct rtnl_dump_filter_arg
 {
        rtnl_filter_t filter;
        void *arg1;
+       __u16 nc_flags;
 };
 
 int rtnl_dump_filter_l(struct rtnl_handle *rth,
                              const struct rtnl_dump_filter_arg *arg);
-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)
 int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
              struct nlmsghdr *answer, size_t len)
        __attribute__((warn_unused_result));
index 09b0e911f9185946a9ecdb4367cda5db48bd034e..922ec2d9f8722283c3886cd6cfaaffa6e0b110ff 100644 (file)
@@ -259,6 +259,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)
@@ -317,13 +319,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);