summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2010-10-21 12:00:27 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2010-10-21 12:00:27 +0200
commit4eaebf5ef25f97cc6960da9f1a29b61737da8abd (patch)
treee28f06c05e5a722e3a2a6de4b42f54bc3d72a81a /src
parent781a9f058327730723525d3c4b85533920a00e9b (diff)
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 'src')
-rw-r--r--src/socket.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/socket.c b/src/socket.c
index 08ac138..53f98c7 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -186,8 +186,11 @@ int mnl_socket_sendto(const struct mnl_socket *nl, const void *buf, size_t len)
*
* On error, it returns -1 and errno is appropriately set. If errno is set
* to ENOSPC, it means that the buffer that you have passed to store the
- * netlink message is small so you have received a truncated message. Make
- * sure your program set a buffer big enough to store the netlink message.
+ * netlink message is too small so you have received a truncated message.
+ * To avoid this you have to allocate a buffer of MNL_SOCKET_BUFFER_SIZE
+ * (which is 8KB, see linux/netlink.h for more information). Using this
+ * buffer size ensures that your buffer is big enough to store the netlink
+ * message without truncating it.
*/
int mnl_socket_recvfrom(const struct mnl_socket *nl, void *buf, size_t bufsiz)
{