diff options
author | Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> | 2006-04-01 05:22:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-04-01 05:22:30 -0500 |
commit | dc5ab2faece3b7473931357db7f63f596678481d (patch) | |
tree | d1e5fd3e805e7d2c4136459cca17d5f8ed44bfb6 /net/ipv4 | |
parent | 9606a21635cec077e1928273751b44ecc824a49d (diff) |
[NETFILTER]: x_tables: unify IPv4/IPv6 esp match
This unifies ipt_esp and ip6t_esp to xt_esp. Please note that now
a user program needs to specify IPPROTO_ESP as protocol to use esp match
with IPv6. This means that ip6tables requires '-p esp' like iptables.
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/netfilter/Kconfig | 8 | ||||
-rw-r--r-- | net/ipv4/netfilter/Makefile | 2 | ||||
-rw-r--r-- | net/ipv4/netfilter/ipt_esp.c | 111 |
3 files changed, 5 insertions, 116 deletions
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index 882b842c25d4..ebbd644fa8c4 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig | |||
@@ -272,12 +272,12 @@ config IP_NF_MATCH_DSCP | |||
272 | 272 | ||
273 | To compile it as a module, choose M here. If unsure, say N. | 273 | To compile it as a module, choose M here. If unsure, say N. |
274 | 274 | ||
275 | config IP_NF_MATCH_AH_ESP | 275 | config IP_NF_MATCH_AH |
276 | tristate "AH/ESP match support" | 276 | tristate "AH match support" |
277 | depends on IP_NF_IPTABLES | 277 | depends on IP_NF_IPTABLES |
278 | help | 278 | help |
279 | These two match extensions (`ah' and `esp') allow you to match a | 279 | This match extension allows you to match a range of SPIs |
280 | range of SPIs inside AH or ESP headers of IPSec packets. | 280 | inside AH header of IPSec packets. |
281 | 281 | ||
282 | To compile it as a module, choose M here. If unsure, say N. | 282 | To compile it as a module, choose M here. If unsure, say N. |
283 | 283 | ||
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile index f2cd9a6c5b91..09ae167632e7 100644 --- a/net/ipv4/netfilter/Makefile +++ b/net/ipv4/netfilter/Makefile | |||
@@ -59,7 +59,7 @@ obj-$(CONFIG_IP_NF_MATCH_TOS) += ipt_tos.o | |||
59 | obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o | 59 | obj-$(CONFIG_IP_NF_MATCH_RECENT) += ipt_recent.o |
60 | obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o | 60 | obj-$(CONFIG_IP_NF_MATCH_ECN) += ipt_ecn.o |
61 | obj-$(CONFIG_IP_NF_MATCH_DSCP) += ipt_dscp.o | 61 | obj-$(CONFIG_IP_NF_MATCH_DSCP) += ipt_dscp.o |
62 | obj-$(CONFIG_IP_NF_MATCH_AH_ESP) += ipt_ah.o ipt_esp.o | 62 | obj-$(CONFIG_IP_NF_MATCH_AH) += ipt_ah.o |
63 | obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o | 63 | obj-$(CONFIG_IP_NF_MATCH_TTL) += ipt_ttl.o |
64 | obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o | 64 | obj-$(CONFIG_IP_NF_MATCH_ADDRTYPE) += ipt_addrtype.o |
65 | 65 | ||
diff --git a/net/ipv4/netfilter/ipt_esp.c b/net/ipv4/netfilter/ipt_esp.c deleted file mode 100644 index 3840b417a3c5..000000000000 --- a/net/ipv4/netfilter/ipt_esp.c +++ /dev/null | |||
@@ -1,111 +0,0 @@ | |||
1 | /* Kernel module to match ESP parameters. */ | ||
2 | |||
3 | /* (C) 1999-2000 Yon Uriarte <yon@astaro.de> | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify | ||
6 | * it under the terms of the GNU General Public License version 2 as | ||
7 | * published by the Free Software Foundation. | ||
8 | */ | ||
9 | |||
10 | #include <linux/module.h> | ||
11 | #include <linux/skbuff.h> | ||
12 | #include <linux/ip.h> | ||
13 | |||
14 | #include <linux/netfilter_ipv4/ipt_esp.h> | ||
15 | #include <linux/netfilter_ipv4/ip_tables.h> | ||
16 | |||
17 | MODULE_LICENSE("GPL"); | ||
18 | MODULE_AUTHOR("Yon Uriarte <yon@astaro.de>"); | ||
19 | MODULE_DESCRIPTION("iptables ESP SPI match module"); | ||
20 | |||
21 | #ifdef DEBUG_CONNTRACK | ||
22 | #define duprintf(format, args...) printk(format , ## args) | ||
23 | #else | ||
24 | #define duprintf(format, args...) | ||
25 | #endif | ||
26 | |||
27 | /* Returns 1 if the spi is matched by the range, 0 otherwise */ | ||
28 | static inline int | ||
29 | spi_match(u_int32_t min, u_int32_t max, u_int32_t spi, int invert) | ||
30 | { | ||
31 | int r=0; | ||
32 | duprintf("esp spi_match:%c 0x%x <= 0x%x <= 0x%x",invert? '!':' ', | ||
33 | min,spi,max); | ||
34 | r=(spi >= min && spi <= max) ^ invert; | ||
35 | duprintf(" result %s\n",r? "PASS" : "FAILED"); | ||
36 | return r; | ||
37 | } | ||
38 | |||
39 | static int | ||
40 | match(const struct sk_buff *skb, | ||
41 | const struct net_device *in, | ||
42 | const struct net_device *out, | ||
43 | const struct xt_match *match, | ||
44 | const void *matchinfo, | ||
45 | int offset, | ||
46 | unsigned int protoff, | ||
47 | int *hotdrop) | ||
48 | { | ||
49 | struct ip_esp_hdr _esp, *eh; | ||
50 | const struct ipt_esp *espinfo = matchinfo; | ||
51 | |||
52 | /* Must not be a fragment. */ | ||
53 | if (offset) | ||
54 | return 0; | ||
55 | |||
56 | eh = skb_header_pointer(skb, protoff, | ||
57 | sizeof(_esp), &_esp); | ||
58 | if (eh == NULL) { | ||
59 | /* We've been asked to examine this packet, and we | ||
60 | * can't. Hence, no choice but to drop. | ||
61 | */ | ||
62 | duprintf("Dropping evil ESP tinygram.\n"); | ||
63 | *hotdrop = 1; | ||
64 | return 0; | ||
65 | } | ||
66 | |||
67 | return spi_match(espinfo->spis[0], espinfo->spis[1], | ||
68 | ntohl(eh->spi), | ||
69 | !!(espinfo->invflags & IPT_ESP_INV_SPI)); | ||
70 | } | ||
71 | |||
72 | /* Called when user tries to insert an entry of this type. */ | ||
73 | static int | ||
74 | checkentry(const char *tablename, | ||
75 | const void *ip_void, | ||
76 | const struct xt_match *match, | ||
77 | void *matchinfo, | ||
78 | unsigned int matchinfosize, | ||
79 | unsigned int hook_mask) | ||
80 | { | ||
81 | const struct ipt_esp *espinfo = matchinfo; | ||
82 | |||
83 | /* Must specify no unknown invflags */ | ||
84 | if (espinfo->invflags & ~IPT_ESP_INV_MASK) { | ||
85 | duprintf("ipt_esp: unknown flags %X\n", espinfo->invflags); | ||
86 | return 0; | ||
87 | } | ||
88 | return 1; | ||
89 | } | ||
90 | |||
91 | static struct ipt_match esp_match = { | ||
92 | .name = "esp", | ||
93 | .match = match, | ||
94 | .matchsize = sizeof(struct ipt_esp), | ||
95 | .proto = IPPROTO_ESP, | ||
96 | .checkentry = checkentry, | ||
97 | .me = THIS_MODULE, | ||
98 | }; | ||
99 | |||
100 | static int __init ipt_esp_init(void) | ||
101 | { | ||
102 | return ipt_register_match(&esp_match); | ||
103 | } | ||
104 | |||
105 | static void __exit ipt_esp_fini(void) | ||
106 | { | ||
107 | ipt_unregister_match(&esp_match); | ||
108 | } | ||
109 | |||
110 | module_init(ipt_esp_init); | ||
111 | module_exit(ipt_esp_fini); | ||