From c04175e392335fb22b52f234171b5042e0b8f6bd Mon Sep 17 00:00:00 2001 From: Alvaro Neira Date: Fri, 3 Oct 2014 20:02:40 +0200 Subject: src: internal set id allocation from nft_ruleset_parse*() Extends this function to attach the set to the rule through the set_idi. If it doesn't exist in the list, maybe the set already exists in the kernel. In that case, we don't set any id. Signed-off-by: Alvaro Neira Ayuso Signed-off-by: Pablo Neira Ayuso --- src/jansson.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/jansson.c') diff --git a/src/jansson.c b/src/jansson.c index 377d06e..728de12 100644 --- a/src/jansson.c +++ b/src/jansson.c @@ -187,11 +187,13 @@ int nft_jansson_str2num(json_t *root, const char *node_name, int base, } struct nft_rule_expr *nft_jansson_expr_parse(json_t *root, - struct nft_parse_err *err) + struct nft_parse_err *err, + struct nft_set_list *set_list) { struct nft_rule_expr *e; const char *type; - int ret; + struct nft_set *set_cur = NULL; + int ret, set_id; type = nft_jansson_parse_str(root, "type", err); if (type == NULL) @@ -205,6 +207,11 @@ struct nft_rule_expr *nft_jansson_expr_parse(json_t *root, ret = e->ops->json_parse(e, root, err); + if (set_list != NULL && + strcmp(type, "lookup") == 0 && + nft_set_lookup_id(e, set_list, &set_id)) + nft_rule_expr_set_u32(e, NFT_EXPR_LOOKUP_SET_ID, set_id); + return ret < 0 ? NULL : e; } -- cgit v1.2.3