All of lore.kernel.org
 help / color / mirror / Atom feed
From: William Blough <devel@blough.us>
To: netfilter-devel@vger.kernel.org
Subject: [PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size
Date: Fri, 6 Jan 2023 14:25:23 -0500	[thread overview]
Message-ID: <Y7h1o0H+dvAz1vtZ@prometheus> (raw)

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


             reply	other threads:[~2023-01-06 19:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 19:25 William Blough [this message]
2023-01-11 17:27 ` [PATCH libnetfilter_conntrack 1/1] conntrack: Allow setting of netlink buffer size Pablo Neira Ayuso
2023-01-11 18:20   ` Bill Blough

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y7h1o0H+dvAz1vtZ@prometheus \
    --to=devel@blough.us \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.