2008-05-19 04:24:51 +08:00
|
|
|
Index: linux-2.6.23.17/include/net/xfrmudp.h
|
2007-10-04 10:26:27 +08:00
|
|
|
===================================================================
|
2008-05-19 04:24:51 +08:00
|
|
|
--- /dev/null
|
|
|
|
+++ linux-2.6.23.17/include/net/xfrmudp.h
|
2007-10-04 10:26:27 +08:00
|
|
|
@@ -0,0 +1,10 @@
|
|
|
|
+/*
|
|
|
|
+ * pointer to function for type that xfrm4_input wants, to permit
|
|
|
|
+ * decoupling of XFRM from udp.c
|
|
|
|
+ */
|
|
|
|
+#define HAVE_XFRM4_UDP_REGISTER
|
|
|
|
+
|
|
|
|
+typedef int (*xfrm4_rcv_encap_t)(struct sk_buff *skb, __u16 encap_type);
|
|
|
|
+extern int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
|
|
|
|
+ , xfrm4_rcv_encap_t *oldfunc);
|
|
|
|
+extern int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func);
|
2008-05-19 04:24:51 +08:00
|
|
|
Index: linux-2.6.23.17/net/ipv4/Kconfig
|
2007-10-04 10:26:27 +08:00
|
|
|
===================================================================
|
2008-05-19 04:24:51 +08:00
|
|
|
--- linux-2.6.23.17.orig/net/ipv4/Kconfig
|
|
|
|
+++ linux-2.6.23.17/net/ipv4/Kconfig
|
|
|
|
@@ -224,6 +224,12 @@ config NET_IPGRE_BROADCAST
|
2007-10-04 10:26:27 +08:00
|
|
|
Network), but can be distributed all over the Internet. If you want
|
|
|
|
to do that, say Y here and to "IP multicast routing" below.
|
|
|
|
|
|
|
|
+config IPSEC_NAT_TRAVERSAL
|
|
|
|
+ bool "IPSEC NAT-Traversal (KLIPS compatible)"
|
|
|
|
+ depends on INET
|
|
|
|
+ ---help---
|
|
|
|
+ Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
|
|
|
|
+
|
|
|
|
config IP_MROUTE
|
|
|
|
bool "IP: multicast routing"
|
|
|
|
depends on IP_MULTICAST
|
2008-05-19 04:24:51 +08:00
|
|
|
Index: linux-2.6.23.17/net/ipv4/xfrm4_input.c
|
2007-10-04 10:26:27 +08:00
|
|
|
===================================================================
|
2008-05-19 04:24:51 +08:00
|
|
|
--- linux-2.6.23.17.orig/net/ipv4/xfrm4_input.c
|
|
|
|
+++ linux-2.6.23.17/net/ipv4/xfrm4_input.c
|
2007-10-04 10:26:27 +08:00
|
|
|
@@ -15,6 +15,7 @@
|
|
|
|
#include <linux/netfilter_ipv4.h>
|
|
|
|
#include <net/ip.h>
|
|
|
|
#include <net/xfrm.h>
|
|
|
|
+#include <net/xfrmudp.h>
|
|
|
|
|
|
|
|
static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq)
|
|
|
|
{
|
2008-05-19 04:24:51 +08:00
|
|
|
@@ -161,6 +162,29 @@ drop:
|
2007-10-04 10:26:27 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
|
|
|
|
+static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
|
|
|
|
+
|
|
|
|
+int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func,
|
|
|
|
+ xfrm4_rcv_encap_t *oldfunc)
|
|
|
|
+{
|
|
|
|
+ if(oldfunc != NULL)
|
|
|
|
+ *oldfunc = xfrm4_rcv_encap_func;
|
|
|
|
+
|
|
|
|
+ xfrm4_rcv_encap_func = func;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
|
|
|
|
+{
|
|
|
|
+ if(xfrm4_rcv_encap_func != func)
|
|
|
|
+ return -1;
|
|
|
|
+
|
|
|
|
+ xfrm4_rcv_encap_func = NULL;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+#endif /* CONFIG_IPSEC_NAT_TRAVERSAL */
|
|
|
|
+
|
|
|
|
/* If it's a keepalive packet, then just eat it.
|
|
|
|
* If it's an encapsulated packet, then pass it to the
|
|
|
|
* IPsec xfrm input.
|
2008-05-19 04:24:51 +08:00
|
|
|
@@ -251,7 +275,13 @@ int xfrm4_udp_encap_rcv(struct sock *sk,
|
2007-10-04 10:26:27 +08:00
|
|
|
iph->protocol = IPPROTO_ESP;
|
|
|
|
|
|
|
|
/* process ESP */
|
|
|
|
+#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
|
|
|
|
+ if(xfrm4_rcv_encap_func == NULL)
|
|
|
|
+ goto drop;
|
|
|
|
+ ret = (*xfrm4_rcv_encap_func)(skb, up->encap_type);
|
|
|
|
+#else
|
|
|
|
ret = xfrm4_rcv_encap(skb, encap_type);
|
|
|
|
+#endif
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
drop:
|
2008-05-19 04:24:51 +08:00
|
|
|
@@ -265,3 +295,8 @@ int xfrm4_rcv(struct sk_buff *skb)
|
2007-10-04 10:26:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
EXPORT_SYMBOL(xfrm4_rcv);
|
|
|
|
+
|
|
|
|
+#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
|
|
|
|
+EXPORT_SYMBOL(udp4_register_esp_rcvencap);
|
|
|
|
+EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);
|
|
|
|
+#endif
|