Skip to contentSkip to conversation

expression: provide clone operation for set element ops

PATCH In review Florian Westphal 3 participants 3 messages Sep 30, 2015 – Oct 6, 2015 netfilter

lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 expression: provide clone operation for set element ops

define addrs={ 1.2.3.4 }

table ip filter {
	chain input {
		type filter hook input priority 0;
		ip saddr $addrs accept
	}
}

segfaults. Using saddr { 1.2.3.4 } instead of $addrs works.

---
 src/expression.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
src/expression.c +11 -0
index 3edc550..70f18e2 100644
@@ -48,6 +48,7 @@ struct expr *expr_clone(const struct expr *expr)
 			 expr->byteorder, expr->len);
 	new->flags = expr->flags;
 	new->op    = expr->op;
+	assert(expr->ops->clone);
 	expr->ops->clone(new, expr);
 	return new;
 }
@@ -907,9 +908,19 @@ static void set_elem_expr_destroy(struct expr *expr)
 	expr_free(expr->key);
 }
 
+static void set_elem_expr_clone(struct expr *new, const struct expr *expr)
+{
+	new->key = expr_clone(expr->key);
+	new->expiration = expr->expiration;
+	new->timeout = expr->timeout;
+	if (expr->comment)
+		new->comment = xstrdup(expr->comment);
+}
+
 static const struct expr_ops set_elem_expr_ops = {
 	.type		= EXPR_SET_ELEM,
 	.name		= "set element",
+	.clone		= set_elem_expr_clone,
 	.print		= set_elem_expr_print,
 	.destroy	= set_elem_expr_destroy,
 };
Signature · 1 line
2.0.5
Tested-by on v1 1/1
#1 lore raw
Quoted 8 lines · Florian Westphal

define addrs={ 1.2.3.4 }

table ip filter {
        chain input {
                type filter hook input priority 0;
                ip saddr $addrs accept
        }
}
Quoted 7 lines

segfaults. Using saddr { 1.2.3.4 } instead of $addrs works.

---
 src/expression.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Signature · 5 lines
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw
Quoted 11 lines · Arturo Borrero Gonzalez
Quoted 10 lines · Florian Westphal

define addrs={ 1.2.3.4 }

table ip filter {
        chain input {
                type filter hook input priority 0;
                ip saddr $addrs accept
        }
}

segfaults. Using saddr { 1.2.3.4 } instead of $addrs works.

Quoted 7 lines
Quoted 5 lines
---
 src/expression.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Testing helps us a lot to speed up submission process. Thanks.