diff options
author | Patrick McHardy <kaber@trash.net> | 2011-01-20 04:33:55 -0500 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2011-01-20 04:33:55 -0500 |
commit | 82d800d8e7fa731b50deb851d16b68050673f587 (patch) | |
tree | 60acee6699b1cdb7fe5e2802947737dffeeeb6c9 | |
parent | 28a51ba59a1a983d63d4775e9bb8230fe0fb3b29 (diff) | |
parent | cc4fc022571376412986e27e08b0765e9cb2aafb (diff) |
Merge branch 'connlimit' of git://dev.medozas.de/linux
Conflicts:
Documentation/feature-removal-schedule.txt
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r-- | Documentation/feature-removal-schedule.txt | 7 | ||||
-rw-r--r-- | include/linux/netfilter/xt_connlimit.h | 12 | ||||
-rw-r--r-- | net/netfilter/xt_connlimit.c | 44 |
3 files changed, 49 insertions, 14 deletions
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt index 8c594c45b6a1..05b248aa91f1 100644 --- a/Documentation/feature-removal-schedule.txt +++ b/Documentation/feature-removal-schedule.txt | |||
@@ -611,3 +611,10 @@ Why: The adm9240, w83792d and w83793 hardware monitoring drivers have | |||
611 | Who: Jean Delvare <khali@linux-fr.org> | 611 | Who: Jean Delvare <khali@linux-fr.org> |
612 | 612 | ||
613 | ---------------------------- | 613 | ---------------------------- |
614 | |||
615 | What: xt_connlimit rev 0 | ||
616 | When: 2012 | ||
617 | Who: Jan Engelhardt <jengelh@medozas.de> | ||
618 | Files: net/netfilter/xt_connlimit.c | ||
619 | |||
620 | ---------------------------- | ||
diff --git a/include/linux/netfilter/xt_connlimit.h b/include/linux/netfilter/xt_connlimit.h index 7e3284bcbd2b..8884efc605c7 100644 --- a/include/linux/netfilter/xt_connlimit.h +++ b/include/linux/netfilter/xt_connlimit.h | |||
@@ -3,6 +3,11 @@ | |||
3 | 3 | ||
4 | struct xt_connlimit_data; | 4 | struct xt_connlimit_data; |
5 | 5 | ||
6 | enum { | ||
7 | XT_CONNLIMIT_INVERT = 1 << 0, | ||
8 | XT_CONNLIMIT_DADDR = 1 << 1, | ||
9 | }; | ||
10 | |||
6 | struct xt_connlimit_info { | 11 | struct xt_connlimit_info { |
7 | union { | 12 | union { |
8 | union nf_inet_addr mask; | 13 | union nf_inet_addr mask; |
@@ -14,6 +19,13 @@ struct xt_connlimit_info { | |||
14 | #endif | 19 | #endif |
15 | }; | 20 | }; |
16 | unsigned int limit, inverse; | 21 | unsigned int limit, inverse; |
22 | union { | ||
23 | /* revision 0 */ | ||
24 | unsigned int inverse; | ||
25 | |||
26 | /* revision 1 */ | ||
27 | __u32 flags; | ||
28 | }; | ||
17 | 29 | ||
18 | /* Used internally by the kernel */ | 30 | /* Used internally by the kernel */ |
19 | struct xt_connlimit_data *data __attribute__((aligned(8))); | 31 | struct xt_connlimit_data *data __attribute__((aligned(8))); |
diff --git a/net/netfilter/xt_connlimit.c b/net/netfilter/xt_connlimit.c index 452bc16af56c..7fd3fd51f274 100644 --- a/net/netfilter/xt_connlimit.c +++ b/net/netfilter/xt_connlimit.c | |||
@@ -193,10 +193,12 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) | |||
193 | 193 | ||
194 | if (par->family == NFPROTO_IPV6) { | 194 | if (par->family == NFPROTO_IPV6) { |
195 | const struct ipv6hdr *iph = ipv6_hdr(skb); | 195 | const struct ipv6hdr *iph = ipv6_hdr(skb); |
196 | memcpy(&addr.ip6, &iph->saddr, sizeof(iph->saddr)); | 196 | memcpy(&addr.ip6, (info->flags & XT_CONNLIMIT_DADDR) ? |
197 | &iph->daddr : &iph->saddr, sizeof(addr.ip6)); | ||
197 | } else { | 198 | } else { |
198 | const struct iphdr *iph = ip_hdr(skb); | 199 | const struct iphdr *iph = ip_hdr(skb); |
199 | addr.ip = iph->saddr; | 200 | addr.ip = (info->flags & XT_CONNLIMIT_DADDR) ? |
201 | iph->daddr : iph->saddr; | ||
200 | } | 202 | } |
201 | 203 | ||
202 | spin_lock_bh(&info->data->lock); | 204 | spin_lock_bh(&info->data->lock); |
@@ -208,7 +210,8 @@ connlimit_mt(const struct sk_buff *skb, struct xt_action_param *par) | |||
208 | /* kmalloc failed, drop it entirely */ | 210 | /* kmalloc failed, drop it entirely */ |
209 | goto hotdrop; | 211 | goto hotdrop; |
210 | 212 | ||
211 | return (connections > info->limit) ^ info->inverse; | 213 | return (connections > info->limit) ^ |
214 | !!(info->flags & XT_CONNLIMIT_INVERT); | ||
212 | 215 | ||
213 | hotdrop: | 216 | hotdrop: |
214 | par->hotdrop = true; | 217 | par->hotdrop = true; |
@@ -266,25 +269,38 @@ static void connlimit_mt_destroy(const struct xt_mtdtor_param *par) | |||
266 | kfree(info->data); | 269 | kfree(info->data); |
267 | } | 270 | } |
268 | 271 | ||
269 | static struct xt_match connlimit_mt_reg __read_mostly = { | 272 | static struct xt_match connlimit_mt_reg[] __read_mostly = { |
270 | .name = "connlimit", | 273 | { |
271 | .revision = 0, | 274 | .name = "connlimit", |
272 | .family = NFPROTO_UNSPEC, | 275 | .revision = 0, |
273 | .checkentry = connlimit_mt_check, | 276 | .family = NFPROTO_UNSPEC, |
274 | .match = connlimit_mt, | 277 | .checkentry = connlimit_mt_check, |
275 | .matchsize = sizeof(struct xt_connlimit_info), | 278 | .match = connlimit_mt, |
276 | .destroy = connlimit_mt_destroy, | 279 | .matchsize = sizeof(struct xt_connlimit_info), |
277 | .me = THIS_MODULE, | 280 | .destroy = connlimit_mt_destroy, |
281 | .me = THIS_MODULE, | ||
282 | }, | ||
283 | { | ||
284 | .name = "connlimit", | ||
285 | .revision = 1, | ||
286 | .family = NFPROTO_UNSPEC, | ||
287 | .checkentry = connlimit_mt_check, | ||
288 | .match = connlimit_mt, | ||
289 | .matchsize = sizeof(struct xt_connlimit_info), | ||
290 | .destroy = connlimit_mt_destroy, | ||
291 | .me = THIS_MODULE, | ||
292 | }, | ||
278 | }; | 293 | }; |
279 | 294 | ||
280 | static int __init connlimit_mt_init(void) | 295 | static int __init connlimit_mt_init(void) |
281 | { | 296 | { |
282 | return xt_register_match(&connlimit_mt_reg); | 297 | return xt_register_matches(connlimit_mt_reg, |
298 | ARRAY_SIZE(connlimit_mt_reg)); | ||
283 | } | 299 | } |
284 | 300 | ||
285 | static void __exit connlimit_mt_exit(void) | 301 | static void __exit connlimit_mt_exit(void) |
286 | { | 302 | { |
287 | xt_unregister_match(&connlimit_mt_reg); | 303 | xt_unregister_matches(connlimit_mt_reg, ARRAY_SIZE(connlimit_mt_reg)); |
288 | } | 304 | } |
289 | 305 | ||
290 | module_init(connlimit_mt_init); | 306 | module_init(connlimit_mt_init); |