[PATCH libmnl] include: add MNL_SOCKET_DUMP_SIZE definition

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add definition to recommend a new buffer size for netlink dumps.
Details are available here:

 commit d35c99ff77ecb2eb239731b799386f3b3637a31e
 Author: Eric Dumazet <edumazet@xxxxxxxxxx>
 Date:   Thu Oct 6 04:13:18 2016 +0900

    netlink: do not enter direct reclaim from netlink_dump()

 iproute2 is using 32 KBytes buffer in netlink dumps to speed up netlink
 dumps for a while. Let's recommend this buffer size through this new
 definitions.

Update examples too.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 examples/netfilter/nfct-dump.c  | 2 +-
 examples/rtnl/rtnl-addr-dump.c  | 4 ++--
 examples/rtnl/rtnl-link-dump.c  | 4 ++--
 examples/rtnl/rtnl-link-dump2.c | 4 ++--
 examples/rtnl/rtnl-link-dump3.c | 4 ++--
 examples/rtnl/rtnl-neigh-dump.c | 4 ++--
 examples/rtnl/rtnl-route-dump.c | 4 ++--
 include/libmnl/libmnl.h         | 1 +
 8 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/examples/netfilter/nfct-dump.c b/examples/netfilter/nfct-dump.c
index 114af616977b..cb8e52ccad0e 100644
--- a/examples/netfilter/nfct-dump.c
+++ b/examples/netfilter/nfct-dump.c
@@ -263,8 +263,8 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
 
 int main(void)
 {
+	char buf[MNL_SOCKET_DUMP_SIZE];
 	struct mnl_socket *nl;
-	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlmsghdr *nlh;
 	struct nfgenmsg *nfh;
 	uint32_t seq, portid;
diff --git a/examples/rtnl/rtnl-addr-dump.c b/examples/rtnl/rtnl-addr-dump.c
index b92b75f6eef3..675e9b0b5256 100644
--- a/examples/rtnl/rtnl-addr-dump.c
+++ b/examples/rtnl/rtnl-addr-dump.c
@@ -76,12 +76,12 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
 
 int main(int argc, char *argv[])
 {
+	char buf[MNL_SOCKET_DUMP_SIZE];
+	unsigned int seq, portid;
 	struct mnl_socket *nl;
-	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlmsghdr *nlh;
 	struct rtgenmsg *rt;
 	int ret;
-	unsigned int seq, portid;
 
 	if (argc != 2) {
 		fprintf(stderr, "Usage: %s <inet|inet6>\n", argv[0]);
diff --git a/examples/rtnl/rtnl-link-dump.c b/examples/rtnl/rtnl-link-dump.c
index f5d63125c60c..031346fbf61a 100644
--- a/examples/rtnl/rtnl-link-dump.c
+++ b/examples/rtnl/rtnl-link-dump.c
@@ -81,12 +81,12 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
 
 int main(void)
 {
+	char buf[MNL_SOCKET_DUMP_SIZE];
+	unsigned int seq, portid;
 	struct mnl_socket *nl;
-	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlmsghdr *nlh;
 	struct rtgenmsg *rt;
 	int ret;
-	unsigned int seq, portid;
 
 	nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type	= RTM_GETLINK;
diff --git a/examples/rtnl/rtnl-link-dump2.c b/examples/rtnl/rtnl-link-dump2.c
index b3ca3fa6be4b..890e51ad43d0 100644
--- a/examples/rtnl/rtnl-link-dump2.c
+++ b/examples/rtnl/rtnl-link-dump2.c
@@ -54,12 +54,12 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
 
 int main(void)
 {
+	char buf[MNL_SOCKET_DUMP_SIZE];
+	unsigned int seq, portid;
 	struct mnl_socket *nl;
-	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlmsghdr *nlh;
 	struct rtgenmsg *rt;
 	int ret;
-	unsigned int seq, portid;
 
 	nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type	= RTM_GETLINK;
diff --git a/examples/rtnl/rtnl-link-dump3.c b/examples/rtnl/rtnl-link-dump3.c
index 2521214ed597..a381da1bd697 100644
--- a/examples/rtnl/rtnl-link-dump3.c
+++ b/examples/rtnl/rtnl-link-dump3.c
@@ -54,12 +54,12 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
 
 int main(void)
 {
+	char buf[MNL_SOCKET_DUMP_SIZE];
+	unsigned int seq, portid;
 	struct mnl_socket *nl;
-	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlmsghdr *nlh;
 	struct rtgenmsg *rt;
 	int ret;
-	unsigned int seq, portid;
 
 	nlh = mnl_nlmsg_put_header(buf);
 	nlh->nlmsg_type	= RTM_GETLINK;
diff --git a/examples/rtnl/rtnl-neigh-dump.c b/examples/rtnl/rtnl-neigh-dump.c
index f4d500078388..786e31d8ded3 100644
--- a/examples/rtnl/rtnl-neigh-dump.c
+++ b/examples/rtnl/rtnl-neigh-dump.c
@@ -99,12 +99,12 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
 
 int main(int argc, char *argv[])
 {
+	char buf[MNL_SOCKET_DUMP_SIZE];
+	unsigned int seq, portid;
 	struct mnl_socket *nl;
-	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlmsghdr *nlh;
 	struct rtgenmsg *rt;
 	int ret;
-	unsigned int seq, portid;
 
 	if (argc != 2) {
 		fprintf(stderr, "Usage: %s <inet|inet6>\n", argv[0]);
diff --git a/examples/rtnl/rtnl-route-dump.c b/examples/rtnl/rtnl-route-dump.c
index 17da80b90d1d..02ac6b20c644 100644
--- a/examples/rtnl/rtnl-route-dump.c
+++ b/examples/rtnl/rtnl-route-dump.c
@@ -298,12 +298,12 @@ static int data_cb(const struct nlmsghdr *nlh, void *data)
 
 int main(int argc, char *argv[])
 {
+	char buf[MNL_SOCKET_DUMP_SIZE];
+	unsigned int seq, portid;
 	struct mnl_socket *nl;
-	char buf[MNL_SOCKET_BUFFER_SIZE];
 	struct nlmsghdr *nlh;
 	struct rtmsg *rtm;
 	int ret;
-	unsigned int seq, portid;
 
 	if (argc != 2) {
 		fprintf(stderr, "Usage: %s <inet|inet6>\n", argv[0]);
diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index 0331da71775f..4bd0b92e8742 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -18,6 +18,7 @@ extern "C" {
 
 #define MNL_SOCKET_AUTOPID	0
 #define MNL_SOCKET_BUFFER_SIZE (sysconf(_SC_PAGESIZE) < 8192L ? sysconf(_SC_PAGESIZE) : 8192L)
+#define MNL_SOCKET_DUMP_SIZE	32768
 
 struct mnl_socket;
 
-- 
2.11.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux