[iproute2-next,4/5] libnetlink: Add RTNL_HANDLE_F_STRICT_CHK flag
diff mbox series

Message ID 20190103043832.3748-5-dsahern@kernel.org
State Accepted
Delegated to: David Ahern
Headers show
Series
  • ip bridge: Updates to neigh and fdb dumps
Related show

Commit Message

David Ahern Jan. 3, 2019, 4:38 a.m. UTC
From: David Ahern <dsahern@gmail.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@mellanox.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
---
 include/libnetlink.h | 1 +
 lib/libnetlink.c     | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

Patch
diff mbox series

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)