2 +++ b/include/net/xfrmudp.h
5 + * pointer to function for type that xfrm4_input wants, to permit
6 + * decoupling of XFRM from udp.c
8 +#define HAVE_XFRM4_UDP_REGISTER
10 +typedef int (*xfrm4_rcv_encap_t)(struct sk_buff *skb, __u16 encap_type);
11 +extern int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
12 + , xfrm4_rcv_encap_t *oldfunc);
13 +extern int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func);
14 --- a/net/ipv4/Kconfig
15 +++ b/net/ipv4/Kconfig
16 @@ -224,6 +224,12 @@ config NET_IPGRE_BROADCAST
17 Network), but can be distributed all over the Internet. If you want
18 to do that, say Y here and to "IP multicast routing" below.
20 +config IPSEC_NAT_TRAVERSAL
21 + bool "IPSEC NAT-Traversal (KLIPS compatible)"
24 + Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
27 bool "IP: multicast routing"
28 depends on IP_MULTICAST
29 --- a/net/ipv4/xfrm4_input.c
30 +++ b/net/ipv4/xfrm4_input.c
32 #include <linux/netfilter_ipv4.h>
35 +#include <net/xfrmudp.h>
37 static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq)
39 @@ -161,6 +162,29 @@ drop:
43 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
44 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
46 +int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func,
47 + xfrm4_rcv_encap_t *oldfunc)
50 + *oldfunc = xfrm4_rcv_encap_func;
52 + xfrm4_rcv_encap_func = func;
56 +int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
58 + if(xfrm4_rcv_encap_func != func)
61 + xfrm4_rcv_encap_func = NULL;
64 +#endif /* CONFIG_IPSEC_NAT_TRAVERSAL */
66 /* If it's a keepalive packet, then just eat it.
67 * If it's an encapsulated packet, then pass it to the
69 @@ -251,7 +275,13 @@ int xfrm4_udp_encap_rcv(struct sock *sk,
70 iph->protocol = IPPROTO_ESP;
73 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
74 + if(xfrm4_rcv_encap_func == NULL)
76 + ret = (*xfrm4_rcv_encap_func)(skb, up->encap_type);
78 ret = xfrm4_rcv_encap(skb, encap_type);
83 @@ -265,3 +295,8 @@ int xfrm4_rcv(struct sk_buff *skb)
86 EXPORT_SYMBOL(xfrm4_rcv);
88 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
89 +EXPORT_SYMBOL(udp4_register_esp_rcvencap);
90 +EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);