]> git.ipfire.org Git - ipfire-2.x.git/blob - src/patches/openswan-2.4.12.kernel-2.6.20.21-natt.patch
471eb3296d76668898345178dfa92b4b81ea8ecd
[ipfire-2.x.git] / src / patches / openswan-2.4.12.kernel-2.6.20.21-natt.patch
1 packaging/utils/nattpatch 2.6
2 --- /dev/null Tue Mar 11 13:02:56 2003
3 +++ nat-t/include/net/xfrmudp.h Mon Feb 9 13:51:03 2004
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
10 +
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 --- /distros/kernel/linux-2.6.11.2/net/ipv4/Kconfig 2005-03-09 03:12:33.000000000 -0500
16 +++ swan26/net/ipv4/Kconfig 2005-04-04 18:46:13.000000000 -0400
17 @@ -351,2 +351,8 @@
18
19 +config IPSEC_NAT_TRAVERSAL
20 + bool "IPSEC NAT-Traversal (KLIPS compatible)"
21 + depends on INET
22 + ---help---
23 + Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
24 +
25 config IP_TCPDIAG
26 --- plain26/net/ipv4/udp.c.orig 2006-01-02 22:21:10.000000000 -0500
27 +++ plain26/net/ipv4/udp.c 2006-01-12 20:18:57.000000000 -0500
28 @@ -108,6 +108,7 @@
29 */
30
31 DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
32 +#include <net/xfrmudp.h>
33
34 struct hlist_head udp_hash[UDP_HTABLE_SIZE];
35 DEFINE_RWLOCK(udp_hash_lock);
36 @@ -914,6 +915,44 @@
37 return 0;
38 }
39
40 +#if defined(CONFIG_XFRM) || defined(CONFIG_IPSEC_NAT_TRAVERSAL)
41 +
42 +/* if XFRM isn't a module, then register it directly. */
43 +#if !defined(CONFIG_XFRM_MODULE)
44 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = xfrm4_rcv_encap;
45 +#else
46 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
47 +#endif
48 +
49 +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func;
50 +
51 +int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
52 + , xfrm4_rcv_encap_t *oldfunc)
53 +{
54 + if(oldfunc != NULL) {
55 + *oldfunc = xfrm4_rcv_encap_func;
56 + }
57 +
58 +#if 0
59 + if(xfrm4_rcv_encap_func != NULL)
60 + return -1;
61 +#endif
62 +
63 + xfrm4_rcv_encap_func = func;
64 + return 0;
65 +}
66 +
67 +int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
68 +{
69 + if(xfrm4_rcv_encap_func != func)
70 + return -1;
71 +
72 + xfrm4_rcv_encap_func = NULL;
73 + return 0;
74 +}
75 +#endif /* CONFIG_XFRM || defined(CONFIG_IPSEC_NAT_TRAVERSAL)*/
76 +
77 +
78 /* return:
79 * 1 if the the UDP system should process it
80 * 0 if we should drop this packet
81 @@ -921,9 +960,9 @@
82 */
83 static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
84 {
85 -#ifndef CONFIG_XFRM
86 +#if !defined(CONFIG_XFRM) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
87 return 1;
88 -#else
89 +#else /* either CONFIG_XFRM or CONFIG_IPSEC_NAT_TRAVERSAL */
90 struct udp_sock *up = udp_sk(sk);
91 struct udphdr *uh;
92 struct iphdr *iph;
93 @@ -1049,11 +1088,15 @@
94 kfree_skb(skb);
95 return 0;
96 }
97 - if (ret < 0) {
98 - /* process the ESP packet */
99 - ret = xfrm4_rcv_encap(skb, up->encap_type);
100 - UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
101 - return -ret;
102 + if (ret < 0) {
103 + if(xfrm4_rcv_encap_func != NULL) {
104 + ret = (*xfrm4_rcv_encap_func)(skb, up->encap_type);
105 + UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
106 + } else {
107 + UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
108 + ret = 1;
109 + }
110 + return ret;
111 }
112 /* FALLTHROUGH -- it's a UDP Packet */
113 }
114 @@ -1732,3 +1775,8 @@
115 EXPORT_SYMBOL(udp_proc_register);
116 EXPORT_SYMBOL(udp_proc_unregister);
117 #endif
118 +
119 +#if defined(CONFIG_IPSEC_NAT_TRAVERSAL)
120 +EXPORT_SYMBOL(udp4_register_esp_rcvencap);
121 +EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);
122 +#endif