summaryrefslogtreecommitdiffstats
path: root/src/expr_ops.c
diff options
context:
space:
mode:
authorPablo Neira Ayuso <pablo@netfilter.org>2015-03-22 20:59:42 +0100
committerPablo Neira Ayuso <pablo@netfilter.org>2015-03-23 12:46:25 +0100
commit305b4707d134362c9229241b922c3b2286d3c150 (patch)
tree9e54e6faa05d5022f2fc294f9ec62eb0cb7ca0df /src/expr_ops.c
parent8b2d59dadb920ed45dd347e2962ef4cf216d0c57 (diff)
src: restore static array with expression operations
We cannot use __attribute__((constructor)) to register the supported expressions in runtime when the library is statically linked. This lead us to some explicit libnftnl_init() function that needs to be called from the main() function of the client program. This patch reverts 4dd0772 ("expr: use __attribute__((constructor)) to register expression"). Reported-by: Laurent Bercot <ska-devel@skarnet.org> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/expr_ops.c')
-rw-r--r--src/expr_ops.c58
1 files changed, 48 insertions, 10 deletions
diff --git a/src/expr_ops.c b/src/expr_ops.c
index d0315a3..fce5b02 100644
--- a/src/expr_ops.c
+++ b/src/expr_ops.c
@@ -3,21 +3,59 @@
#include "expr_ops.h"
-static LIST_HEAD(expr_ops_list);
+/* Unfortunately, __attribute__((constructor)) breaks library static linking */
+extern struct expr_ops expr_ops_bitwise;
+extern struct expr_ops expr_ops_byteorder;
+extern struct expr_ops expr_ops_cmp;
+extern struct expr_ops expr_ops_counter;
+extern struct expr_ops expr_ops_ct;
+extern struct expr_ops expr_ops_exthdr;
+extern struct expr_ops expr_ops_immediate;
+extern struct expr_ops expr_ops_limit;
+extern struct expr_ops expr_ops_log;
+extern struct expr_ops expr_ops_lookup;
+extern struct expr_ops expr_ops_masq;
+extern struct expr_ops expr_ops_match;
+extern struct expr_ops expr_ops_meta;
+extern struct expr_ops expr_ops_nat;
+extern struct expr_ops expr_ops_payload;
+extern struct expr_ops expr_ops_redir;
+extern struct expr_ops expr_ops_reject;
+extern struct expr_ops expr_ops_queue;
+extern struct expr_ops expr_ops_target;
-void nft_expr_ops_register(struct expr_ops *ops)
-{
- list_add_tail(&ops->head, &expr_ops_list);
-}
+static struct expr_ops *expr_ops[] = {
+ &expr_ops_bitwise,
+ &expr_ops_byteorder,
+ &expr_ops_cmp,
+ &expr_ops_counter,
+ &expr_ops_ct,
+ &expr_ops_exthdr,
+ &expr_ops_immediate,
+ &expr_ops_limit,
+ &expr_ops_log,
+ &expr_ops_lookup,
+ &expr_ops_masq,
+ &expr_ops_match,
+ &expr_ops_meta,
+ &expr_ops_nat,
+ &expr_ops_payload,
+ &expr_ops_redir,
+ &expr_ops_reject,
+ &expr_ops_queue,
+ &expr_ops_target,
+ NULL,
+};
struct expr_ops *nft_expr_ops_lookup(const char *name)
{
- struct expr_ops *ops;
+ int i = 0;
- list_for_each_entry(ops, &expr_ops_list, head) {
- if (strcmp(ops->name, name) == 0)
- return ops;
- }
+ while (expr_ops[i] != NULL) {
+ if (strcmp(expr_ops[i]->name, name) == 0)
+ return expr_ops[i];
+ i++;
+ }
return NULL;
}