[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190103043832.3748-5-dsahern@kernel.org>
Date: Wed, 2 Jan 2019 20:38:31 -0800
From: David Ahern <dsahern@...nel.org>
To: netdev@...r.kernel.org
Cc: idosch@...lanox.com, stephen@...workplumber.org,
David Ahern <dsahern@...il.com>
Subject: [PATCH iproute2-next 4/5] libnetlink: Add RTNL_HANDLE_F_STRICT_CHK flag
From: David Ahern <dsahern@...il.com>
Add RTNL_HANDLE_F_STRICT_CHK flag and set in rth flags to let know
commands know if the kernel supports strict checking.
Extracted from patch from Ido to fix filtering with strict checking
enabled.
Cc: Ido Schimmel <idosch@...lanox.com>
Signed-off-by: David Ahern <dsahern@...il.com>
---
include/libnetlink.h | 1 +
lib/libnetlink.c | 7 +++++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/libnetlink.h b/include/libnetlink.h
index 148951510d1e..0854d6ad2fab 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -23,6 +23,7 @@ struct rtnl_handle {
FILE *dump_fp;
#define RTNL_HANDLE_F_LISTEN_ALL_NSID 0x01
#define RTNL_HANDLE_F_SUPPRESS_NLERR 0x02
+#define RTNL_HANDLE_F_STRICT_CHK 0x04
int flags;
};
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index 19318b445266..600e9a2476ba 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -166,8 +166,11 @@ void rtnl_set_strict_dump(struct rtnl_handle *rth)
{
int one = 1;
- setsockopt(rth->fd, SOL_NETLINK, NETLINK_GET_STRICT_CHK,
- &one, sizeof(one));
+ if (setsockopt(rth->fd, SOL_NETLINK, NETLINK_GET_STRICT_CHK,
+ &one, sizeof(one)) < 0)
+ return;
+
+ rth->flags |= RTNL_HANDLE_F_STRICT_CHK;
}
void rtnl_close(struct rtnl_handle *rth)
--
2.11.0
Powered by blists - more mailing lists