1 Index: linux-2.6.22.19/include/net/xfrmudp.h
2 ===================================================================
4 +++ linux-2.6.22.19/include/net/xfrmudp.h
7 + * pointer to function for type that xfrm4_input wants, to permit
8 + * decoupling of XFRM from udp.c
10 +#define HAVE_XFRM4_UDP_REGISTER
12 +typedef int (*xfrm4_rcv_encap_t)(struct sk_buff *skb, __u16 encap_type);
13 +extern int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
14 + , xfrm4_rcv_encap_t *oldfunc);
15 +extern int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func);
16 Index: linux-2.6.22.19/net/ipv4/Kconfig
17 ===================================================================
18 --- linux-2.6.22.19.orig/net/ipv4/Kconfig
19 +++ linux-2.6.22.19/net/ipv4/Kconfig
20 @@ -266,6 +266,12 @@ config NET_IPGRE_BROADCAST
21 Network), but can be distributed all over the Internet. If you want
22 to do that, say Y here and to "IP multicast routing" below.
24 +config IPSEC_NAT_TRAVERSAL
25 + bool "IPSEC NAT-Traversal (KLIPS compatible)"
28 + Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
31 bool "IP: multicast routing"
32 depends on IP_MULTICAST
33 Index: linux-2.6.22.19/net/ipv4/udp.c
34 ===================================================================
35 --- linux-2.6.22.19.orig/net/ipv4/udp.c
36 +++ linux-2.6.22.19/net/ipv4/udp.c
38 #include <net/route.h>
39 #include <net/checksum.h>
41 +#include <net/xfrmudp.h>
45 * Snmp MIB for the UDP layer
48 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func;
50 DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
52 struct hlist_head udp_hash[UDP_HTABLE_SIZE];
53 @@ -919,6 +922,42 @@ int udp_disconnect(struct sock *sk, int
57 +#if defined(CONFIG_XFRM) || defined(CONFIG_IPSEC_NAT_TRAVERSAL)
59 +/* if XFRM isn't a module, then register it directly. */
60 +#if 0 && !defined(CONFIG_XFRM_MODULE) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
61 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = xfrm4_rcv_encap;
63 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
66 +int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
67 + , xfrm4_rcv_encap_t *oldfunc)
69 + if(oldfunc != NULL) {
70 + *oldfunc = xfrm4_rcv_encap_func;
74 + if(xfrm4_rcv_encap_func != NULL)
78 + xfrm4_rcv_encap_func = func;
82 +int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
84 + if(xfrm4_rcv_encap_func != func)
87 + xfrm4_rcv_encap_func = NULL;
90 +#endif /* CONFIG_XFRM_MODULE || CONFIG_IPSEC_NAT_TRAVERSAL */
94 * 1 if the UDP system should process it
95 * 0 if we should drop this packet
96 @@ -926,7 +965,7 @@ int udp_disconnect(struct sock *sk, int
98 static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
101 +#if !defined(CONFIG_XFRM) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
104 struct udp_sock *up = udp_sk(sk);
105 @@ -941,11 +980,11 @@ static int udp_encap_rcv(struct sock * s
106 /* if we're overly short, let UDP handle it */
107 len = skb->len - sizeof(struct udphdr);
112 /* if this is not encapsulated socket, then just return now */
117 /* If this is a paged skb, make sure we pull up
118 * whatever data we need to look at. */
119 @@ -968,7 +1007,7 @@ static int udp_encap_rcv(struct sock * s
120 len = sizeof(struct udphdr);
122 /* Must be an IKE packet.. pass it through */
126 case UDP_ENCAP_ESPINUDP_NON_IKE:
127 /* Check if this is a keepalive packet. If so, eat it. */
128 @@ -981,7 +1020,7 @@ static int udp_encap_rcv(struct sock * s
129 len = sizeof(struct udphdr) + 2 * sizeof(u32);
131 /* Must be an IKE packet.. pass it through */
137 @@ -992,6 +1031,8 @@ static int udp_encap_rcv(struct sock * s
139 if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
141 + if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
144 /* Now we can update and verify the packet length... */
146 @@ -1056,9 +1097,13 @@ int udp_queue_rcv_skb(struct sock * sk,
150 - /* process the ESP packet */
151 - ret = xfrm4_rcv_encap(skb, up->encap_type);
152 - UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
153 + if(xfrm4_rcv_encap_func != NULL) {
154 + ret = (*xfrm4_rcv_encap_func)(skb, up->encap_type);
155 + UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
157 + UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
162 /* FALLTHROUGH -- it's a UDP Packet */
163 @@ -1742,3 +1787,9 @@ EXPORT_SYMBOL(udp_poll);
164 EXPORT_SYMBOL(udp_proc_register);
165 EXPORT_SYMBOL(udp_proc_unregister);
168 +#if defined(CONFIG_IPSEC_NAT_TRAVERSAL)
169 +EXPORT_SYMBOL(udp4_register_esp_rcvencap);
170 +EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);