mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 22:30:19 +01:00
firewall: introduce helper function for add/flush/delete nft table command
(cherry picked from commit e796a67d6c)
This commit is contained in:
parent
d7bc25b3bd
commit
56a503c879
1 changed files with 9 additions and 2 deletions
|
|
@ -619,6 +619,14 @@ _fw_nft_call_sync(GBytes *stdin_buf, GError **error)
|
|||
|
||||
#define _append(p_strbuf, fmt, ...) nm_str_buf_append_printf((p_strbuf), "" fmt "\n", ##__VA_ARGS__)
|
||||
|
||||
static void
|
||||
_fw_nft_append_cmd_table(NMStrBuf *strbuf, const char *family, const char *table_name, gboolean up)
|
||||
{
|
||||
/* Either delete the table, or create/flush it. */
|
||||
_append(strbuf, "add table %s %s", family, table_name);
|
||||
_append(strbuf, "%s table %s %s", up ? "flush" : "delete", family, table_name);
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
_fw_nft_set_shared_construct(gboolean up, const char *ip_iface, in_addr_t addr, guint8 plen)
|
||||
{
|
||||
|
|
@ -630,8 +638,7 @@ _fw_nft_set_shared_construct(gboolean up, const char *ip_iface, in_addr_t addr,
|
|||
|
||||
_share_iptables_subnet_to_str(str_subnet, addr, plen);
|
||||
|
||||
_append(&strbuf, "add table ip %s", table_name);
|
||||
_append(&strbuf, "%s table ip %s", up ? "flush" : "delete", table_name);
|
||||
_fw_nft_append_cmd_table(&strbuf, "ip", table_name, up);
|
||||
|
||||
if (up) {
|
||||
_append(&strbuf,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue