aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Engelhardt <jengelh@medozas.de>2011-01-26 05:50:03 -0500
committerJan Engelhardt <jengelh@medozas.de>2011-01-26 07:01:39 -0500
commitad86e1f27a9a97a9e50810b10bca678407b1d6fd (patch)
tree1ad952ca2f4e5b4e9e4a950861199aaaf9537117
parent4b3fd57138c969dd940651fadf90db627254edbf (diff)
netfilter: xt_connlimit: pick right dstaddr in NAT scenario
xt_connlimit normally records the "original" tuples in a hashlist (such as "1.2.3.4 -> 5.6.7.8"), and looks in this list for iph->daddr when counting. When the user however uses DNAT in PREROUTING, looking for iph->daddr -- which is now 192.168.9.10 -- will not match. Thus in daddr mode, we need to record the reverse direction tuple ("192.168.9.10 -> 1.2.3.4") instead. In the reverse tuple, the dst addr is on the src side, which is convenient, as count_them still uses &conn->tuple.src.u3. Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
-rw-r--r--net/netfilter/xt_connlimit.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c
index 7fd3fd51f27..e029c480740 100644
--- a/net/netfilter/xt_connlimit.c
+++ b/net/netfilter/xt_connlimit.c
@@ -185,11 +185,15 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par)
185 int connections; 185 int connections;
186 186
187 ct = nf_ct_get(skb, &ctinfo); 187 ct = nf_ct_get(skb, &ctinfo);
188 if (ct != NULL) 188 if (ct != NULL) {
189 tuple_ptr = &ct->tuplehash[0].tuple; 189 if (info->flags & XT_CONNLIMIT_DADDR)
190 else if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb), 190 tuple_ptr = &ct->tuplehash[IP_CT_DIR_REPLY].tuple;
191 par->family, &tuple)) 191 else
192 tuple_ptr = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
193 } else if (!nf_ct_get_tuplepr(skb, skb_network_offset(skb),
194 par->family, &tuple)) {
192 goto hotdrop; 195 goto hotdrop;
196 }
193 197
194 if (par->family == NFPROTO_IPV6) { 198 if (par->family == NFPROTO_IPV6) {
195 const struct ipv6hdr *iph = ipv6_hdr(skb); 199 const struct ipv6hdr *iph = ipv6_hdr(skb);