Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mt fixes/v6 #9365

Closed
wants to merge 13 commits into from
Closed
23 changes: 23 additions & 0 deletions doc/userguide/configuration/multi-tenant.rst
Expand Up @@ -217,6 +217,29 @@ Tenants can be mapped to vlan ids.
The registration of tenant and tenant handlers can be done on a
running engine.

Reloads
~~~~~~~

Reloading all tenants:

``reload-tenants``

::

reload-tenants

Reloading a single tenant:

``reload-tenant <tenant id> [yaml path]``

::

reload-tenant 1 tenant-1.yaml
reload-tenant 5

The ``[yaml path]`` is optional. If it isn't provided, the original path of
the tenant will be used during the reload.

Eve JSON output
---------------

Expand Down
10 changes: 8 additions & 2 deletions doc/userguide/partials/commands-sc.rst
Expand Up @@ -82,9 +82,15 @@

Register tenant with a particular ID and filename.

.. describe:: reload-tenant <id> <filename>
.. describe:: reload-tenant <id> [filename]

Reload a tenant with specified ID and filename.
Reload a tenant with specified ID. A filename to a tenant yaml can be
specified. If it is omitted, the original yaml that was used to load
/ last reload the tenant is used.

.. describe:: reload-tenants

Reload all registered tenants by reloading their yaml.

.. describe:: unregister-tenant <id>

Expand Down
2 changes: 1 addition & 1 deletion python/suricata/sc/specs.py
Expand Up @@ -116,7 +116,7 @@
},
{
"name": "filename",
"required": 1,
"required": 0,
},
],
"add-hostbit": [
Expand Down
1 change: 1 addition & 0 deletions python/suricata/sc/suricatasc.py
Expand Up @@ -94,6 +94,7 @@ def __init__(self, sck_path, verbose=False):
"pcap-last-processed",
"pcap-interrupt",
"iface-list",
"reload-tenants",
]
self.fn_commands = [
"pcap-file",
Expand Down
2 changes: 1 addition & 1 deletion src/detect-engine-build.c
Expand Up @@ -2035,7 +2035,7 @@ int SigGroupBuild(DetectEngineCtx *de_ctx)
ThresholdHashAllocate(de_ctx);

if (!DetectEngineMultiTenantEnabled()) {
VarNameStoreActivateStaging();
VarNameStoreActivate();
}
return 0;
}
Expand Down
5 changes: 3 additions & 2 deletions src/detect-engine-loader.c
Expand Up @@ -401,7 +401,7 @@ static int num_loaders = NLOADERS;

/** \param loader -1 for auto select
* \retval loader_id or negative in case of error */
int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx)
int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx, LoaderFreeFunc FreeFunc)
{
if (loader_id == -1) {
loader_id = cur_loader;
Expand All @@ -421,6 +421,7 @@ int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx)

t->Func = Func;
t->ctx = func_ctx;
t->FreeFunc = FreeFunc;

SCMutexLock(&loader->m);
TAILQ_INSERT_TAIL(&loader->task_list, t, next);
Expand Down Expand Up @@ -596,7 +597,7 @@ static TmEcode DetectLoader(ThreadVars *th_v, void *thread_data)
int r = task->Func(task->ctx, ftd->instance);
loader->result |= r;
TAILQ_REMOVE(&loader->task_list, task, next);
SCFree(task->ctx);
task->FreeFunc(task->ctx);
SCFree(task);
}

Expand Down
4 changes: 3 additions & 1 deletion src/detect-engine-loader.h
Expand Up @@ -32,10 +32,12 @@
* \param loader_id id of the loader that executed the task
*/
typedef int (*LoaderFunc)(void *ctx, int loader_id);
typedef void (*LoaderFreeFunc)(void *ctx);

typedef struct DetectLoaderTask_ {
LoaderFunc Func;
void *ctx;
LoaderFreeFunc FreeFunc;
TAILQ_ENTRY(DetectLoaderTask_) next;
} DetectLoaderTask;

Expand All @@ -46,7 +48,7 @@ typedef struct DetectLoaderControl_ {
TAILQ_HEAD(, DetectLoaderTask_) task_list;
} DetectLoaderControl;

int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx);
int DetectLoaderQueueTask(int loader_id, LoaderFunc Func, void *func_ctx, LoaderFreeFunc FreeFunc);
int DetectLoadersSync(void);
void DetectLoadersInit(void);

Expand Down