include: add MNL_SOCKET_DUMP_SIZE definition
Pablo Neira Ayuso
maintainerPATCH 1/1 include: add MNL_SOCKET_DUMP_SIZE definition
Add definition to recommend a new buffer size for netlink dumps. Details are available here:
commit d35c99ff77ecb2eb239731b799386f3b3637a31e
Author: Eric Dumazet <[email protected]>
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 <[email protected]>
--- 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(-)
examples/netfilter/nfct-dump.c +1 -1
@@ -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;
examples/rtnl/rtnl-addr-dump.c +2 -2
@@ -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 ]);
examples/rtnl/rtnl-link-dump.c +2 -2
@@ -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 ;
examples/rtnl/rtnl-link-dump2.c +2 -2
@@ -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 ;
examples/rtnl/rtnl-link-dump3.c +2 -2
@@ -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 ;
examples/rtnl/rtnl-neigh-dump.c +2 -2
@@ -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 ]);
examples/rtnl/rtnl-route-dump.c +2 -2
@@ -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 ]);
include/libmnl/libmnl.h +1 -0
@@ -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 32768struct mnl_socket ;
Signature · 1 line
2.11.0