[nft PATCH v3 03/14] libnftables: Make some arrays globally accessible

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This removes static flag and adds declarations in headers for the
following arrays:

* ct_templates from src/ct.c
* mark_tbl from src/datatype.c
* meta_templates and devgroup_tbl from src/meta.c
* table_flags_name from src/rule.c
* set_stmt_op_names from src/statement.c
* tcpopthdr_protocols from src/tcpopt.c

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 include/ct.h        | 2 ++
 include/datatype.h  | 1 +
 include/meta.h      | 4 ++++
 include/rt.h        | 2 ++
 include/rule.h      | 3 +++
 include/statement.h | 2 ++
 include/tcpopt.h    | 4 ++++
 src/ct.c            | 2 +-
 src/datatype.c      | 3 ++-
 src/meta.c          | 5 +++--
 src/rt.c            | 2 +-
 src/rule.c          | 2 --
 src/statement.c     | 2 +-
 src/tcpopt.c        | 2 +-
 14 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/include/ct.h b/include/ct.h
index 2c3392d36c94e..dadd820f88740 100644
--- a/include/ct.h
+++ b/include/ct.h
@@ -16,6 +16,8 @@ struct ct_template {
 	unsigned int		len;
 };
 
+extern const struct ct_template ct_templates[__NFT_CT_MAX];
+
 #define CT_TEMPLATE(__token, __dtype, __byteorder, __len) {	\
 	.token		= (__token),				\
 	.dtype		= (__dtype),				\
diff --git a/include/datatype.h b/include/datatype.h
index 3f612e52aec29..a1abe31f2b2bd 100644
--- a/include/datatype.h
+++ b/include/datatype.h
@@ -218,6 +218,7 @@ extern struct symbol_table *rt_symbol_table_init(const char *filename);
 extern void rt_symbol_table_free(struct symbol_table *tbl);
 
 extern const struct symbol_table inet_service_tbl;
+extern struct symbol_table *mark_tbl;
 
 extern const struct datatype invalid_type;
 extern const struct datatype verdict_type;
diff --git a/include/meta.h b/include/meta.h
index 6086a71cc0115..a49b4ff549702 100644
--- a/include/meta.h
+++ b/include/meta.h
@@ -16,6 +16,8 @@ struct meta_template {
 	unsigned int		len;
 };
 
+extern const struct meta_template meta_templates[];
+
 #define META_TEMPLATE(__token, __dtype, __len, __byteorder) {	\
 	.token		= (__token),				\
 	.dtype		= (__dtype),				\
@@ -40,4 +42,6 @@ extern const struct datatype devgroup_type;
 extern const struct datatype pkttype_type;
 extern const struct datatype ifname_type;
 
+extern struct symbol_table *devgroup_tbl;
+
 #endif /* NFTABLES_META_H */
diff --git a/include/rt.h b/include/rt.h
index 9828e634660a1..195af94345cbc 100644
--- a/include/rt.h
+++ b/include/rt.h
@@ -18,6 +18,8 @@ struct rt_template {
 	bool			invalid;
 };
 
+extern const struct rt_template rt_templates[];
+
 #define RT_TEMPLATE(__token, __dtype, __len, __byteorder, __invalid) {	\
 	.token		= (__token),					\
 	.dtype		= (__dtype),					\
diff --git a/include/rule.h b/include/rule.h
index b265690d3c964..74903eca3608f 100644
--- a/include/rule.h
+++ b/include/rule.h
@@ -114,6 +114,9 @@ struct symbol *symbol_get(const struct scope *scope, const char *identifier);
 enum table_flags {
 	TABLE_F_DORMANT		= (1 << 0),
 };
+#define TABLE_FLAGS_MAX 1
+
+extern const char *table_flags_name[TABLE_FLAGS_MAX];
 
 /**
  * struct table - nftables table
diff --git a/include/statement.h b/include/statement.h
index 7315e7aeea8bc..5987b18170f94 100644
--- a/include/statement.h
+++ b/include/statement.h
@@ -163,6 +163,8 @@ struct set_stmt {
 	enum nft_dynset_ops	op;
 };
 
+extern const char * const set_stmt_op_names[];
+
 extern struct stmt *set_stmt_alloc(const struct location *loc);
 
 struct map_stmt {
diff --git a/include/tcpopt.h b/include/tcpopt.h
index 9be84817e6f20..ffdbcb028125c 100644
--- a/include/tcpopt.h
+++ b/include/tcpopt.h
@@ -29,6 +29,7 @@ enum tcpopt_hdr_types {
 	TCPOPTHDR_TIMESTAMP,
 	TCPOPTHDR_ECHO,
 	TCPOPTHDR_ECHO_REPLY,
+	__TCPOPTHDR_MAX
 };
 
 enum tcpopt_hdr_fields {
@@ -42,4 +43,7 @@ enum tcpopt_hdr_fields {
 	TCPOPTHDR_FIELD_TSVAL,
 	TCPOPTHDR_FIELD_TSECR,
 };
+
+extern const struct exthdr_desc *tcpopthdr_protocols[__TCPOPTHDR_MAX];
+
 #endif /* NFTABLES_TCPOPT_H */
