|
|
bacbc8 |
From 61e3dab3169af7add5fa131bb7414adf586d2997 Mon Sep 17 00:00:00 2001
|
|
|
bacbc8 |
From: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
bacbc8 |
Date: Fri, 5 Apr 2019 15:35:36 +0200
|
|
|
bacbc8 |
Subject: [PATCH] src: missing destroy function in statement definitions
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
bacbc8 |
(cherry picked from commit 4ac11b890fe870d1c066783bccc235e1922dd431)
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Conflicts:
|
|
|
bacbc8 |
-> Dropped changes to set_stmt_destroy() and map_stmt_destroy() due to
|
|
|
bacbc8 |
missing commit a55ca1a24b7b2 ("src: integrate stateful expressions
|
|
|
bacbc8 |
into sets and maps")
|
|
|
bacbc8 |
|
|
|
bacbc8 |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
bacbc8 |
---
|
|
|
bacbc8 |
src/ct.c | 12 ++++++++++++
|
|
|
bacbc8 |
src/exthdr.c | 7 +++++++
|
|
|
bacbc8 |
src/meta.c | 6 ++++++
|
|
|
bacbc8 |
src/payload.c | 7 +++++++
|
|
|
bacbc8 |
src/statement.c | 19 +++++++++++++++++++
|
|
|
bacbc8 |
src/xt.c | 1 +
|
|
|
bacbc8 |
6 files changed, 52 insertions(+)
|
|
|
bacbc8 |
|
|
|
bacbc8 |
diff --git a/src/ct.c b/src/ct.c
|
|
|
bacbc8 |
index f019f5af3e182..c2ca51494af60 100644
|
|
|
bacbc8 |
--- a/src/ct.c
|
|
|
bacbc8 |
+++ b/src/ct.c
|
|
|
bacbc8 |
@@ -440,11 +440,17 @@ static void ct_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
expr_print(stmt->ct.expr, octx);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void ct_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ expr_free(stmt->ct.expr);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops ct_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_CT,
|
|
|
bacbc8 |
.name = "ct",
|
|
|
bacbc8 |
.print = ct_stmt_print,
|
|
|
bacbc8 |
.json = ct_stmt_json,
|
|
|
bacbc8 |
+ .destroy = ct_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *ct_stmt_alloc(const struct location *loc, enum nft_ct_keys key,
|
|
|
bacbc8 |
@@ -484,10 +490,16 @@ static void flow_offload_stmt_print(const struct stmt *stmt,
|
|
|
bacbc8 |
nft_print(octx, "flow offload @%s", stmt->flow.table_name);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void flow_offload_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ xfree(stmt->flow.table_name);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops flow_offload_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_FLOW_OFFLOAD,
|
|
|
bacbc8 |
.name = "flow_offload",
|
|
|
bacbc8 |
.print = flow_offload_stmt_print,
|
|
|
bacbc8 |
+ .destroy = flow_offload_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *flow_offload_stmt_alloc(const struct location *loc,
|
|
|
bacbc8 |
diff --git a/src/exthdr.c b/src/exthdr.c
|
|
|
bacbc8 |
index cb0a58e8526a5..8602016f66477 100644
|
|
|
bacbc8 |
--- a/src/exthdr.c
|
|
|
bacbc8 |
+++ b/src/exthdr.c
|
|
|
bacbc8 |
@@ -104,11 +104,18 @@ static void exthdr_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
expr_print(stmt->exthdr.val, octx);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void exthdr_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ expr_free(stmt->exthdr.expr);
|
|
|
bacbc8 |
+ expr_free(stmt->exthdr.val);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops exthdr_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_EXTHDR,
|
|
|
bacbc8 |
.name = "exthdr",
|
|
|
bacbc8 |
.print = exthdr_stmt_print,
|
|
|
bacbc8 |
.json = exthdr_stmt_json,
|
|
|
bacbc8 |
+ .destroy = exthdr_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *exthdr_stmt_alloc(const struct location *loc,
|
|
|
bacbc8 |
diff --git a/src/meta.c b/src/meta.c
|
|
|
bacbc8 |
index ff0cb122d7dfa..c1021febdefd4 100644
|
|
|
bacbc8 |
--- a/src/meta.c
|
|
|
bacbc8 |
+++ b/src/meta.c
|
|
|
bacbc8 |
@@ -604,11 +604,17 @@ static void meta_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
expr_print(stmt->meta.expr, octx);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void meta_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ expr_free(stmt->meta.expr);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops meta_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_META,
|
|
|
bacbc8 |
.name = "meta",
|
|
|
bacbc8 |
.print = meta_stmt_print,
|
|
|
bacbc8 |
.json = meta_stmt_json,
|
|
|
bacbc8 |
+ .destroy = meta_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *meta_stmt_alloc(const struct location *loc, enum nft_meta_keys key,
|
|
|
bacbc8 |
diff --git a/src/payload.c b/src/payload.c
|
|
|
bacbc8 |
index 6517686cbfba5..42b055360848d 100644
|
|
|
bacbc8 |
--- a/src/payload.c
|
|
|
bacbc8 |
+++ b/src/payload.c
|
|
|
bacbc8 |
@@ -189,11 +189,18 @@ static void payload_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
expr_print(stmt->payload.val, octx);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void payload_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ expr_free(stmt->payload.expr);
|
|
|
bacbc8 |
+ expr_free(stmt->payload.val);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops payload_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_PAYLOAD,
|
|
|
bacbc8 |
.name = "payload",
|
|
|
bacbc8 |
.print = payload_stmt_print,
|
|
|
bacbc8 |
.json = payload_stmt_json,
|
|
|
bacbc8 |
+ .destroy = payload_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *payload_stmt_alloc(const struct location *loc,
|
|
|
bacbc8 |
diff --git a/src/statement.c b/src/statement.c
|
|
|
bacbc8 |
index e9c9d648b0092..1b889e77cca20 100644
|
|
|
bacbc8 |
--- a/src/statement.c
|
|
|
bacbc8 |
+++ b/src/statement.c
|
|
|
bacbc8 |
@@ -134,6 +134,7 @@ static void meter_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
expr_free(stmt->meter.key);
|
|
|
bacbc8 |
expr_free(stmt->meter.set);
|
|
|
bacbc8 |
stmt_free(stmt->meter.stmt);
|
|
|
bacbc8 |
+ xfree(stmt->meter.name);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
static const struct stmt_ops meter_stmt_ops = {
|
|
|
bacbc8 |
@@ -226,11 +227,17 @@ static void objref_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
expr_print(stmt->objref.expr, octx);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void objref_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ expr_free(stmt->objref.expr);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops objref_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_OBJREF,
|
|
|
bacbc8 |
.name = "objref",
|
|
|
bacbc8 |
.print = objref_stmt_print,
|
|
|
bacbc8 |
.json = objref_stmt_json,
|
|
|
bacbc8 |
+ .destroy = objref_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *objref_stmt_alloc(const struct location *loc)
|
|
|
bacbc8 |
@@ -435,11 +442,17 @@ static void queue_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void queue_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ expr_free(stmt->queue.queue);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops queue_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_QUEUE,
|
|
|
bacbc8 |
.name = "queue",
|
|
|
bacbc8 |
.print = queue_stmt_print,
|
|
|
bacbc8 |
.json = queue_stmt_json,
|
|
|
bacbc8 |
+ .destroy = queue_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *queue_stmt_alloc(const struct location *loc)
|
|
|
bacbc8 |
@@ -511,11 +524,17 @@ static void reject_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
+static void reject_stmt_destroy(struct stmt *stmt)
|
|
|
bacbc8 |
+{
|
|
|
bacbc8 |
+ expr_free(stmt->reject.expr);
|
|
|
bacbc8 |
+}
|
|
|
bacbc8 |
+
|
|
|
bacbc8 |
static const struct stmt_ops reject_stmt_ops = {
|
|
|
bacbc8 |
.type = STMT_REJECT,
|
|
|
bacbc8 |
.name = "reject",
|
|
|
bacbc8 |
.print = reject_stmt_print,
|
|
|
bacbc8 |
.json = reject_stmt_json,
|
|
|
bacbc8 |
+ .destroy = reject_stmt_destroy,
|
|
|
bacbc8 |
};
|
|
|
bacbc8 |
|
|
|
bacbc8 |
struct stmt *reject_stmt_alloc(const struct location *loc)
|
|
|
bacbc8 |
diff --git a/src/xt.c b/src/xt.c
|
|
|
bacbc8 |
index 74763d58cafd7..298a94d51e8a0 100644
|
|
|
bacbc8 |
--- a/src/xt.c
|
|
|
bacbc8 |
+++ b/src/xt.c
|
|
|
bacbc8 |
@@ -92,6 +92,7 @@ void xt_stmt_release(const struct stmt *stmt)
|
|
|
bacbc8 |
break;
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
xfree(stmt->xt.entry);
|
|
|
bacbc8 |
+ xfree(stmt->xt.name);
|
|
|
bacbc8 |
}
|
|
|
bacbc8 |
|
|
|
bacbc8 |
static void *xt_entry_alloc(struct xt_stmt *xt, uint32_t af)
|
|
|
bacbc8 |
--
|
|
|
bacbc8 |
2.21.0
|
|
|
bacbc8 |
|