diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2010-10-21 12:00:27 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2010-10-21 12:00:27 +0200 |
commit | 4eaebf5ef25f97cc6960da9f1a29b61737da8abd (patch) | |
tree | e28f06c05e5a722e3a2a6de4b42f54bc3d72a81a /examples/rtnl | |
parent | 781a9f058327730723525d3c4b85533920a00e9b (diff) | |
download | libmnl-4eaebf5ef25f97cc6960da9f1a29b61737da8abd.tar.gz libmnl-4eaebf5ef25f97cc6960da9f1a29b61737da8abd.zip |
src: define MNL_SOCKET_BUFFER_SIZE to 8192UL
Davem spotted during the Netfilter Workshop that user-space applications
should use 8KB buffers for recv(). I accidentally found that NFLOG is
not following this approach (in this case we're using 131072 bytes
messages), we have to document this.
Anyway, according to linux/netlink.h (and to complete this log message):
"skb should fit one page. This choice is good for headerless malloc.
But we should limit to 8K so that userspace does not have to
use enormous buffer sizes on recvmsg() calls just to avoid
MSG_TRUNC when PAGE_SIZE is very large."
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'examples/rtnl')
-rw-r--r-- | examples/rtnl/rtnl-link-dump.c | 2 | ||||
-rw-r--r-- | examples/rtnl/rtnl-link-dump2.c | 2 | ||||
-rw-r--r-- | examples/rtnl/rtnl-link-dump3.c | 2 | ||||
-rw-r--r-- | examples/rtnl/rtnl-link-event.c | 2 | ||||
-rw-r--r-- | examples/rtnl/rtnl-link-set.c | 2 | ||||
-rw-r--r-- | examples/rtnl/rtnl-route-add.c | 2 | ||||
-rw-r--r-- | examples/rtnl/rtnl-route-dump.c | 2 |
7 files changed, 7 insertions, 7 deletions
diff --git a/examples/rtnl/rtnl-link-dump.c b/examples/rtnl/rtnl-link-dump.c index 8bce803..d47d32e 100644 --- a/examples/rtnl/rtnl-link-dump.c +++ b/examples/rtnl/rtnl-link-dump.c @@ -69,7 +69,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) int main() { struct mnl_socket *nl; - char buf[getpagesize()]; + char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; struct rtgenmsg *rt; int ret; diff --git a/examples/rtnl/rtnl-link-dump2.c b/examples/rtnl/rtnl-link-dump2.c index ac3a6be..8189e7c 100644 --- a/examples/rtnl/rtnl-link-dump2.c +++ b/examples/rtnl/rtnl-link-dump2.c @@ -60,7 +60,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) int main() { struct mnl_socket *nl; - char buf[getpagesize()]; + char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; struct rtgenmsg *rt; int ret; diff --git a/examples/rtnl/rtnl-link-dump3.c b/examples/rtnl/rtnl-link-dump3.c index 6d06d7c..d8cacb4 100644 --- a/examples/rtnl/rtnl-link-dump3.c +++ b/examples/rtnl/rtnl-link-dump3.c @@ -60,7 +60,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) int main() { struct mnl_socket *nl; - char buf[getpagesize()]; + char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; struct rtgenmsg *rt; int ret; diff --git a/examples/rtnl/rtnl-link-event.c b/examples/rtnl/rtnl-link-event.c index aa51a1e..4aa11ef 100644 --- a/examples/rtnl/rtnl-link-event.c +++ b/examples/rtnl/rtnl-link-event.c @@ -68,7 +68,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) int main() { struct mnl_socket *nl; - char buf[getpagesize()]; + char buf[MNL_SOCKET_BUFFER_SIZE]; int ret; nl = mnl_socket_open(NETLINK_ROUTE); diff --git a/examples/rtnl/rtnl-link-set.c b/examples/rtnl/rtnl-link-set.c index d5cf9b1..00afe27 100644 --- a/examples/rtnl/rtnl-link-set.c +++ b/examples/rtnl/rtnl-link-set.c @@ -18,7 +18,7 @@ int main(int argc, char *argv[]) { struct mnl_socket *nl; - char buf[getpagesize()]; + char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; struct ifinfomsg *ifm; int ret; diff --git a/examples/rtnl/rtnl-route-add.c b/examples/rtnl/rtnl-route-add.c index 1f2d1a0..26105b3 100644 --- a/examples/rtnl/rtnl-route-add.c +++ b/examples/rtnl/rtnl-route-add.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) } struct mnl_socket *nl; - char buf[getpagesize()]; + char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; struct rtmsg *rtm; diff --git a/examples/rtnl/rtnl-route-dump.c b/examples/rtnl/rtnl-route-dump.c index 34c95cf..22395c4 100644 --- a/examples/rtnl/rtnl-route-dump.c +++ b/examples/rtnl/rtnl-route-dump.c @@ -199,7 +199,7 @@ static int data_cb(const struct nlmsghdr *nlh, void *data) int main() { struct mnl_socket *nl; - char buf[getpagesize()]; + char buf[MNL_SOCKET_BUFFER_SIZE]; struct nlmsghdr *nlh; struct rtmsg *rtm; int ret; |