[PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size

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

 



ENOBUFS is returned in the case that the nfnetlink socket buffer is
exhausted.  The function nfnl_rcvbufsize is provided by libnfnetlink
to set the buffer size in order to handle this error, however
libnetfilter_conntrack does not expose this function for the underlying
netlink socket.

Add nfct_rcvbufsiz function to allow setting of buffer size for netlink
socket.

Signed-off-by: William Blough <devel@xxxxxxxxx>
---
 .../libnetfilter_conntrack.h                   |  3 +++
 src/conntrack/api.c                            | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/include/libnetfilter_conntrack/libnetfilter_conntrack.h b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
index e229472..d496307 100644
--- a/include/libnetfilter_conntrack/libnetfilter_conntrack.h
+++ b/include/libnetfilter_conntrack/libnetfilter_conntrack.h
@@ -591,6 +591,9 @@ extern int nfct_nlmsg_build_filter(struct nlmsghdr *nlh, const struct nfct_filte
 extern int nfct_nlmsg_parse(const struct nlmsghdr *nlh, struct nf_conntrack *ct);
 extern int nfct_payload_parse(const void *payload, size_t payload_len, uint16_t l3num, struct nf_conntrack *ct);
 
+/* set size of netlink socket buffer */
+unsigned int nfct_rcvbufsize(struct nfct_handle *h, unsigned int size);
+
 /*
  * NEW expectation API
  */
diff --git a/src/conntrack/api.c b/src/conntrack/api.c
index 7f72d07..699f560 100644
--- a/src/conntrack/api.c
+++ b/src/conntrack/api.c
@@ -350,6 +350,24 @@ void nfct_callback_unregister2(struct nfct_handle *h)
 	h->nfnl_cb_ct.attr_count = 0;
 }
 
+/**
+ * nfct_rcvbufsiz - set size of netlink socket buffer
+ * \param h library handler
+ * \param size size of the buffer we want to set
+ *
+ * This function sets the new size of the the netlink socket buffer.  Use this
+ * setting to increase the socket buffer size if your system is reporting
+ * ENOBUFS errors.
+ *
+ * This function returns the new size of the netlink socket buffer.
+ */
+unsigned int nfct_rcvbufsiz(struct nfct_handle *h, unsigned int size)
+{
+	assert(h != NULL);
+
+	return nfnl_rcvbufsiz(h->nfnlh, size);
+}
+
 /**
  * @}
  */
-- 
2.30.2




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

  Powered by Linux