1 diff -urN linux-2.6.21.1.old/include/net/xfrmudp.h linux-2.6.21.1.dev/include/net/xfrmudp.h
2 --- linux-2.6.21.1.old/include/net/xfrmudp.h 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.21.1.dev/include/net/xfrmudp.h 2007-05-26 20:24:53.933599448 +0200
6 + * pointer to function for type that xfrm4_input wants, to permit
7 + * decoupling of XFRM from udp.c
9 +#define HAVE_XFRM4_UDP_REGISTER
11 +typedef int (*xfrm4_rcv_encap_t)(struct sk_buff *skb, __u16 encap_type);
12 +extern int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
13 + , xfrm4_rcv_encap_t *oldfunc);
14 +extern int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func);
15 diff -urN linux-2.6.21.1.old/net/ipv4/Kconfig linux-2.6.21.1.dev/net/ipv4/Kconfig
16 --- linux-2.6.21.1.old/net/ipv4/Kconfig 2007-04-27 23:49:26.000000000 +0200
17 +++ linux-2.6.21.1.dev/net/ipv4/Kconfig 2007-05-26 20:24:53.965594584 +0200
19 Network), but can be distributed all over the Internet. If you want
20 to do that, say Y here and to "IP multicast routing" below.
22 +config IPSEC_NAT_TRAVERSAL
23 + bool "IPSEC NAT-Traversal (KLIPS compatible)"
26 + Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
29 bool "IP: multicast routing"
30 depends on IP_MULTICAST
31 diff -urN linux-2.6.21.1.old/net/ipv4/udp.c linux-2.6.21.1.dev/net/ipv4/udp.c
32 --- linux-2.6.21.1.old/net/ipv4/udp.c 2007-04-27 23:49:26.000000000 +0200
33 +++ linux-2.6.21.1.dev/net/ipv4/udp.c 2007-05-26 20:24:53.966594432 +0200
35 #include <net/route.h>
36 #include <net/checksum.h>
38 +#include <net/xfrmudp.h>
42 * Snmp MIB for the UDP layer
45 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func;
47 DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
49 struct hlist_head udp_hash[UDP_HTABLE_SIZE];
54 +#if defined(CONFIG_XFRM) || defined(CONFIG_IPSEC_NAT_TRAVERSAL)
56 +/* if XFRM isn't a module, then register it directly. */
57 +#if 0 && !defined(CONFIG_XFRM_MODULE) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
58 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = xfrm4_rcv_encap;
60 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
63 +int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
64 + , xfrm4_rcv_encap_t *oldfunc)
66 + if(oldfunc != NULL) {
67 + *oldfunc = xfrm4_rcv_encap_func;
71 + if(xfrm4_rcv_encap_func != NULL)
75 + xfrm4_rcv_encap_func = func;
79 +int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
81 + if(xfrm4_rcv_encap_func != func)
84 + xfrm4_rcv_encap_func = NULL;
87 +#endif /* CONFIG_XFRM_MODULE || CONFIG_IPSEC_NAT_TRAVERSAL */
91 * 1 if the the UDP system should process it
92 * 0 if we should drop this packet
95 static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
98 +#if !defined(CONFIG_XFRM) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
101 struct udp_sock *up = udp_sk(sk);
102 @@ -937,11 +976,11 @@
103 /* if we're overly short, let UDP handle it */
104 len = skb->len - sizeof(struct udphdr);
109 /* if this is not encapsulated socket, then just return now */
114 /* If this is a paged skb, make sure we pull up
115 * whatever data we need to look at. */
117 len = sizeof(struct udphdr);
119 /* Must be an IKE packet.. pass it through */
123 case UDP_ENCAP_ESPINUDP_NON_IKE:
124 /* Check if this is a keepalive packet. If so, eat it. */
126 len = sizeof(struct udphdr) + 2 * sizeof(u32);
128 /* Must be an IKE packet.. pass it through */
136 if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
138 + if (skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
141 /* Now we can update and verify the packet length... */
143 @@ -1051,9 +1092,13 @@
147 - /* process the ESP packet */
148 - ret = xfrm4_rcv_encap(skb, up->encap_type);
149 - UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
150 + if(xfrm4_rcv_encap_func != NULL) {
151 + ret = (*xfrm4_rcv_encap_func)(skb, up->encap_type);
152 + UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
154 + UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
159 /* FALLTHROUGH -- it's a UDP Packet */
160 @@ -1733,3 +1778,9 @@
161 EXPORT_SYMBOL(udp_proc_register);
162 EXPORT_SYMBOL(udp_proc_unregister);
165 +#if defined(CONFIG_IPSEC_NAT_TRAVERSAL)
166 +EXPORT_SYMBOL(udp4_register_esp_rcvencap);
167 +EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);