linux-2.6.21.5-openswan-2.4.8.kernel-2.6-natt.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. diff -rduNp linux-2.6.21.5.orig/include/net/xfrmudp.h linux-2.6.21.5/include/net/xfrmudp.h
  2. --- linux-2.6.21.5.orig/include/net/xfrmudp.h 1970-01-01 01:00:00.000000000 +0100
  3. +++ linux-2.6.21.5/include/net/xfrmudp.h 2007-06-21 10:53:38.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
  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. diff -rduNp linux-2.6.21.5.orig/net/ipv4/Kconfig linux-2.6.21.5/net/ipv4/Kconfig
  16. --- linux-2.6.21.5.orig/net/ipv4/Kconfig 2007-06-11 20:37:06.000000000 +0200
  17. +++ linux-2.6.21.5/net/ipv4/Kconfig 2007-06-21 10:53:38.000000000 +0200
  18. @@ -349,6 +349,12 @@ config SYN_COOKIES
  19. be taken as absolute truth.
  20. SYN cookies may prevent correct error reporting on clients when the
  21. +config IPSEC_NAT_TRAVERSAL
  22. + bool "IPSEC NAT-Traversal (KLIPS compatible)"
  23. + depends on INET
  24. + ---help---
  25. + Includes support for RFC3947/RFC3948 NAT-Traversal of ESP over UDP.
  26. +
  27. server is really overloaded. If this happens frequently better turn
  28. them off.
  29. diff -rduNp linux-2.6.21.5.orig/net/ipv4/udp.c linux-2.6.21.5/net/ipv4/udp.c
  30. --- linux-2.6.21.5.orig/net/ipv4/udp.c 2007-06-11 20:37:06.000000000 +0200
  31. +++ linux-2.6.21.5/net/ipv4/udp.c 2007-06-21 10:56:18.000000000 +0200
  32. @@ -108,6 +108,7 @@
  33. */
  34. DEFINE_SNMP_STAT(struct udp_mib, udp_statistics) __read_mostly;
  35. +#include <net/xfrmudp.h>
  36. struct hlist_head udp_hash[UDP_HTABLE_SIZE];
  37. DEFINE_RWLOCK(udp_hash_lock);
  38. @@ -915,6 +916,44 @@ int udp_disconnect(struct sock *sk, int
  39. return 0;
  40. }
  41. +#if defined(CONFIG_XFRM) || defined(CONFIG_IPSEC_NAT_TRAVERSAL)
  42. +
  43. +/* if XFRM isn't a module, then register it directly. */
  44. +#if !defined(CONFIG_XFRM_MODULE)
  45. +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = xfrm4_rcv_encap;
  46. +#else
  47. +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func = NULL;
  48. +#endif
  49. +
  50. +static xfrm4_rcv_encap_t xfrm4_rcv_encap_func;
  51. +
  52. +int udp4_register_esp_rcvencap(xfrm4_rcv_encap_t func
  53. + , xfrm4_rcv_encap_t *oldfunc)
  54. +{
  55. + if(oldfunc != NULL) {
  56. + *oldfunc = xfrm4_rcv_encap_func;
  57. + }
  58. +
  59. +#if 0
  60. + if(xfrm4_rcv_encap_func != NULL)
  61. + return -1;
  62. +#endif
  63. +
  64. + xfrm4_rcv_encap_func = func;
  65. + return 0;
  66. +}
  67. +
  68. +int udp4_unregister_esp_rcvencap(xfrm4_rcv_encap_t func)
  69. +{
  70. + if(xfrm4_rcv_encap_func != func)
  71. + return -1;
  72. +
  73. + xfrm4_rcv_encap_func = NULL;
  74. + return 0;
  75. +}
  76. +#endif /* CONFIG_XFRM || defined(CONFIG_IPSEC_NAT_TRAVERSAL)*/
  77. +
  78. +
  79. /* return:
  80. * 1 if the the UDP system should process it
  81. * 0 if we should drop this packet
  82. @@ -922,9 +961,9 @@ int udp_disconnect(struct sock *sk, int
  83. */
  84. static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb)
  85. {
  86. -#ifndef CONFIG_XFRM
  87. +#if !defined(CONFIG_XFRM) && !defined(CONFIG_IPSEC_NAT_TRAVERSAL)
  88. return 1;
  89. -#else
  90. +#else /* either CONFIG_XFRM or CONFIG_IPSEC_NAT_TRAVERSAL */
  91. struct udp_sock *up = udp_sk(sk);
  92. struct udphdr *uh;
  93. struct iphdr *iph;
  94. @@ -1052,9 +1091,14 @@ int udp_queue_rcv_skb(struct sock * sk,
  95. }
  96. if (ret < 0) {
  97. /* process the ESP packet */
  98. - ret = xfrm4_rcv_encap(skb, up->encap_type);
  99. - UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
  100. - return -ret;
  101. + if (xfrm4_rcv_encap_func != NULL) {
  102. + ret = (*xfrm4_rcv_encap_func)(skb, up->encap_type);
  103. + UDP_INC_STATS_BH(UDP_MIB_INDATAGRAMS, up->pcflag);
  104. + } else {
  105. + UDP_INC_STATS_BH(UDP_MIB_INERRORS, up->pcflag);
  106. + ret = 1;
  107. + }
  108. + return ret;
  109. }
  110. /* FALLTHROUGH -- it's a UDP Packet */
  111. }
  112. @@ -1733,3 +1777,9 @@ EXPORT_SYMBOL(udp_poll);
  113. EXPORT_SYMBOL(udp_proc_register);
  114. EXPORT_SYMBOL(udp_proc_unregister);
  115. #endif
  116. +
  117. +#if defined(CONFIG_IPSEC_NAT_TRAVERSAL)
  118. +EXPORT_SYMBOL(udp4_register_esp_rcvencap);
  119. +EXPORT_SYMBOL(udp4_unregister_esp_rcvencap);
  120. +#endif
  121. +