]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
include: Remove datatype_register().
authorVarsha Rao <rvarsha016@gmail.com>
Fri, 30 Jun 2017 09:26:19 +0000 (14:56 +0530)
committerPablo Neira Ayuso <pablo@netfilter.org>
Fri, 30 Jun 2017 10:44:54 +0000 (12:44 +0200)
Remove datatype_register() function and its calling __init functions.
Add arguments of datatype_register() function to datatype array.

Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
14 files changed:
include/ct.h
include/datatype.h
include/exthdr.h
include/fib.h
include/meta.h
include/proto.h
include/rt.h
src/ct.c
src/datatype.c
src/exthdr.c
src/fib.c
src/meta.c
src/proto.c
src/rt.c

index ae900ee4fb61c62eac2ac359630469786c62ca18..becd09c6e867adfd7942e07235c3ceb842cefcb3 100644 (file)
@@ -35,4 +35,8 @@ extern struct error_record *ct_objtype_parse(const struct location *loc, const c
 
 extern struct stmt *notrack_stmt_alloc(const struct location *loc);
 
+extern const struct datatype ct_dir_type;
+extern const struct datatype ct_state_type;
+extern const struct datatype ct_status_type;
+
 #endif /* NFTABLES_CT_H */
index 58c4d3e0cb35709bd593df5d70803aa5edb048c4..2e345910be83db5e3d41913139644d1ddbbd9106 100644 (file)
@@ -152,7 +152,6 @@ struct datatype {
        const struct symbol_table       *sym_tbl;
 };
 
-extern void datatype_register(const struct datatype *dtype);
 extern const struct datatype *datatype_lookup(enum datatypes type);
 extern const struct datatype *datatype_lookup_byname(const char *name);
 
index a2647ee142dcdf688ff03fff58c974bcdd13db4f..97ccc3876f63f43dfdf3a3a18463387ed80a6d99 100644 (file)
@@ -89,5 +89,6 @@ extern const struct exthdr_desc exthdr_rt2;
 extern const struct exthdr_desc exthdr_frag;
 extern const struct exthdr_desc exthdr_dst;
 extern const struct exthdr_desc exthdr_mh;
+extern const struct datatype mh_type_type;
 
 #endif /* NFTABLES_EXTHDR_H */
index 3a019e65c814ca133325788fe949b440ad2908c9..9ce681cc1ecf35aa1421d67067af1a9d8a25e5ab 100644 (file)
@@ -4,4 +4,6 @@
 extern struct expr *fib_expr_alloc(const struct location *loc,
                                   unsigned int flags,
                                   unsigned int result);
+extern const struct datatype fib_addr_type;
+
 #endif /* NFTABLES_FIB_H */
index 55784609e564c9359aa57ee937586a8e8b114cd6..47b16c4b7e82766913cd7470d2240d8ac110315a 100644 (file)
@@ -28,10 +28,15 @@ extern struct expr *meta_expr_alloc(const struct location *loc,
 
 struct stmt *meta_stmt_meta_iiftype(const struct location *loc, uint16_t type);
 
-const struct datatype ifindex_type;
-
 struct error_record *meta_key_parse(const struct location *loc,
                                    const char *name,
                                    unsigned int *value);
 
+extern const struct datatype ifindex_type;
+extern const struct datatype tchandle_type;
+extern const struct datatype gid_type;
+extern const struct datatype uid_type;
+extern const struct datatype devgroup_type;
+extern const struct datatype pkttype_type;
+
 #endif /* NFTABLES_META_H */
index 01188ab6eee4059609d6a68972446943ddfd9e0e..39aa4850740cdefc5c818b21221fad2fefaae042 100644 (file)
@@ -322,4 +322,12 @@ extern const struct proto_desc proto_netdev;
 extern const struct proto_desc proto_unknown;
 extern const struct proto_hdr_template proto_unknown_template;
 
+extern const struct datatype icmp_type_type;
+extern const struct datatype tcp_flag_type;
+extern const struct datatype dccp_pkttype_type;
+extern const struct datatype arpop_type;
+extern const struct datatype icmp6_type_type;
+extern const struct datatype dscp_type;
+extern const struct datatype ecn_type;
+
 #endif /* NFTABLES_PROTO_H */
index 728cf5f050e6d01ec32524edf2fe75e6dbd3e5b3..9828e634660a12fa321e0806303e124d73c6ef82 100644 (file)
@@ -30,4 +30,6 @@ extern struct expr *rt_expr_alloc(const struct location *loc,
                                  enum nft_rt_keys key, bool invalid);
 extern void rt_expr_update_type(struct proto_ctx *ctx, struct expr *expr);
 
+extern const struct datatype realm_type;
+
 #endif /* NFTABLES_RT_H */
index c705750db4f711b6783bfa297a84b9162849c5a0..9b7140b352bb444d2955597ffbfded8fa96b93ab 100644 (file)
--- a/src/ct.c
+++ b/src/ct.c
@@ -44,7 +44,7 @@ static const struct symbol_table ct_state_tbl = {
        }
 };
 
-static const struct datatype ct_state_type = {
+const struct datatype ct_state_type = {
        .type           = TYPE_CT_STATE,
        .name           = "ct_state",
        .desc           = "conntrack state",
@@ -63,7 +63,7 @@ static const struct symbol_table ct_dir_tbl = {
        }
 };
 
-static const struct datatype ct_dir_type = {
+const struct datatype ct_dir_type = {
        .type           = TYPE_CT_DIR,
        .name           = "ct_dir",
        .desc           = "conntrack direction",
@@ -90,7 +90,7 @@ static const struct symbol_table ct_status_tbl = {
        },
 };
 
-static const struct datatype ct_status_type = {
+const struct datatype ct_status_type = {
        .type           = TYPE_CT_STATUS,
        .name           = "ct_status",
        .desc           = "conntrack status",
@@ -485,10 +485,3 @@ struct stmt *notrack_stmt_alloc(const struct location *loc)
 {
        return stmt_alloc(loc, &notrack_stmt_ops);
 }
-
-static void __init ct_init(void)
-{
-       datatype_register(&ct_state_type);
-       datatype_register(&ct_dir_type);
-       datatype_register(&ct_status_type);
-}
index 899e9c0a3e5ba393d058f1054ad2facecafe7dc2..287ca009a40c180bc5105398d21588e7b2d0cd79 100644 (file)
@@ -40,25 +40,40 @@ static const struct datatype *datatypes[TYPE_MAX + 1] = {
        [TYPE_IP6ADDR]          = &ip6addr_type,
        [TYPE_ETHERADDR]        = &etheraddr_type,
        [TYPE_ETHERTYPE]        = &ethertype_type,
+       [TYPE_ARPOP]            = &arpop_type,
        [TYPE_INET_PROTOCOL]    = &inet_protocol_type,
        [TYPE_INET_SERVICE]     = &inet_service_type,
+       [TYPE_ICMP_TYPE]        = &icmp_type_type,
+       [TYPE_TCP_FLAG]         = &tcp_flag_type,
+       [TYPE_DCCP_PKTTYPE]     = &dccp_pkttype_type,
+       [TYPE_MH_TYPE]          = &mh_type_type,
        [TYPE_TIME]             = &time_type,
        [TYPE_MARK]             = &mark_type,
+       [TYPE_IFINDEX]          = &ifindex_type,
        [TYPE_ARPHRD]           = &arphrd_type,
+       [TYPE_REALM]            = &realm_type,
+       [TYPE_CLASSID]          = &tchandle_type,
+       [TYPE_UID]              = &uid_type,
+       [TYPE_GID]              = &gid_type,
+       [TYPE_CT_STATE]         = &ct_state_type,
+       [TYPE_CT_DIR]           = &ct_dir_type,
+       [TYPE_CT_STATUS]        = &ct_status_type,
+       [TYPE_ICMP6_TYPE]       = &icmp6_type_type,
+       [TYPE_PKTTYPE]          = &pkttype_type,
        [TYPE_ICMP_CODE]        = &icmp_code_type,
        [TYPE_ICMPV6_CODE]      = &icmpv6_code_type,
        [TYPE_ICMPX_CODE]       = &icmpx_code_type,
+       [TYPE_DEVGROUP]         = &devgroup_type,
+       [TYPE_DSCP]             = &dscp_type,
+       [TYPE_ECN]              = &ecn_type,
+       [TYPE_FIB_ADDR]         = &fib_addr_type,
        [TYPE_BOOLEAN]          = &boolean_type,
 };
 
-void datatype_register(const struct datatype *dtype)
+const struct datatype *datatype_lookup(enum datatypes type)
 {
        BUILD_BUG_ON(TYPE_MAX & ~TYPE_MASK);
-       datatypes[dtype->type] = dtype;
-}
 
-const struct datatype *datatype_lookup(enum datatypes type)
-{
        if (type > TYPE_MAX)
                return NULL;
        return datatypes[type];
index f31deea5720b3a9eaa3d2713a4966436a84064b3..a678115b692aa426ff33a0b387efe889cd81b6b3 100644 (file)
@@ -322,7 +322,7 @@ static const struct symbol_table mh_type_tbl = {
        },
 };
 
-static const struct datatype mh_type_type = {
+const struct datatype mh_type_type = {
        .type           = TYPE_MH_TYPE,
        .name           = "mh_type",
        .desc           = "Mobility Header Type",
@@ -343,8 +343,3 @@ const struct exthdr_desc exthdr_mh = {
                [MHHDR_CHECKSUM]        = MH_FIELD("checksum", ip6mh_cksum, &integer_type),
        },
 };
-
-static void __init exthdr_init(void)
-{
-       datatype_register(&mh_type_type);
-}
index 28d2b1d92469a1e5c39f91a2442bf7bb4bf5b29b..b3488afff3923a48aa2749646a27647ce8c03aa4 100644 (file)
--- a/src/fib.c
+++ b/src/fib.c
@@ -42,7 +42,7 @@ static const struct symbol_table addrtype_tbl = {
        }
 };
 
-static const struct datatype fib_addr_type = {
+const struct datatype fib_addr_type = {
        .type           = TYPE_FIB_ADDR,
        .name           = "fib_addrtype",
        .desc           = "fib address type",
@@ -141,8 +141,3 @@ struct expr *fib_expr_alloc(const struct location *loc,
 
        return expr;
 }
-
-static void __init fib_init(void)
-{
-       datatype_register(&fib_addr_type);
-}
index a30331859bf863151f1028b2f34f28fc6392c031..e9334b8642782669bae0b077e00fd64f836b6297 100644 (file)
@@ -47,29 +47,6 @@ static void __exit realm_table_exit(void)
        rt_symbol_table_free(realm_tbl);
 }
 
-static void realm_type_print(const struct expr *expr, struct output_ctx *octx)
-{
-       return symbolic_constant_print(realm_tbl, expr, true, octx);
-}
-
-static struct error_record *realm_type_parse(const struct expr *sym,
-                                            struct expr **res)
-{
-       return symbolic_constant_parse(sym, realm_tbl, res);
-}
-
-static const struct datatype realm_type = {
-       .type           = TYPE_REALM,
-       .name           = "realm",
-       .desc           = "routing realm",
-       .byteorder      = BYTEORDER_HOST_ENDIAN,
-       .size           = 4 * BITS_PER_BYTE,
-       .basetype       = &integer_type,
-       .print          = realm_type_print,
-       .parse          = realm_type_parse,
-       .flags          = DTYPE_F_PREFIX,
-};
-
 static void tchandle_type_print(const struct expr *expr,
                                struct output_ctx *octx)
 {
@@ -139,7 +116,7 @@ err:
        return error(&sym->location, "Could not parse %s", sym->dtype->desc);
 }
 
-static const struct datatype tchandle_type = {
+const struct datatype tchandle_type = {
        .type           = TYPE_CLASSID,
        .name           = "classid",
        .desc           = "TC classid",
@@ -264,7 +241,7 @@ static struct error_record *uid_type_parse(const struct expr *sym,
        return NULL;
 }
 
-static const struct datatype uid_type = {
+const struct datatype uid_type = {
        .type           = TYPE_UID,
        .name           = "uid",
        .desc           = "user ID",
@@ -316,7 +293,7 @@ static struct error_record *gid_type_parse(const struct expr *sym,
        return NULL;
 }
 
-static const struct datatype gid_type = {
+const struct datatype gid_type = {
        .type           = TYPE_GID,
        .name           = "gid",
        .desc           = "group ID",
@@ -344,7 +321,7 @@ static void pkttype_type_print(const struct expr *expr, struct output_ctx *octx)
        return symbolic_constant_print(&pkttype_type_tbl, expr, false, octx);
 }
 
-static const struct datatype pkttype_type = {
+const struct datatype pkttype_type = {
        .type           = TYPE_PKTTYPE,
        .name           = "pkt_type",
        .desc           = "packet type",
@@ -378,7 +355,7 @@ static struct error_record *devgroup_type_parse(const struct expr *sym,
        return symbolic_constant_parse(sym, devgroup_tbl, res);
 }
 
-static const struct datatype devgroup_type = {
+const struct datatype devgroup_type = {
        .type           = TYPE_DEVGROUP,
        .name           = "devgroup",
        .desc           = "devgroup name",
@@ -621,17 +598,6 @@ struct stmt *meta_stmt_alloc(const struct location *loc, enum nft_meta_keys key,
        return stmt;
 }
 
-static void __init meta_init(void)
-{
-       datatype_register(&ifindex_type);
-       datatype_register(&realm_type);
-       datatype_register(&tchandle_type);
-       datatype_register(&uid_type);
-       datatype_register(&gid_type);
-       datatype_register(&devgroup_type);
-       datatype_register(&pkttype_type);
-}
-
 /*
  * @expr:      payload expression
  * @res:       dependency expression
index 64d06325637650b23e758c1849223e1c9a69023f..7ac0ee03191ac29b5d3ef36c63817f4fbeaf1b18 100644 (file)
@@ -406,7 +406,7 @@ static const struct symbol_table tcp_flag_tbl = {
        },
 };
 
-static const struct datatype tcp_flag_type = {
+const struct datatype tcp_flag_type = {
        .type           = TYPE_TCP_FLAG,
        .name           = "tcp_flag",
        .desc           = "TCP flag",
@@ -467,7 +467,7 @@ static const struct symbol_table dccp_pkttype_tbl = {
        },
 };
 
-static const struct datatype dccp_pkttype_type = {
+const struct datatype dccp_pkttype_type = {
        .type           = TYPE_DCCP_PKTTYPE,
        .name           = "dccp_pkttype",
        .desc           = "DCCP packet type",
@@ -545,7 +545,7 @@ static const struct symbol_table dscp_type_tbl = {
        },
 };
 
-static const struct datatype dscp_type = {
+const struct datatype dscp_type = {
        .type           = TYPE_DSCP,
        .name           = "dscp",
        .desc           = "Differentiated Services Code Point",
@@ -567,7 +567,7 @@ static const struct symbol_table ecn_type_tbl = {
        },
 };
 
-static const struct datatype ecn_type = {
+const struct datatype ecn_type = {
        .type           = TYPE_ECN,
        .name           = "ecn",
        .desc           = "Explicit Congestion Notification",
@@ -662,7 +662,7 @@ static const struct symbol_table icmp6_type_tbl = {
        },
 };
 
-static const struct datatype icmp6_type_type = {
+const struct datatype icmp6_type_type = {
        .type           = TYPE_ICMP6_TYPE,
        .name           = "icmpv6_type",
        .desc           = "ICMPv6 type",
@@ -807,7 +807,7 @@ static const struct symbol_table arpop_tbl = {
        },
 };
 
-static const struct datatype arpop_type = {
+const struct datatype arpop_type = {
        .type           = TYPE_ARPOP,
        .name           = "arp_op",
        .desc           = "ARP operation",
@@ -960,15 +960,3 @@ const struct proto_desc proto_netdev = {
                [0]     = PROTO_META_TEMPLATE("protocol", &ethertype_type, NFT_META_PROTOCOL, 16),
        },
 };
-
-static void __init proto_init(void)
-{
-       datatype_register(&icmp_type_type);
-       datatype_register(&tcp_flag_type);
-       datatype_register(&dccp_pkttype_type);
-       datatype_register(&arpop_type);
-       datatype_register(&ethertype_type);
-       datatype_register(&icmp6_type_type);
-       datatype_register(&dscp_type);
-       datatype_register(&ecn_type);
-}
index eb5f9c33a59537ddfb17dfcb506ecd9b3e239a05..530ebe6e3362bbc97f3b05c2c4f1ee76175148c4 100644 (file)
--- a/src/rt.c
+++ b/src/rt.c
@@ -45,7 +45,7 @@ static struct error_record *realm_type_parse(const struct expr *sym,
        return symbolic_constant_parse(sym, realm_tbl, res);
 }
 
-static const struct datatype realm_type = {
+const struct datatype realm_type = {
        .type           = TYPE_REALM,
        .name           = "realm",
        .desc           = "routing realm",
@@ -134,8 +134,3 @@ void rt_expr_update_type(struct proto_ctx *ctx, struct expr *expr)
                break;
        }
 }
-
-static void __init rt_init(void)
-{
-       datatype_register(&realm_type);
-}