Commit 2b628a0866860d44652362aafe403e5b5895583d

Authored by Patrick McHardy
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
... ... @@ -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
... ... @@ -135,7 +135,7 @@
135 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 139 .name = "GRE",
140 140 .protonum = IPPROTO_GRE,
141 141 .me = THIS_MODULE,
net/ipv4/netfilter/nf_nat_proto_icmp.c
... ... @@ -71,7 +71,7 @@
71 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 75 .name = "ICMP",
76 76 .protonum = IPPROTO_ICMP,
77 77 .me = THIS_MODULE,
net/ipv4/netfilter/nf_nat_proto_tcp.c
... ... @@ -137,7 +137,7 @@
137 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 141 .name = "TCP",
142 142 .protonum = IPPROTO_TCP,
143 143 .me = THIS_MODULE,
net/ipv4/netfilter/nf_nat_proto_udp.c
... ... @@ -127,7 +127,7 @@
127 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 131 .name = "UDP",
132 132 .protonum = IPPROTO_UDP,
133 133 .me = THIS_MODULE,
net/ipv4/netfilter/nf_nat_proto_unknown.c
... ... @@ -45,7 +45,7 @@
45 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 49 .name = "unknown",
50 50 /* .me isn't set: getting a ref to this cannot fail. */
51 51 .manip_pkt = unknown_manip_pkt,
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);