summaryrefslogtreecommitdiffstats
path: root/src/evaluate.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2018-01-18 08:43:23 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2018-03-05 16:30:15 +0100
commit92911b362e9067a9a335ac1a63e15119fb69a47d (patch)
tree74dba6877734feb8a1900b469b76bb1dffc13421 /src/evaluate.c
parentdb0697ce7f6020b525cee072e7c0c85512daabda (diff)
src: add support to add flowtables
This patch allows you to create flowtable: # nft add table x # nft add flowtable x m { hook ingress priority 10\; devices = { eth0, wlan0 }\; } You have to specify hook and priority. So far, only the ingress hook is supported. The priority represents where this flowtable is placed in the ingress hook, which is registered to the devices that the user specifies. You can also use the 'create' command instead to bail out in case that there is an existing flowtable with this name. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/evaluate.c')
-rw-r--r--src/evaluate.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/evaluate.c b/src/evaluate.c
index 6094d0c5..9da185c9 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -2910,6 +2910,24 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
return 0;
}
+static uint32_t str2hooknum(uint32_t family, const char *hook);
+
+static int flowtable_evaluate(struct eval_ctx *ctx, struct flowtable *ft)
+{
+ struct table *table;
+
+ table = table_lookup_global(ctx);
+ if (table == NULL)
+ return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
+ ctx->cmd->handle.table);
+
+ ft->hooknum = str2hooknum(NFPROTO_NETDEV, ft->hookstr);
+ if (ft->hooknum == NF_INET_NUMHOOKS)
+ return chain_error(ctx, ft, "invalid hook %s", ft->hookstr);
+
+ return 0;
+}
+
static int rule_evaluate(struct eval_ctx *ctx, struct rule *rule)
{
struct stmt *stmt, *tstmt = NULL;
@@ -3082,6 +3100,14 @@ static int cmd_evaluate_add(struct eval_ctx *ctx, struct cmd *cmd)
return chain_evaluate(ctx, cmd->chain);
case CMD_OBJ_TABLE:
return table_evaluate(ctx, cmd->table);
+ case CMD_OBJ_FLOWTABLE:
+ ret = cache_update(ctx->nf_sock, ctx->cache, cmd->op,
+ ctx->msgs, ctx->debug_mask & NFT_DEBUG_NETLINK, ctx->octx);
+ if (ret < 0)
+ return ret;
+
+ handle_merge(&cmd->flowtable->handle, &cmd->handle);
+ return flowtable_evaluate(ctx, cmd->flowtable);
case CMD_OBJ_COUNTER:
case CMD_OBJ_QUOTA:
case CMD_OBJ_CT_HELPER: