* [PATCH v2 0/1] Reusing modifier socket for bulk ct loads
@ 2022-06-09 20:41 Mikhail Sennikovsky
2022-06-09 20:41 ` [PATCH v2 1/1] conntrack: use same modifier socket for bulk ops Mikhail Sennikovsky
0 siblings, 1 reply; 3+ messages in thread
From: Mikhail Sennikovsky @ 2022-06-09 20:41 UTC (permalink / raw)
To: netfilter-devel, pablo, mikhail.sennikovsky; +Cc: Mikhail Sennikovsky
Hi Pablo & all,
Here is the updated patch to use the same mnl modifier socket
for all operation in bulk ct loads, with removed
nfct_mnl_socket.events field as we discussed.
Any further feedback/suggestions are welcome.
Regards,
Mikhail
Mikhail Sennikovsky (1):
conntrack: use same modifier socket for bulk ops
src/conntrack.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v2 1/1] conntrack: use same modifier socket for bulk ops
2022-06-09 20:41 [PATCH v2 0/1] Reusing modifier socket for bulk ct loads Mikhail Sennikovsky
@ 2022-06-09 20:41 ` Mikhail Sennikovsky
2022-06-20 14:42 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Mikhail Sennikovsky @ 2022-06-09 20:41 UTC (permalink / raw)
To: netfilter-devel, pablo, mikhail.sennikovsky; +Cc: Mikhail Sennikovsky
For bulk ct entry loads (with -R option) reusing the same mnl
modifier socket for all entries results in reduction of entries
creation time, which becomes especially signifficant when loading
tens of thouthand of entries.
Signed-off-by: Mikhail Sennikovsky <mikhail.sennikovskii@ionos.com>
---
src/conntrack.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/src/conntrack.c b/src/conntrack.c
index 27e2bea..6022d19 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -2470,6 +2470,23 @@ static void nfct_mnl_socket_close(const struct nfct_mnl_socket *sock)
mnl_socket_close(sock->mnl);
}
+static int nfct_mnl_socket_check_open(struct nfct_mnl_socket *socket,
+ unsigned int events)
+{
+ if (socket->mnl != NULL)
+ return 0;
+
+ return nfct_mnl_socket_open(socket, events);
+}
+
+static void nfct_mnl_socket_check_close(struct nfct_mnl_socket *sock)
+{
+ if (sock->mnl) {
+ nfct_mnl_socket_close(sock);
+ memset(sock, 0, sizeof(*sock));
+ }
+}
+
static int __nfct_mnl_dump(struct nfct_mnl_socket *sock,
const struct nlmsghdr *nlh, mnl_cb_t cb, void *data)
{
@@ -3383,19 +3400,17 @@ static int do_command_ct(const char *progname, struct ct_cmd *cmd,
break;
case CT_UPDATE:
- if (nfct_mnl_socket_open(modifier_sock, 0) < 0)
+ if (nfct_mnl_socket_check_open(modifier_sock, 0) < 0)
exit_error(OTHER_PROBLEM, "Can't open handler");
nfct_filter_init(cmd);
res = nfct_mnl_dump(sock, NFNL_SUBSYS_CTNETLINK,
IPCTNL_MSG_CT_GET, mnl_nfct_update_cb,
cmd, NULL);
-
- nfct_mnl_socket_close(modifier_sock);
break;
case CT_DELETE:
- if (nfct_mnl_socket_open(modifier_sock, 0) < 0)
+ if (nfct_mnl_socket_check_open(modifier_sock, 0) < 0)
exit_error(OTHER_PROBLEM, "Can't open handler");
nfct_filter_init(cmd);
@@ -3418,8 +3433,6 @@ static int do_command_ct(const char *progname, struct ct_cmd *cmd,
cmd, filter_dump);
nfct_filter_dump_destroy(filter_dump);
-
- nfct_mnl_socket_close(modifier_sock);
break;
case EXP_DELETE:
@@ -3857,6 +3870,7 @@ static const char *ct_unsupp_cmd_file(const struct ct_cmd *cmd)
int main(int argc, char *argv[])
{
struct nfct_mnl_socket *sock = &_sock;
+ struct nfct_mnl_socket *modifier_sock = &_modifier_sock;
struct ct_cmd *cmd, *next;
LIST_HEAD(cmd_list);
int res = 0;
@@ -3900,6 +3914,7 @@ int main(int argc, char *argv[])
free(cmd);
}
nfct_mnl_socket_close(sock);
+ nfct_mnl_socket_check_close(modifier_sock);
return res < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
}
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] conntrack: use same modifier socket for bulk ops
2022-06-09 20:41 ` [PATCH v2 1/1] conntrack: use same modifier socket for bulk ops Mikhail Sennikovsky
@ 2022-06-20 14:42 ` Pablo Neira Ayuso
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2022-06-20 14:42 UTC (permalink / raw)
To: Mikhail Sennikovsky; +Cc: netfilter-devel, mikhail.sennikovsky
On Thu, Jun 09, 2022 at 10:41:42PM +0200, Mikhail Sennikovsky wrote:
> For bulk ct entry loads (with -R option) reusing the same mnl
> modifier socket for all entries results in reduction of entries
> creation time, which becomes especially signifficant when loading
> tens of thouthand of entries.
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-20 15:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 20:41 [PATCH v2 0/1] Reusing modifier socket for bulk ct loads Mikhail Sennikovsky
2022-06-09 20:41 ` [PATCH v2 1/1] conntrack: use same modifier socket for bulk ops Mikhail Sennikovsky
2022-06-20 14:42 ` Pablo Neira Ayuso
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.