1 packaging/utils/nattpatch 2.4
2 Index: linux-2.4.35.4/include/net/sock.h
3 ===================================================================
4 --- linux-2.4.35.4.orig/include/net/sock.h
5 +++ linux-2.4.35.4/include/net/sock.h
6 @@ -488,7 +488,13 @@ struct tcp_opt {
12 +#define UDP_OPT_IN_SOCK 1
19 * This structure really needs to be cleaned up.
20 * Most of it is for TCP, and not used by any of
21 @@ -655,6 +661,9 @@ struct sock {
22 #if defined(CONFIG_SPX) || defined (CONFIG_SPX_MODULE)
23 struct spx_opt af_spx;
24 #endif /* CONFIG_SPX */
26 + struct udp_opt af_udp;
31 Index: linux-2.4.35.4/net/Config.in
32 ===================================================================
33 --- linux-2.4.35.4.orig/net/Config.in
34 +++ linux-2.4.35.4/net/Config.in
35 @@ -104,4 +104,6 @@ comment 'Network testing'
36 dep_tristate 'Packet Generator (USE WITH CAUTION)' CONFIG_NET_PKTGEN $CONFIG_PROC_FS
39 +bool 'IPSEC NAT-Traversal' CONFIG_IPSEC_NAT_TRAVERSAL
42 Index: linux-2.4.35.4/net/ipv4/udp.c
43 ===================================================================
44 --- linux-2.4.35.4.orig/net/ipv4/udp.c
45 +++ linux-2.4.35.4/net/ipv4/udp.c
46 @@ -860,6 +860,9 @@ static void udp_close(struct sock *sk, l
48 static int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb)
50 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
51 + struct udp_opt *tp = &(sk->tp_pinfo.af_udp);
54 * Charge it to the socket, dropping if the queue is full.
56 @@ -877,6 +880,40 @@ static int udp_queue_rcv_skb(struct sock
60 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
61 + if (tp->esp_in_udp) {
63 + * Set skb->sk and xmit packet to ipsec_rcv.
65 + * If ret != 0, ipsec_rcv refused the packet (not ESPinUDP),
66 + * restore skb->sk and fall back to sock_queue_rcv_skb
68 + struct inet_protocol *esp = NULL;
70 +#if defined(CONFIG_KLIPS) && !defined(CONFIG_KLIPS_MODULE)
71 + /* optomize only when we know it is statically linked */
72 + extern struct inet_protocol esp_protocol;
73 + esp = &esp_protocol;
75 + for (esp = (struct inet_protocol *)inet_protos[IPPROTO_ESP & (MAX_INET_PROTOS - 1)];
76 + (esp) && (esp->protocol != IPPROTO_ESP);
80 + if (esp && esp->handler) {
81 + struct sock *sav_sk = skb->sk;
83 + if (esp->handler(skb) == 0) {
85 + /*not sure we might count ESPinUDP as UDP...*/
86 + UDP_INC_STATS_BH(UdpInDatagrams);
94 if (sock_queue_rcv_skb(sk,skb)<0) {
95 UDP_INC_STATS_BH(UdpInErrors);
96 IP_INC_STATS_BH(IpInDiscards);
97 @@ -1100,13 +1137,49 @@ out:
101 +static int udp_setsockopt(struct sock *sk, int level, int optname,
102 + char *optval, int optlen)
104 + struct udp_opt *tp = &(sk->tp_pinfo.af_udp);
108 + if (level != SOL_UDP)
109 + return ip_setsockopt(sk, level, optname, optval, optlen);
111 + if(optlen<sizeof(int))
114 + if (get_user(val, (int *)optval))
120 +#ifdef CONFIG_IPSEC_NAT_TRAVERSAL
121 +#ifndef UDP_ESPINUDP
122 +#define UDP_ESPINUDP 100
125 + tp->esp_in_udp = val;
129 + err = -ENOPROTOOPT;
137 struct proto udp_prot = {
140 connect: udp_connect,
141 disconnect: udp_disconnect,
143 - setsockopt: ip_setsockopt,
144 + setsockopt: udp_setsockopt,
145 getsockopt: ip_getsockopt,
146 sendmsg: udp_sendmsg,
147 recvmsg: udp_recvmsg,