diff options
author | Patrick McHardy <kaber@trash.net> | 2007-12-18 01:37:36 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:58:56 -0500 |
commit | 2b628a0866860d44652362aafe403e5b5895583d (patch) | |
tree | bb548f5ad7b7f932f8a8a52ff1922316750ae0ae | |
parent | 3ee9e760387c38558df976bc2905959826adf331 (diff) |
[NETFILTER]: nf_nat: mark NAT protocols const
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/netfilter/nf_nat_protocol.h | 18 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_core.c | 20 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_proto_gre.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_proto_icmp.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_proto_tcp.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_proto_udp.c | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/nf_nat_proto_unknown.c | 2 | ||||
-rw-r--r-- | net/netfilter/nf_conntrack_netlink.c | 2 |
8 files changed, 25 insertions, 25 deletions
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h index 04578bfe23e1..4aa0edbb5b96 100644 --- a/include/net/netfilter/nf_nat_protocol.h +++ b/include/net/netfilter/nf_nat_protocol.h | |||
@@ -46,21 +46,21 @@ struct nf_nat_protocol | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | /* Protocol registration. */ | 48 | /* Protocol registration. */ |
49 | extern int nf_nat_protocol_register(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(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); | 52 | extern const 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); | 53 | extern void nf_nat_proto_put(const struct nf_nat_protocol *proto); |
54 | 54 | ||
55 | /* Built-in protocols. */ | 55 | /* Built-in protocols. */ |
56 | extern struct nf_nat_protocol nf_nat_protocol_tcp; | 56 | extern const struct nf_nat_protocol nf_nat_protocol_tcp; |
57 | extern struct nf_nat_protocol nf_nat_protocol_udp; | 57 | extern const struct nf_nat_protocol nf_nat_protocol_udp; |
58 | extern struct nf_nat_protocol nf_nat_protocol_icmp; | 58 | extern const struct nf_nat_protocol nf_nat_protocol_icmp; |
59 | extern struct nf_nat_protocol nf_nat_unknown_protocol; | 59 | extern const struct nf_nat_protocol nf_nat_unknown_protocol; |
60 | 60 | ||
61 | extern int init_protocols(void) __init; | 61 | extern int init_protocols(void) __init; |
62 | extern void cleanup_protocols(void); | 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 | extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb, | 65 | extern int nf_nat_port_range_to_nlattr(struct sk_buff *skb, |
66 | const struct nf_nat_range *range); | 66 | const struct nf_nat_range *range); |
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index 4ee67e9f42ba..a772445228ac 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -42,18 +42,18 @@ static int nf_nat_vmalloced; | |||
42 | static struct hlist_head *bysource; | 42 | static struct hlist_head *bysource; |
43 | 43 | ||
44 | #define MAX_IP_NAT_PROTO 256 | 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 | __nf_nat_proto_find(u_int8_t protonum) | 48 | __nf_nat_proto_find(u_int8_t protonum) |
49 | { | 49 | { |
50 | return rcu_dereference(nf_nat_protos[protonum]); | 50 | return rcu_dereference(nf_nat_protos[protonum]); |
51 | } | 51 | } |
52 | 52 | ||
53 | struct nf_nat_protocol * | 53 | const struct nf_nat_protocol * |
54 | nf_nat_proto_find_get(u_int8_t protonum) | 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 | rcu_read_lock(); | 58 | rcu_read_lock(); |
59 | p = __nf_nat_proto_find(protonum); | 59 | p = __nf_nat_proto_find(protonum); |
@@ -66,7 +66,7 @@ nf_nat_proto_find_get(u_int8_t protonum) | |||
66 | EXPORT_SYMBOL_GPL(nf_nat_proto_find_get); | 66 | EXPORT_SYMBOL_GPL(nf_nat_proto_find_get); |
67 | 67 | ||
68 | void | 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 | module_put(p->me); | 71 | module_put(p->me); |
72 | } | 72 | } |
@@ -105,7 +105,7 @@ static int | |||
105 | in_range(const struct nf_conntrack_tuple *tuple, | 105 | in_range(const struct nf_conntrack_tuple *tuple, |
106 | const struct nf_nat_range *range) | 106 | const struct nf_nat_range *range) |
107 | { | 107 | { |
108 | struct nf_nat_protocol *proto; | 108 | const struct nf_nat_protocol *proto; |
109 | int ret = 0; | 109 | int ret = 0; |
110 | 110 | ||
111 | /* If we are supposed to map IPs, then we must be in the | 111 | /* If we are supposed to map IPs, then we must be in the |
@@ -226,7 +226,7 @@ get_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
226 | struct nf_conn *ct, | 226 | struct nf_conn *ct, |
227 | enum nf_nat_manip_type maniptype) | 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 | /* 1) If this srcip/proto/src-proto-part is currently mapped, | 231 | /* 1) If this srcip/proto/src-proto-part is currently mapped, |
232 | and that same mapping gives a unique tuple within the given | 232 | and that same mapping gives a unique tuple within the given |
@@ -355,7 +355,7 @@ manip_pkt(u_int16_t proto, | |||
355 | enum nf_nat_manip_type maniptype) | 355 | enum nf_nat_manip_type maniptype) |
356 | { | 356 | { |
357 | struct iphdr *iph; | 357 | struct iphdr *iph; |
358 | struct nf_nat_protocol *p; | 358 | const struct nf_nat_protocol *p; |
359 | 359 | ||
360 | if (!skb_make_writable(skb, iphdroff + sizeof(*iph))) | 360 | if (!skb_make_writable(skb, iphdroff + sizeof(*iph))) |
361 | return 0; | 361 | return 0; |
@@ -515,7 +515,7 @@ int nf_nat_icmp_reply_translation(struct nf_conn *ct, | |||
515 | EXPORT_SYMBOL_GPL(nf_nat_icmp_reply_translation); | 515 | EXPORT_SYMBOL_GPL(nf_nat_icmp_reply_translation); |
516 | 516 | ||
517 | /* Protocol registration. */ | 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 | int ret = 0; | 520 | int ret = 0; |
521 | 521 | ||
@@ -532,7 +532,7 @@ int nf_nat_protocol_register(struct nf_nat_protocol *proto) | |||
532 | EXPORT_SYMBOL(nf_nat_protocol_register); | 532 | EXPORT_SYMBOL(nf_nat_protocol_register); |
533 | 533 | ||
534 | /* Noone stores the protocol anywhere; simply delete it. */ | 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 | write_lock_bh(&nf_nat_lock); | 537 | write_lock_bh(&nf_nat_lock); |
538 | rcu_assign_pointer(nf_nat_protos[proto->protonum], | 538 | rcu_assign_pointer(nf_nat_protos[proto->protonum], |
diff --git a/net/ipv4/netfilter/nf_nat_proto_gre.c b/net/ipv4/netfilter/nf_nat_proto_gre.c index 945e0ae78ffa..9fa272e73113 100644 --- a/net/ipv4/netfilter/nf_nat_proto_gre.c +++ b/net/ipv4/netfilter/nf_nat_proto_gre.c | |||
@@ -135,7 +135,7 @@ gre_manip_pkt(struct sk_buff *skb, unsigned int iphdroff, | |||
135 | return 1; | 135 | return 1; |
136 | } | 136 | } |
137 | 137 | ||
138 | static struct nf_nat_protocol gre __read_mostly = { | 138 | static const struct nf_nat_protocol gre = { |
139 | .name = "GRE", | 139 | .name = "GRE", |
140 | .protonum = IPPROTO_GRE, | 140 | .protonum = IPPROTO_GRE, |
141 | .me = THIS_MODULE, | 141 | .me = THIS_MODULE, |
diff --git a/net/ipv4/netfilter/nf_nat_proto_icmp.c b/net/ipv4/netfilter/nf_nat_proto_icmp.c index 088bb141c15d..a0e44c953cb6 100644 --- a/net/ipv4/netfilter/nf_nat_proto_icmp.c +++ b/net/ipv4/netfilter/nf_nat_proto_icmp.c | |||
@@ -71,7 +71,7 @@ icmp_manip_pkt(struct sk_buff *skb, | |||
71 | return 1; | 71 | return 1; |
72 | } | 72 | } |
73 | 73 | ||
74 | struct nf_nat_protocol nf_nat_protocol_icmp = { | 74 | const struct nf_nat_protocol nf_nat_protocol_icmp = { |
75 | .name = "ICMP", | 75 | .name = "ICMP", |
76 | .protonum = IPPROTO_ICMP, | 76 | .protonum = IPPROTO_ICMP, |
77 | .me = THIS_MODULE, | 77 | .me = THIS_MODULE, |
diff --git a/net/ipv4/netfilter/nf_nat_proto_tcp.c b/net/ipv4/netfilter/nf_nat_proto_tcp.c index 633c53ff3d32..da23e9fbe679 100644 --- a/net/ipv4/netfilter/nf_nat_proto_tcp.c +++ b/net/ipv4/netfilter/nf_nat_proto_tcp.c | |||
@@ -137,7 +137,7 @@ tcp_manip_pkt(struct sk_buff *skb, | |||
137 | return 1; | 137 | return 1; |
138 | } | 138 | } |
139 | 139 | ||
140 | struct nf_nat_protocol nf_nat_protocol_tcp = { | 140 | const struct nf_nat_protocol nf_nat_protocol_tcp = { |
141 | .name = "TCP", | 141 | .name = "TCP", |
142 | .protonum = IPPROTO_TCP, | 142 | .protonum = IPPROTO_TCP, |
143 | .me = THIS_MODULE, | 143 | .me = THIS_MODULE, |
diff --git a/net/ipv4/netfilter/nf_nat_proto_udp.c b/net/ipv4/netfilter/nf_nat_proto_udp.c index 9c6519cd15f5..10df4db078af 100644 --- a/net/ipv4/netfilter/nf_nat_proto_udp.c +++ b/net/ipv4/netfilter/nf_nat_proto_udp.c | |||
@@ -127,7 +127,7 @@ udp_manip_pkt(struct sk_buff *skb, | |||
127 | return 1; | 127 | return 1; |
128 | } | 128 | } |
129 | 129 | ||
130 | struct nf_nat_protocol nf_nat_protocol_udp = { | 130 | const struct nf_nat_protocol nf_nat_protocol_udp = { |
131 | .name = "UDP", | 131 | .name = "UDP", |
132 | .protonum = IPPROTO_UDP, | 132 | .protonum = IPPROTO_UDP, |
133 | .me = THIS_MODULE, | 133 | .me = THIS_MODULE, |
diff --git a/net/ipv4/netfilter/nf_nat_proto_unknown.c b/net/ipv4/netfilter/nf_nat_proto_unknown.c index cfd2742e9706..a26efeb073cb 100644 --- a/net/ipv4/netfilter/nf_nat_proto_unknown.c +++ b/net/ipv4/netfilter/nf_nat_proto_unknown.c | |||
@@ -45,7 +45,7 @@ unknown_manip_pkt(struct sk_buff *skb, | |||
45 | return 1; | 45 | return 1; |
46 | } | 46 | } |
47 | 47 | ||
48 | struct nf_nat_protocol nf_nat_unknown_protocol = { | 48 | const struct nf_nat_protocol nf_nat_unknown_protocol = { |
49 | .name = "unknown", | 49 | .name = "unknown", |
50 | /* .me isn't set: getting a ref to this cannot fail. */ | 50 | /* .me isn't set: getting a ref to this cannot fail. */ |
51 | .manip_pkt = unknown_manip_pkt, | 51 | .manip_pkt = unknown_manip_pkt, |
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 75012585efe0..7851065ef206 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -695,7 +695,7 @@ static int nfnetlink_parse_nat_proto(struct nlattr *attr, | |||
695 | struct nf_nat_range *range) | 695 | struct nf_nat_range *range) |
696 | { | 696 | { |
697 | struct nlattr *tb[CTA_PROTONAT_MAX+1]; | 697 | struct nlattr *tb[CTA_PROTONAT_MAX+1]; |
698 | struct nf_nat_protocol *npt; | 698 | const struct nf_nat_protocol *npt; |
699 | int err; | 699 | int err; |
700 | 700 | ||
701 | err = nla_parse_nested(tb, CTA_PROTONAT_MAX, attr, protonat_nla_policy); | 701 | err = nla_parse_nested(tb, CTA_PROTONAT_MAX, attr, protonat_nla_policy); |