set: remove unused set_clone() function
PATCH 1/2 set: remove unused set_clone() function
The set_clone() function was added by the event monitor patchset and is unused. It is also broken since it simply initializes the list head to the list of the original set, so remove it.
Signed-off-by Patrick McHardy <[email protected]>
--- include/rule.h | 1 - src/rule.c | 18 ------------------ 2 files changed, 19 deletions(-)
include/rule.h +0 -1
@@ -203,7 +203,6 @@ struct set {extern struct set *set_alloc (const struct location *loc);extern struct set *set_get (struct set *set);extern void set_free (struct set *set); -extern struct set *set_clone (const struct set *set);extern void set_add_hash (struct set *set,struct table *table);extern struct set *set_lookup (const struct table *table,const char *name); extern struct set *set_lookup_global(uint32_t family, const char *table,
src/rule.c +0 -18
@@ -80,24 +80,6 @@ void set_free(struct set *set)xfree (set); } -struct set *set_clone (const struct set *set) -{ -struct set *newset =set_alloc (&set->location); - - newset->list = set->list; -handle_merge (&newset->handle, &set->handle); - newset->flags = set->flags; - newset->keytype = set->keytype; - newset->keylen = set->keylen; - newset->datatype = set->datatype; - newset->datalen = set->datalen; - newset->init =expr_clone (set->init); - newset->policy = set->policy; - newset->desc.size = set->desc.size; - -return newset; -} -void set_add_hash (struct set *set,struct table *table) {list_add_tail (&set->list, &table->sets);
Signature · 1 line
2.1.0
PATCH 2/2 expr: fix crash when listing non-verdict mappings
Fix regression introduced by commit 87c2a2205:
netlink_delinearize: clone on netlink_get_register(), release previous on _set()
When using a non-verdict mapping, the set ref expression is assigned to the destination register. The next get_register() will attempt to clone it and crash because of the missing ->clone() callback.
# nft filter input meta mark set ip daddr map { 192.168.0.1 : 123 }
# nft list table filter
Segmentation fault (core dumped)Signed-off-by Patrick McHardy <[email protected]>
--- src/expression.c | 6 ++++++ 1 file changed, 6 insertions(+)
src/expression.c +6 -0
@@ -858,6 +858,11 @@ static void set_ref_expr_print(const struct expr *expr)printf ("@%s" , expr->set->handle.set); } +static void set_ref_expr_clone (struct expr *new,const struct expr *expr) +{ + new->set =set_get (expr->set); +} +static void set_ref_expr_destroy (struct expr *expr) {set_free (expr->set);
@@ -867,6 +872,7 @@ static const struct expr_ops set_ref_expr_ops = { .type = EXPR_SET_REF, .name = "set reference", .print = set_ref_expr_print, + .clone = set_ref_expr_clone, .destroy = set_ref_expr_destroy, };
Signature · 1 line
2.1.0