diff --git a/src/ct.c b/src/ct.c
index 6cb6bd5af927b..2abaa0d581443 100644
--- a/src/ct.c
+++ b/src/ct.c
@@ -220,7 +220,7 @@ void ct_label_table_exit(void)
 #define NF_CT_HELPER_NAME_LEN	16
 #endif
 
-static const struct ct_template ct_templates[] = {
+const struct ct_template ct_templates[__NFT_CT_MAX] = {
 	[NFT_CT_STATE]		= CT_TEMPLATE("state",	    &ct_state_type,
 					      BYTEORDER_HOST_ENDIAN,
 					      4 * BITS_PER_BYTE),
diff --git a/src/datatype.c b/src/datatype.c
index 446bde9f438d1..8b4579daa8444 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -721,7 +721,8 @@ void rt_symbol_table_free(struct symbol_table *tbl)
 	xfree(tbl);
 }
 
-static struct symbol_table *mark_tbl;
+struct symbol_table *mark_tbl = NULL;
+
 void mark_table_init(void)
 {
 	mark_tbl = rt_symbol_table_init("/etc/iproute2/rt_marks");
diff --git a/src/meta.c b/src/meta.c
index 3012efa94e242..fb94ed406d4a5 100644
--- a/src/meta.c
+++ b/src/meta.c
@@ -334,7 +334,8 @@ const struct datatype pkttype_type = {
 	.sym_tbl	= &pkttype_type_tbl,
 };
 
-static struct symbol_table *devgroup_tbl;
+struct symbol_table *devgroup_tbl = NULL;
+
 void devgroup_table_init(void)
 {
 	devgroup_tbl = rt_symbol_table_init("/etc/iproute2/group");
@@ -378,7 +379,7 @@ const struct datatype ifname_type = {
 	.basetype	= &string_type,
 };
 
-static const struct meta_template meta_templates[] = {
+const struct meta_template meta_templates[] = {
 	[NFT_META_LEN]		= META_TEMPLATE("length",    &integer_type,
 						4 * 8, BYTEORDER_HOST_ENDIAN),
 	[NFT_META_PROTOCOL]	= META_TEMPLATE("protocol",  &ethertype_type,
diff --git a/src/rt.c b/src/rt.c
index 041dbc2f7d900..2530b663bb249 100644
--- a/src/rt.c
+++ b/src/rt.c
@@ -57,7 +57,7 @@ const struct datatype realm_type = {
 	.flags		= DTYPE_F_PREFIX,
 };
 
-static const struct rt_template rt_templates[] = {
+const struct rt_template rt_templates[] = {
 	[NFT_RT_CLASSID]	= RT_TEMPLATE("classid",
 					      &realm_type,
 					      4 * BITS_PER_BYTE,
diff --git a/src/rule.c b/src/rule.c
index 2f0123b7a4a58..700ddffbe6919 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -848,8 +848,6 @@ struct table *table_lookup(const struct handle *h,
 	return NULL;
 }
 
-#define TABLE_FLAGS_MAX 1
-
 const char *table_flags_name[TABLE_FLAGS_MAX] = {
 	"dormant",
 };
diff --git a/src/statement.c b/src/statement.c
index 19c30cf861c81..a5ef7d7dfd2eb 100644
--- a/src/statement.c
+++ b/src/statement.c
@@ -567,7 +567,7 @@ struct stmt *nat_stmt_alloc(const struct location *loc,
 	return stmt;
 }
 
-static const char * const set_stmt_op_names[] = {
+const char * const set_stmt_op_names[] = {
 	[NFT_DYNSET_OP_ADD]	= "add",
 	[NFT_DYNSET_OP_UPDATE]	= "update",
 };
diff --git a/src/tcpopt.c b/src/tcpopt.c
index 7c6c2557028ab..66f021f94d63f 100644
--- a/src/tcpopt.c
+++ b/src/tcpopt.c
@@ -136,7 +136,7 @@ static unsigned int calc_offset_reverse(const struct exthdr_desc *desc,
 	}
 }
 
-static const struct exthdr_desc *tcpopthdr_protocols[] = {
+const struct exthdr_desc *tcpopthdr_protocols[__TCPOPTHDR_MAX] = {
 	[TCPOPTHDR_EOL]			= &tcpopt_eol,
 	[TCPOPTHDR_NOOP]		= &tcpopt_nop,
 	[TCPOPTHDR_MAXSEG]		= &tcptopt_maxseg,
-- 
2.17.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux