aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@computergmbh.de>2008-04-14 05:15:53 -0400
committerPatrick McHardy <kaber@trash.net>2008-04-14 05:15:53 -0400
commit5f2b4c9006fc667c4614f0b079efab3721f68316 (patch)
tree828631ee4bcbe4ba58ddfe24d95b2615f763c042
parent09f263cd39751cada63dec2dccc71e67c00bc38c (diff)
[NETFILTER]: nf_conntrack: use bool type in struct nf_conntrack_tuple.h
Signed-off-by: Jan Engelhardt <jengelh@computergmbh.de> Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--include/net/netfilter/nf_conntrack.h11
-rw-r--r--include/net/netfilter/nf_conntrack_core.h4
-rw-r--r--include/net/netfilter/nf_conntrack_tuple.h39
-rw-r--r--net/netfilter/nf_conntrack_core.c22
4 files changed, 38 insertions, 38 deletions
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 26e6a6e2b5a2..2dbd6c015b94 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -194,12 +194,11 @@ extern void nf_conntrack_hash_insert(struct nf_conn *ct);
194 194
195extern void nf_conntrack_flush(void); 195extern void nf_conntrack_flush(void);
196 196
197extern int nf_ct_get_tuplepr(const struct sk_buff *skb, 197extern bool nf_ct_get_tuplepr(const struct sk_buff *skb,
198 unsigned int nhoff, 198 unsigned int nhoff, u_int16_t l3num,
199 u_int16_t l3num, 199 struct nf_conntrack_tuple *tuple);
200 struct nf_conntrack_tuple *tuple); 200extern bool nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
201extern int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, 201 const struct nf_conntrack_tuple *orig);
202 const struct nf_conntrack_tuple *orig);
203 202
204extern void __nf_ct_refresh_acct(struct nf_conn *ct, 203extern void __nf_ct_refresh_acct(struct nf_conn *ct,
205 enum ip_conntrack_info ctinfo, 204 enum ip_conntrack_info ctinfo,
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index 9ee26469c759..a81771210934 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -30,7 +30,7 @@ extern void nf_conntrack_cleanup(void);
30extern int nf_conntrack_proto_init(void); 30extern int nf_conntrack_proto_init(void);
31extern void nf_conntrack_proto_fini(void); 31extern void nf_conntrack_proto_fini(void);
32 32
33extern int 33extern bool
34nf_ct_get_tuple(const struct sk_buff *skb, 34nf_ct_get_tuple(const struct sk_buff *skb,
35 unsigned int nhoff, 35 unsigned int nhoff,
36 unsigned int dataoff, 36 unsigned int dataoff,
@@ -40,7 +40,7 @@ nf_ct_get_tuple(const struct sk_buff *skb,
40 const struct nf_conntrack_l3proto *l3proto, 40 const struct nf_conntrack_l3proto *l3proto,
41 const struct nf_conntrack_l4proto *l4proto); 41 const struct nf_conntrack_l4proto *l4proto);
42 42
43extern int 43extern bool
44nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, 44nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
45 const struct nf_conntrack_tuple *orig, 45 const struct nf_conntrack_tuple *orig,
46 const struct nf_conntrack_l3proto *l3proto, 46 const struct nf_conntrack_l3proto *l3proto,
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h
index bdeec3461384..2722b13ecd6c 100644
--- a/include/net/netfilter/nf_conntrack_tuple.h
+++ b/include/net/netfilter/nf_conntrack_tuple.h
@@ -166,61 +166,64 @@ struct nf_conntrack_tuple_hash
166 166
167#endif /* __KERNEL__ */ 167#endif /* __KERNEL__ */
168 168
169static inline int __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, 169static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1,
170 const struct nf_conntrack_tuple *t2) 170 const struct nf_conntrack_tuple *t2)
171{ 171{
172 return (nf_inet_addr_cmp(&t1->src.u3, &t2->src.u3) && 172 return (nf_inet_addr_cmp(&t1->src.u3, &t2->src.u3) &&
173 t1->src.u.all == t2->src.u.all && 173 t1->src.u.all == t2->src.u.all &&
174 t1->src.l3num == t2->src.l3num); 174 t1->src.l3num == t2->src.l3num);
175} 175}
176 176
177static inline int __nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1, 177static inline bool __nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1,
178 const struct nf_conntrack_tuple *t2) 178 const struct nf_conntrack_tuple *t2)
179{ 179{
180 return (nf_inet_addr_cmp(&t1->dst.u3, &t2->dst.u3) && 180 return (nf_inet_addr_cmp(&t1->dst.u3, &t2->dst.u3) &&
181 t1->dst.u.all == t2->dst.u.all && 181 t1->dst.u.all == t2->dst.u.all &&
182 t1->dst.protonum == t2->dst.protonum); 182 t1->dst.protonum == t2->dst.protonum);
183} 183}
184 184
185static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1, 185static inline bool nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1,
186 const struct nf_conntrack_tuple *t2) 186 const struct nf_conntrack_tuple *t2)
187{ 187{
188 return __nf_ct_tuple_src_equal(t1, t2) && 188 return __nf_ct_tuple_src_equal(t1, t2) &&
189 __nf_ct_tuple_dst_equal(t1, t2); 189 __nf_ct_tuple_dst_equal(t1, t2);
190} 190}
191 191
192static inline int nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1, 192static inline bool
193 const struct nf_conntrack_tuple_mask *m2) 193nf_ct_tuple_mask_equal(const struct nf_conntrack_tuple_mask *m1,
194 const struct nf_conntrack_tuple_mask *m2)
194{ 195{
195 return (nf_inet_addr_cmp(&m1->src.u3, &m2->src.u3) && 196 return (nf_inet_addr_cmp(&m1->src.u3, &m2->src.u3) &&
196 m1->src.u.all == m2->src.u.all); 197 m1->src.u.all == m2->src.u.all);
197} 198}
198 199
199static inline int nf_ct_tuple_src_mask_cmp(const struct nf_conntrack_tuple *t1, 200static inline bool
200 const struct nf_conntrack_tuple *t2, 201nf_ct_tuple_src_mask_cmp(const struct nf_conntrack_tuple *t1,
201 const struct nf_conntrack_tuple_mask *mask) 202 const struct nf_conntrack_tuple *t2,
203 const struct nf_conntrack_tuple_mask *mask)
202{ 204{
203 int count; 205 int count;
204 206
205 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++) { 207 for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++) {
206 if ((t1->src.u3.all[count] ^ t2->src.u3.all[count]) & 208 if ((t1->src.u3.all[count] ^ t2->src.u3.all[count]) &
207 mask->src.u3.all[count]) 209 mask->src.u3.all[count])
208 return 0; 210 return false;
209 } 211 }
210 212
211 if ((t1->src.u.all ^ t2->src.u.all) & mask->src.u.all) 213 if ((t1->src.u.all ^ t2->src.u.all) & mask->src.u.all)
212 return 0; 214 return false;
213 215
214 if (t1->src.l3num != t2->src.l3num || 216 if (t1->src.l3num != t2->src.l3num ||
215 t1->dst.protonum != t2->dst.protonum) 217 t1->dst.protonum != t2->dst.protonum)
216 return 0; 218 return false;
217 219
218 return 1; 220 return true;
219} 221}
220 222
221static inline int nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t, 223static inline bool
222 const struct nf_conntrack_tuple *tuple, 224nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t,
223 const struct nf_conntrack_tuple_mask *mask) 225 const struct nf_conntrack_tuple *tuple,
226 const struct nf_conntrack_tuple_mask *mask)
224{ 227{
225 return nf_ct_tuple_src_mask_cmp(t, tuple, mask) && 228 return nf_ct_tuple_src_mask_cmp(t, tuple, mask) &&
226 __nf_ct_tuple_dst_equal(t, tuple); 229 __nf_ct_tuple_dst_equal(t, tuple);
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 21ab0c3846ac..a3fe9db412d3 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -94,7 +94,7 @@ static inline u_int32_t hash_conntrack(const struct nf_conntrack_tuple *tuple)
94 nf_conntrack_hash_rnd); 94 nf_conntrack_hash_rnd);
95} 95}
96 96
97int 97bool
98nf_ct_get_tuple(const struct sk_buff *skb, 98nf_ct_get_tuple(const struct sk_buff *skb,
99 unsigned int nhoff, 99 unsigned int nhoff,
100 unsigned int dataoff, 100 unsigned int dataoff,
@@ -108,7 +108,7 @@ nf_ct_get_tuple(const struct sk_buff *skb,
108 108
109 tuple->src.l3num = l3num; 109 tuple->src.l3num = l3num;
110 if (l3proto->pkt_to_tuple(skb, nhoff, tuple) == 0) 110 if (l3proto->pkt_to_tuple(skb, nhoff, tuple) == 0)
111 return 0; 111 return false;
112 112
113 tuple->dst.protonum = protonum; 113 tuple->dst.protonum = protonum;
114 tuple->dst.dir = IP_CT_DIR_ORIGINAL; 114 tuple->dst.dir = IP_CT_DIR_ORIGINAL;
@@ -117,10 +117,8 @@ nf_ct_get_tuple(const struct sk_buff *skb,
117} 117}
118EXPORT_SYMBOL_GPL(nf_ct_get_tuple); 118EXPORT_SYMBOL_GPL(nf_ct_get_tuple);
119 119
120int nf_ct_get_tuplepr(const struct sk_buff *skb, 120bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff,
121 unsigned int nhoff, 121 u_int16_t l3num, struct nf_conntrack_tuple *tuple)
122 u_int16_t l3num,
123 struct nf_conntrack_tuple *tuple)
124{ 122{
125 struct nf_conntrack_l3proto *l3proto; 123 struct nf_conntrack_l3proto *l3proto;
126 struct nf_conntrack_l4proto *l4proto; 124 struct nf_conntrack_l4proto *l4proto;
@@ -134,7 +132,7 @@ int nf_ct_get_tuplepr(const struct sk_buff *skb,
134 ret = l3proto->get_l4proto(skb, nhoff, &protoff, &protonum); 132 ret = l3proto->get_l4proto(skb, nhoff, &protoff, &protonum);
135 if (ret != NF_ACCEPT) { 133 if (ret != NF_ACCEPT) {
136 rcu_read_unlock(); 134 rcu_read_unlock();
137 return 0; 135 return false;
138 } 136 }
139 137
140 l4proto = __nf_ct_l4proto_find(l3num, protonum); 138 l4proto = __nf_ct_l4proto_find(l3num, protonum);
@@ -147,7 +145,7 @@ int nf_ct_get_tuplepr(const struct sk_buff *skb,
147} 145}
148EXPORT_SYMBOL_GPL(nf_ct_get_tuplepr); 146EXPORT_SYMBOL_GPL(nf_ct_get_tuplepr);
149 147
150int 148bool
151nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, 149nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
152 const struct nf_conntrack_tuple *orig, 150 const struct nf_conntrack_tuple *orig,
153 const struct nf_conntrack_l3proto *l3proto, 151 const struct nf_conntrack_l3proto *l3proto,
@@ -157,7 +155,7 @@ nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse,
157 155
158 inverse->src.l3num = orig->src.l3num; 156 inverse->src.l3num = orig->src.l3num;
159 if (l3proto->invert_tuple(inverse, orig) == 0) 157 if (l3proto->invert_tuple(inverse, orig) == 0)
160 return 0; 158 return false;
161 159
162 inverse->dst.dir = !orig->dst.dir; 160 inverse->dst.dir = !orig->dst.dir;
163 161
@@ -738,10 +736,10 @@ nf_conntrack_in(int pf, unsigned int hooknum, struct sk_buff *skb)
738} 736}
739EXPORT_SYMBOL_GPL(nf_conntrack_in); 737EXPORT_SYMBOL_GPL(nf_conntrack_in);
740 738
741int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, 739bool nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse,
742 const struct nf_conntrack_tuple *orig) 740 const struct nf_conntrack_tuple *orig)
743{ 741{
744 int ret; 742 bool ret;
745 743
746 rcu_read_lock(); 744 rcu_read_lock();
747 ret = nf_ct_invert_tuple(inverse, orig, 745 ret = nf_ct_invert_tuple(inverse, orig,