]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
src: delete devices to an existing flowtable
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 20 May 2020 18:23:36 +0000 (20:23 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 2 Jun 2020 12:05:39 +0000 (14:05 +0200)
This patch allows you to remove a device to an existing flowtable:

 # nft delete flowtable x y { devices = { eth0 } \;  }

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
src/mnl.c
src/parser_bison.y

index 8f8fcc2c7ae0f2be8e121e364efb29e2ab0d8eb9..759ae41ceb0162603e3d5cff21b741f767f15da1 100644 (file)
--- a/src/mnl.c
+++ b/src/mnl.c
@@ -1682,6 +1682,7 @@ int mnl_nft_flowtable_add(struct netlink_ctx *ctx, struct cmd *cmd,
 int mnl_nft_flowtable_del(struct netlink_ctx *ctx, struct cmd *cmd)
 {
        struct nftnl_flowtable *flo;
+       const char **dev_array;
        struct nlmsghdr *nlh;
 
        flo = nftnl_flowtable_alloc();
@@ -1691,6 +1692,16 @@ int mnl_nft_flowtable_del(struct netlink_ctx *ctx, struct cmd *cmd)
        nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_FAMILY,
                                cmd->handle.family);
 
+       if (cmd->flowtable && cmd->flowtable->dev_expr) {
+               nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_HOOKNUM, 0);
+               nftnl_flowtable_set_u32(flo, NFTNL_FLOWTABLE_PRIO, 0);
+
+               dev_array = nft_flowtable_dev_array(cmd);
+               nftnl_flowtable_set_data(flo, NFTNL_FLOWTABLE_DEVICES,
+                                        dev_array, 0);
+               nft_flowtable_dev_array_free(dev_array);
+       }
+
        nlh = nftnl_nlmsg_build_hdr(nftnl_batch_buffer(ctx->batch),
                                    NFT_MSG_DELFLOWTABLE, cmd->handle.family,
                                    0, ctx->seqnum);
index 8e937ca305d12395a429d8176df2708333615d2f..461d9bf24d95ad38191fd3a24e1139bff8c7ad89 100644 (file)
@@ -1179,6 +1179,13 @@ delete_cmd               :       TABLE           table_spec
                        {
                                $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_FLOWTABLE, &$2, &@$, NULL);
                        }
+                       |       FLOWTABLE       flowtable_spec  flowtable_block_alloc
+                                               '{'     flowtable_block '}'
+                       {
+                               $5->location = @5;
+                               handle_merge(&$3->handle, &$2);
+                               $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_FLOWTABLE, &$2, &@$, $5);
+                       }
                        |       COUNTER         obj_spec
                        {
                                $$ = cmd_alloc(CMD_DELETE, CMD_OBJ_COUNTER, &$2, &@$, NULL);