Commit 2b628a0866860d44652362aafe403e5b5895583d
Committed by
David S. Miller
1 parent
3ee9e76038
[NETFILTER]: nf_nat: mark NAT protocols const
Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 8 changed files with 25 additions and 25 deletions Side-by-side Diff
- include/net/netfilter/nf_nat_protocol.h
- net/ipv4/netfilter/nf_nat_core.c
- net/ipv4/netfilter/nf_nat_proto_gre.c
- net/ipv4/netfilter/nf_nat_proto_icmp.c
- net/ipv4/netfilter/nf_nat_proto_tcp.c
- net/ipv4/netfilter/nf_nat_proto_udp.c
- net/ipv4/netfilter/nf_nat_proto_unknown.c
- net/netfilter/nf_conntrack_netlink.c
include/net/netfilter/nf_nat_protocol.h
... | ... | @@ -46,21 +46,21 @@ |
46 | 46 | }; |
47 | 47 | |
48 | 48 | /* Protocol registration. */ |
49 | -extern int nf_nat_protocol_register(struct nf_nat_protocol *proto); | |
50 | -extern void nf_nat_protocol_unregister(struct nf_nat_protocol *proto); | |
49 | +extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); | |
50 | +extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); | |
51 | 51 | |
52 | -extern struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); | |
53 | -extern void nf_nat_proto_put(struct nf_nat_protocol *proto); | |
52 | +extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); | |
53 | +extern void nf_nat_proto_put(const struct nf_nat_protocol *proto); | |
54 | 54 | |
55 | 55 | /* Built-in protocols. */ |
56 | -extern struct nf_nat_protocol nf_nat_protocol_tcp; | |
57 | -extern struct nf_nat_protocol nf_nat_protocol_udp; | |
58 | -extern struct nf_nat_protocol nf_nat_protocol_icmp; | |
59 | -extern struct nf_nat_protocol nf_nat_unknown_protocol; | |
56 | +extern const struct nf_nat_protocol nf_nat_protocol_tcp; | |
57 | +extern const struct nf_nat_protocol nf_nat_protocol_udp; | |
58 | +extern const struct nf_nat_protocol nf_nat_protocol_icmp; | |
59 | +extern const struct nf_nat_protocol nf_nat_unknown_protocol; | |
60 | 60 | |
61 | 61 | extern int init_protocols(void) __init; |
62 | 62 | extern void cleanup_protocols(void); |
63 | -extern struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); | |
63 | +extern const struct nf_nat_protocol *find_nat_proto(u_int16_t protonum); | |
64 | 64 | |
65 | 65 | extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb, |
66 | 66 | const struct nf_nat_range *range); |
net/ipv4/netfilter/nf_nat_core.c
... | ... | @@ -42,18 +42,18 @@ |
42 | 42 | static struct hlist_head *bysource; |
43 | 43 | |
44 | 44 | #define MAX_IP_NAT_PROTO 256 |
45 | -static struct nf_nat_protocol *nf_nat_protos[MAX_IP_NAT_PROTO]; | |
45 | +static const struct nf_nat_protocol *nf_nat_protos[MAX_IP_NAT_PROTO]; | |
46 | 46 | |
47 | -static inline struct nf_nat_protocol * | |
47 | +static inline const struct nf_nat_protocol * | |
48 | 48 | __nf_nat_proto_find(u_int8_t protonum) |
49 | 49 | { |
50 | 50 | return rcu_dereference(nf_nat_protos[protonum]); |
51 | 51 | } |
52 | 52 | |
53 | -struct nf_nat_protocol * | |
53 | +const struct nf_nat_protocol * | |
54 | 54 | nf_nat_proto_find_get(u_int8_t protonum) |
55 | 55 | { |
56 | - struct nf_nat_protocol *p; | |
56 | + const struct nf_nat_protocol *p; | |
57 | 57 | |
58 | 58 | rcu_read_lock(); |
59 | 59 | p = __nf_nat_proto_find(protonum); |
... | ... | @@ -66,7 +66,7 @@ |
66 | 66 | EXPORT_SYMBOL_GPL(nf_nat_proto_find_get); |
67 | 67 | |
68 | 68 | void |
69 | -nf_nat_proto_put(struct nf_nat_protocol *p) | |
69 | +nf_nat_proto_put(const struct nf_nat_protocol *p) | |
70 | 70 | { |
71 | 71 | module_put(p->me); |
72 | 72 | } |
... | ... | @@ -105,7 +105,7 @@ |
105 | 105 | in_range(const struct nf_conntrack_tuple *tuple, |
106 | 106 | const struct nf_nat_range *range) |
107 | 107 | { |
108 | - struct nf_nat_protocol *proto; | |
108 | + const struct nf_nat_protocol *proto; | |
109 | 109 | int ret = 0; |
110 | 110 | |
111 | 111 | /* If we are supposed to map IPs, then we must be in the |
... | ... | @@ -226,7 +226,7 @@ |
226 | 226 | struct nf_conn *ct, |
227 | 227 | enum nf_nat_manip_type maniptype) |
228 | 228 | { |
229 | - struct nf_nat_protocol *proto; | |
229 | + const struct nf_nat_protocol *proto; | |
230 | 230 | |
231 | 231 | /* 1) If this srcip/proto/src-proto-part is currently mapped, |
232 | 232 | and that same mapping gives a unique tuple within the given |
... | ... | @@ -355,7 +355,7 @@ |
355 | 355 | enum nf_nat_manip_type maniptype) |
356 | 356 | { |
357 | 357 | struct iphdr *iph; |
358 | - struct nf_nat_protocol *p; | |
358 | + const struct nf_nat_protocol *p; | |
359 | 359 | |
360 | 360 | if (!skb_make_writable(skb, iphdroff + sizeof(*iph))) |
361 | 361 | return 0; |
... | ... | @@ -515,7 +515,7 @@ |
515 | 515 | EXPORT_SYMBOL_GPL(nf_nat_icmp_reply_translation); |
516 | 516 | |
517 | 517 | /* Protocol registration. */ |
518 | -int nf_nat_protocol_register(struct nf_nat_protocol *proto) | |
518 | +int nf_nat_protocol_register(const struct nf_nat_protocol *proto) | |
519 | 519 | { |
520 | 520 | int ret = 0; |
521 | 521 | |
... | ... | @@ -532,7 +532,7 @@ |
532 | 532 | EXPORT_SYMBOL(nf_nat_protocol_register); |
533 | 533 | |
534 | 534 | /* Noone stores the protocol anywhere; simply delete it. */ |
535 | -void nf_nat_protocol_unregister(struct nf_nat_protocol *proto) | |
535 | +void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto) | |
536 | 536 | { |
537 | 537 | write_lock_bh(&nf_nat_lock); |
538 | 538 | rcu_assign_pointer(nf_nat_protos[proto->protonum], |
net/ipv4/netfilter/nf_nat_proto_gre.c
net/ipv4/netfilter/nf_nat_proto_icmp.c
net/ipv4/netfilter/nf_nat_proto_tcp.c
net/ipv4/netfilter/nf_nat_proto_udp.c
net/ipv4/netfilter/nf_nat_proto_unknown.c
net/netfilter/nf_conntrack_netlink.c
... | ... | @@ -695,7 +695,7 @@ |
695 | 695 | struct nf_nat_range *range) |
696 | 696 | { |
697 | 697 | struct nlattr *tb[CTA_PROTONAT_MAX+1]; |
698 | - struct nf_nat_protocol *npt; | |
698 | + const struct nf_nat_protocol *npt; | |
699 | 699 | int err; |
700 | 700 | |
701 | 701 | err = nla_parse_nested(tb, CTA_PROTONAT_MAX, attr, protonat_nla_policy); |