pass ARCH down to uClibc
[buildroot.git] / package / openswan / linux-2.6.22.6-openswan-2.4.9.kernel-2.6-natt.patch
blob412b087d6e57f207aa1b46350bc889ff4e56137b
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
4 @@ -0,0 +1,10 @@
5 +/*
6 + * pointer to function for type that xfrm4_input wants, to permit
7 + * decoupling of XFRM from udp.c
8 + */
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
20 If unsure, say N.
22 +config IPSEC_NAT_TRAVERSAL
23 + bool "IPSEC NAT-Traversal (KLIPS compatible)"
24 + depends on INET
25 + ---help---
26 + Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
28 + server is really overloaded. If this happens frequently better turn
29 + them off.
31 config INET_AH
32 tristate "IP: AH transformation"
33 select XFRM
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
37 @@ -108,6 +108,7 @@
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
46 return 0;
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;
54 +#else
55 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
56 +#endif
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;
65 + }
67 +#if 0
68 + if(xfrm4_rcv_encap_func != NULL)
69 + return -1;
70 +#endif
72 + xfrm4_rcv_encap_func = func;
73 + return 0;
76 +int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
78 + if(xfrm4_rcv_encap_func != func)
79 + return -1;
81 + xfrm4_rcv_encap_func = NULL;
82 + return 0;
84 +#endif /* CONFIG_XFRM || defined(CONFIG_IPSEC_NAT_TRAVERSAL)*/
87 /* return:
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)
94 -#ifndef CONFIG_XFRM
95 +#if !defined(CONFIG_XFRM) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
96 return 1;
97 -#else
98 +#else /* either CONFIG_XFRM or CONFIG_IPSEC_NAT_TRAVERSAL */
99 struct udp_sock *up = udp_sk(sk);
100 struct udphdr *uh;
101 struct iphdr *iph;
102 @@ -1056,10 +1095,14 @@ int udp_queue_rcv_skb(struct sock * sk,
103 return 0;
105 if (ret < 0) {
106 - /* process the ESP packet */
107 - ret = xfrm4_rcv_encap(skb, up->encap_type);
108 - UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
109 - return -ret;
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);
113 + } else {
114 + UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
115 + ret = 1;
117 + return ret;
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);
124 #endif
126 +#if defined(CONFIG_IPSEC_NAT_TRAVERSAL)
127 +EXPORT_SYMBOL(udp4_register_esp_rcvencap);
128 +EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);
129 +#endif