firewall-util: introduce context structure
for planned nft backend we have three choices: - open/close a new nfnetlink socket for every operation - keep a nfnetlink socket open internally - expose a opaque fw_ctx and stash all internal data here. Originally I opted for the 2nd option, but during review it was suggested to avoid static storage duration because of perceived problems with threaded applications. This adds fw_ctx and new/free functions, then converts the existing api and nspawn and networkd to use it.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "capability-util.h"
|
||||
#include "daemon-util.h"
|
||||
#include "firewall-util.h"
|
||||
#include "main-func.h"
|
||||
#include "mkdir.h"
|
||||
#include "networkd-conf.h"
|
||||
@@ -92,6 +93,10 @@ static int run(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = fw_ctx_new(&m->fw_ctx);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Could not initialize firewall, IPMasquerade= option not available: %m");
|
||||
|
||||
r = manager_start(m);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Could not start manager: %m");
|
||||
|
||||
Reference in New Issue
Block a user