]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
datasets: add dump via unix socket
authorEric Leblond <eric@regit.org>
Mon, 28 Dec 2020 23:43:01 +0000 (00:43 +0100)
committerVictor Julien <vjulien@oisf.net>
Thu, 27 Oct 2022 07:44:20 +0000 (09:44 +0200)
This patch adds a dataset-dump command to the list of unix socket
commands. Implementation is not optimal as we are locking the
datasets when doing the dump. But if we consider that the current
alternative from an implementation point of view is to stop Suricata
then this is far better than current state.

Ticket: #5184

src/runmode-unix-socket.c
src/runmode-unix-socket.h
src/unix-manager.c

index e3180604759bb1ed05011493dadb069206f17eef..c302519464f07f1e3c8ce1fb4f3128aa11615e40 100644 (file)
@@ -763,6 +763,15 @@ TmEcode UnixSocketDatasetRemove(json_t *cmd, json_t* answer, void *data)
     }
 }
 
+TmEcode UnixSocketDatasetDump(json_t *cmd, json_t *answer, void *data)
+{
+    SCEnter();
+    SCLogDebug("Going to dump datasets");
+    DatasetsSave();
+    json_object_set_new(answer, "message", json_string("datasets dump done"));
+    SCReturnInt(TM_ECODE_OK);
+}
+
 /**
  * \brief Command to add a tenant handler
  *
index ded10349f084ed7210ae03320e42bdff4cfcd312..31c59ee2f5cb3dd9f9781a7b1fa6bd51911c49ae 100644 (file)
@@ -35,6 +35,7 @@ float MemcapsGetPressure(void);
 #ifdef BUILD_UNIX_SOCKET
 TmEcode UnixSocketDatasetAdd(json_t *cmd, json_t* answer, void *data);
 TmEcode UnixSocketDatasetRemove(json_t *cmd, json_t* answer, void *data);
+TmEcode UnixSocketDatasetDump(json_t *cmd, json_t *answer, void *data);
 TmEcode UnixSocketRegisterTenantHandler(json_t *cmd, json_t* answer, void *data);
 TmEcode UnixSocketUnregisterTenantHandler(json_t *cmd, json_t* answer, void *data);
 TmEcode UnixSocketRegisterTenant(json_t *cmd, json_t* answer, void *data);
index 1d408e4af2beac3953c69d0effc65f2fa4f6275b..4d0203d9334e22653462b350c1236f72a733c44e 100644 (file)
@@ -1088,6 +1088,7 @@ int UnixManagerInit(void)
     UnixManagerRegisterCommand("dataset-remove", UnixSocketDatasetRemove, &command, UNIX_CMD_TAKE_ARGS);
     UnixManagerRegisterCommand(
             "get-flow-stats-by-id", UnixSocketGetFlowStatsById, &command, UNIX_CMD_TAKE_ARGS);
+    UnixManagerRegisterCommand("dataset-dump", UnixSocketDatasetDump, NULL, 0);
 
     return 0;
 }