Skip to content

Commit

Permalink
netfilter: nf_tables: constify chain type definitions and pointers
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick McHardy <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
kaber authored and ummakynes committed Jan 9, 2014

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 93b0806 commit 2a37d75
Showing 11 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions include/net/netfilter/nf_tables.h
Original file line number Diff line number Diff line change
@@ -436,7 +436,7 @@ struct nft_stats {
*/
struct nft_base_chain {
struct nf_hook_ops ops[NFT_HOOK_OPS_MAX];
struct nf_chain_type *type;
const struct nf_chain_type *type;
u8 policy;
struct nft_stats __percpu *stats;
struct nft_chain chain;
@@ -507,8 +507,8 @@ struct nf_chain_type {
int family;
};

int nft_register_chain_type(struct nf_chain_type *);
void nft_unregister_chain_type(struct nf_chain_type *);
int nft_register_chain_type(const struct nf_chain_type *);
void nft_unregister_chain_type(const struct nf_chain_type *);

int nft_register_expr(struct nft_expr_type *);
void nft_unregister_expr(struct nft_expr_type *);
2 changes: 1 addition & 1 deletion net/bridge/netfilter/nf_tables_bridge.c
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ static struct pernet_operations nf_tables_bridge_net_ops = {
.exit = nf_tables_bridge_exit_net,
};

static struct nf_chain_type filter_bridge = {
static const struct nf_chain_type filter_bridge = {
.family = NFPROTO_BRIDGE,
.name = "filter",
.type = NFT_CHAIN_T_DEFAULT,
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/nf_tables_arp.c
Original file line number Diff line number Diff line change
@@ -68,7 +68,7 @@ static struct pernet_operations nf_tables_arp_net_ops = {
.exit = nf_tables_arp_exit_net,
};

static struct nf_chain_type filter_arp = {
static const struct nf_chain_type filter_arp = {
.family = NFPROTO_ARP,
.name = "filter",
.type = NFT_CHAIN_T_DEFAULT,
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/nf_tables_ipv4.c
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ static struct pernet_operations nf_tables_ipv4_net_ops = {
.exit = nf_tables_ipv4_exit_net,
};

static struct nf_chain_type filter_ipv4 = {
static const struct nf_chain_type filter_ipv4 = {
.family = NFPROTO_IPV4,
.name = "filter",
.type = NFT_CHAIN_T_DEFAULT,
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/nft_chain_nat_ipv4.c
Original file line number Diff line number Diff line change
@@ -164,7 +164,7 @@ static unsigned int nf_nat_output(const struct nf_hook_ops *ops,
return ret;
}

static struct nf_chain_type nft_chain_nat_ipv4 = {
static const struct nf_chain_type nft_chain_nat_ipv4 = {
.family = NFPROTO_IPV4,
.name = "nat",
.type = NFT_CHAIN_T_NAT,
2 changes: 1 addition & 1 deletion net/ipv4/netfilter/nft_chain_route_ipv4.c
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops,
return ret;
}

static struct nf_chain_type nft_chain_route_ipv4 = {
static const struct nf_chain_type nft_chain_route_ipv4 = {
.family = NFPROTO_IPV4,
.name = "route",
.type = NFT_CHAIN_T_ROUTE,
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/nf_tables_ipv6.c
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ static struct pernet_operations nf_tables_ipv6_net_ops = {
.exit = nf_tables_ipv6_exit_net,
};

static struct nf_chain_type filter_ipv6 = {
static const struct nf_chain_type filter_ipv6 = {
.family = NFPROTO_IPV6,
.name = "filter",
.type = NFT_CHAIN_T_DEFAULT,
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/nft_chain_nat_ipv6.c
Original file line number Diff line number Diff line change
@@ -170,7 +170,7 @@ static unsigned int nf_nat_ipv6_output(const struct nf_hook_ops *ops,
return ret;
}

static struct nf_chain_type nft_chain_nat_ipv6 = {
static const struct nf_chain_type nft_chain_nat_ipv6 = {
.family = NFPROTO_IPV6,
.name = "nat",
.type = NFT_CHAIN_T_NAT,
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/nft_chain_route_ipv6.c
Original file line number Diff line number Diff line change
@@ -59,7 +59,7 @@ static unsigned int nf_route_table_hook(const struct nf_hook_ops *ops,
return ret;
}

static struct nf_chain_type nft_chain_route_ipv6 = {
static const struct nf_chain_type nft_chain_route_ipv6 = {
.family = NFPROTO_IPV6,
.name = "route",
.type = NFT_CHAIN_T_ROUTE,
14 changes: 7 additions & 7 deletions net/netfilter/nf_tables_api.c
Original file line number Diff line number Diff line change
@@ -124,9 +124,9 @@ static inline u64 nf_tables_alloc_handle(struct nft_table *table)
return ++table->hgenerator;
}

static struct nf_chain_type *chain_type[AF_MAX][NFT_CHAIN_T_MAX];
static const struct nf_chain_type *chain_type[AF_MAX][NFT_CHAIN_T_MAX];

static struct nf_chain_type *
static const struct nf_chain_type *
__nf_tables_chain_type_lookup(int family, const struct nlattr *nla)
{
int i;
@@ -139,12 +139,12 @@ __nf_tables_chain_type_lookup(int family, const struct nlattr *nla)
return NULL;
}

static struct nf_chain_type *
static const struct nf_chain_type *
nf_tables_chain_type_lookup(const struct nft_af_info *afi,
const struct nlattr *nla,
bool autoload)
{
struct nf_chain_type *type;
const struct nf_chain_type *type;

type = __nf_tables_chain_type_lookup(afi->family, nla);
if (type != NULL)
@@ -475,7 +475,7 @@ static int nf_tables_deltable(struct sock *nlsk, struct sk_buff *skb,
return 0;
}

int nft_register_chain_type(struct nf_chain_type *ctype)
int nft_register_chain_type(const struct nf_chain_type *ctype)
{
int err = 0;

@@ -491,7 +491,7 @@ int nft_register_chain_type(struct nf_chain_type *ctype)
}
EXPORT_SYMBOL_GPL(nft_register_chain_type);

void nft_unregister_chain_type(struct nf_chain_type *ctype)
void nft_unregister_chain_type(const struct nf_chain_type *ctype)
{
nfnl_lock(NFNL_SUBSYS_NFTABLES);
chain_type[ctype->family][ctype->type] = NULL;
@@ -900,7 +900,7 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb,
return -EOVERFLOW;

if (nla[NFTA_CHAIN_HOOK]) {
struct nf_chain_type *type;
const struct nf_chain_type *type;
struct nf_hook_ops *ops;
nf_hookfn *hookfn;
u32 hooknum, priority;
2 changes: 1 addition & 1 deletion net/netfilter/nf_tables_inet.c
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ static struct pernet_operations nf_tables_inet_net_ops = {
.exit = nf_tables_inet_exit_net,
};

static struct nf_chain_type filter_inet = {
static const struct nf_chain_type filter_inet = {
.family = NFPROTO_INET,
.name = "filter",
.type = NFT_CHAIN_T_DEFAULT,

0 comments on commit 2a37d75

Please sign in to comment.