1 diff -rdupN linux-2.6.22.6.oorig/include/net/xfrmudp.h linux-2.6.22.6/include/net/xfrmudp.h
2 --- linux-2.6.22.6.oorig/include/net/xfrmudp.h 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.22.6/include/net/xfrmudp.h 2007-09-17 06:10:19.000000000 +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 -rdupN linux-2.6.22.6.oorig/net/ipv4/Kconfig linux-2.6.22.6/net/ipv4/Kconfig
16 --- linux-2.6.22.6.oorig/net/ipv4/Kconfig 2007-08-31 08:21:01.000000000 +0200
17 +++ linux-2.6.22.6/net/ipv4/Kconfig 2007-09-17 06:13:08.000000000 +0200
18 @@ -362,6 +360,15 @@ config SYN_COOKIES
22 +config IPSEC_NAT_TRAVERSAL
23 + bool "IPSEC NAT-Traversal (KLIPS compatible)"
26 + Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
28 + server is really overloaded. If this happens frequently better turn
32 tristate "IP: AH transformation"
34 diff -rdupN linux-2.6.22.6.oorig/net/ipv4/udp.c linux-2.6.22.6/net/ipv4/udp.c
35 --- linux-2.6.22.6.oorig/net/ipv4/udp.c 2007-08-31 08:21:01.000000000 +0200
36 +++ linux-2.6.22.6/net/ipv4/udp.c 2007-09-17 06:10:19.000000000 +0200
40 DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
41 +#include <net/xfrmudp.h>
43 struct hlist_head udp_hash[UDP_HTABLE_SIZE];
44 DEFINE_RWLOCK(udp_hash_lock);
45 @@ -919,6 +920,44 @@ int udp_disconnect(struct sock *sk, int
49 +#if defined(CONFIG_XFRM) || defined(CONFIG_IPSEC_NAT_TRAVERSAL)
51 +/* if XFRM isn't a module, then register it directly. */
52 +#if !defined(CONFIG_XFRM_MODULE)
53 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = xfrm4_rcv_encap;
55 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
58 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func;
60 +int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
61 + , xfrm4_rcv_encap_t *oldfunc)
63 + if(oldfunc != NULL) {
64 + *oldfunc = xfrm4_rcv_encap_func;
68 + if(xfrm4_rcv_encap_func != NULL)
72 + xfrm4_rcv_encap_func = func;
76 +int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
78 + if(xfrm4_rcv_encap_func != func)
81 + xfrm4_rcv_encap_func = NULL;
84 +#endif /* CONFIG_XFRM || defined(CONFIG_IPSEC_NAT_TRAVERSAL)*/
88 * 1 if the UDP system should process it
89 * 0 if we should drop this packet
90 @@ -926,9 +965,9 @@ int udp_disconnect(struct sock *sk, int
92 static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
95 +#if !defined(CONFIG_XFRM) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
98 +#else /* either CONFIG_XFRM or CONFIG_IPSEC_NAT_TRAVERSAL */
99 struct udp_sock *up = udp_sk(sk);
102 @@ -1056,10 +1095,14 @@ int udp_queue_rcv_skb(struct sock * sk,
106 - /* process the ESP packet */
107 - ret = xfrm4_rcv_encap(skb, up->encap_type);
108 - UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
110 + if(xfrm4_rcv_encap_func != NULL) {
111 + ret = (*xfrm4_rcv_encap_func)(skb, up->encap_type);
112 + UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
114 + UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
119 /* FALLTHROUGH -- it's a UDP Packet */
121 @@ -1742,3 +1785,9 @@ EXPORT_SYMBOL(udp_poll);
122 EXPORT_SYMBOL(udp_proc_register);
123 EXPORT_SYMBOL(udp_proc_unregister);
126 +#if defined(CONFIG_IPSEC_NAT_TRAVERSAL)
127 +EXPORT_SYMBOL(udp4_register_esp_rcvencap);
128 +EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);