netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size
@ 2023-01-06 19:25 William Blough
  2023-01-11 17:27 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: William Blough @ 2023-01-06 19:25 UTC (permalink / raw)
  To: netfilter-devel

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@blough.us>
---
 .../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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size
  2023-01-06 19:25 [PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size William Blough
@ 2023-01-11 17:27 ` Pablo Neira Ayuso
  2023-01-11 18:20   ` Bill Blough
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2023-01-11 17:27 UTC (permalink / raw)
  To: William Blough; +Cc: netfilter-devel

On Fri, Jan 06, 2023 at 02:25:23PM -0500, William Blough wrote:
> 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.

Thanks for your patch.

There is already nfct_fd() and you can use setsockopt() on it.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size
  2023-01-11 17:27 ` Pablo Neira Ayuso
@ 2023-01-11 18:20   ` Bill Blough
  0 siblings, 0 replies; 3+ messages in thread
From: Bill Blough @ 2023-01-11 18:20 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

On Wed, Jan 11, 2023 at 06:27:21PM +0100, Pablo Neira Ayuso wrote:
> On Fri, Jan 06, 2023 at 02:25:23PM -0500, William Blough wrote:
> > Add nfct_rcvbufsiz function to allow setting of buffer size for netlink
> > socket.
> 
> Thanks for your patch.
> 
> There is already nfct_fd() and you can use setsockopt() on it.

Ah, apparently I overlooked that.  Thanks.

Best regards,
Bill


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-11 18:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-06 19:25 [PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size William Blough
2023-01-11 17:27 ` Pablo Neira Ayuso
2023-01-11 18:20   ` Bill Blough

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).