📄 ipsec_rcv.c
字号:
* removed old comment about removed code. * added translation from udp.c/2.6 to KLIPS NAT-ESP naming. * comment about check for origin address/port for incoming NAT-ESP packets. * * Revision 1.160 2005/04/15 19:55:58 mcr * adjustments to use proper skb fields for data. * * Revision 1.159 2005/04/10 22:58:20 mcr * refactoring of receive functions to make it easier to * call the ESP decap. * * Revision 1.158 2005/04/08 18:27:53 mcr * refactored ipsec_rcv() into ipsec_rcv() and ipsec_rcv_decap(). * * Revision 1.157 2004/12/28 23:13:09 mcr * use consistent CONFIG_IPSEC_NAT_TRAVERSAL. * * Revision 1.156 2004/12/03 21:34:51 mcr * mistype of KLIPS_USE_COUNT -> KLIPS_INC_USE; * * Revision 1.155 2004/12/03 21:25:57 mcr * compile time fixes for running on 2.6. * still experimental. * * Revision 1.154 2004/09/08 17:21:36 ken * Rename MD5* -> osMD5 functions to prevent clashes with other symbols exported by kernel modules (CIFS in 2.6 initiated this) * * Revision 1.153 2004/08/22 20:10:00 mcr * removed check for incorrect setting of NET_26. * * Revision 1.152 2004/08/21 15:22:39 mcr * added #defines for ATT heartbeat. * * Revision 1.151 2004/08/21 02:16:32 ken * Patch from Jochen Eisinger for AT&T MTS Heartbeat packet support * * Revision 1.150 2004/08/21 00:44:48 mcr * CONFIG_KLIPS_NAT was wrong, also need to include udp.h. * * Revision 1.149 2004/08/20 21:45:45 mcr * CONFIG_KLIPS_NAT_TRAVERSAL is not used in an attempt to * be 26sec compatible. But, some defines where changed. * * Revision 1.148 2004/08/17 03:27:23 mcr * klips 2.6 edits. * * Revision 1.147 2004/08/05 23:29:27 mcr * fixed nesting of #ifdef vs {} in ipsec_rcv(). * * Revision 1.146 2004/08/04 15:57:07 mcr * moved des .h files to include/des/ * * included 2.6 protocol specific things * started at NAT-T support, but it will require a kernel patch. * * Revision 1.145 2004/08/03 18:19:08 mcr * in 2.6, use "net_device" instead of #define device->net_device. * this probably breaks 2.0 compiles. * * Revision 1.144 2004/07/10 19:11:18 mcr * CONFIG_IPSEC -> CONFIG_KLIPS. * * Revision 1.143 2004/05/10 22:27:00 mcr * fix for ESP-3DES-noauth test case. * * Revision 1.142 2004/05/10 22:25:57 mcr * reformat of calls to ipsec_lifetime_check(). * * Revision 1.141 2004/04/06 02:49:26 mcr * pullup of algo code from alg-branch. * * Revision 1.140 2004/02/03 03:12:53 mcr * removed erroneously, double patched code. * * Revision 1.139 2004/01/05 23:21:29 mcr * initialize sin_family in ipsec_rcv.c * * Revision 1.138 2003/12/24 19:46:52 mcr * if sock.h patch has not been applied, then define appropriate * structure so we can use it. This is serious inferior, and * depends upon the concept that the structure in question is * smaller than the other members of that union. * getting rid of differing methods is a better solution. * * Revision 1.137 2003/12/22 19:40:57 mcr * NAT-T patches 0.6c. * * Revision 1.136 2003/12/15 18:13:12 mcr * when compiling with NAT traversal, don't assume that the * kernel has been patched, unless CONFIG_IPSEC_NAT_NON_ESP * is set. * * Revision 1.135 2003/12/13 19:10:21 mcr * refactored rcv and xmit code - same as FS 2.05. * * Revision 1.134.2.1 2003/12/22 15:25:52 jjo * Merged algo-0.8.1-rc11-test1 into alg-branch * * Revision 1.134 2003/12/10 01:14:27 mcr * NAT-traversal patches to KLIPS. * * Revision 1.133 2003/10/31 02:27:55 mcr * pulled up port-selector patches and sa_id elimination. * * Revision 1.132.2.1 2003/10/29 01:30:41 mcr * elimited "struct sa_id". * * Revision 1.132 2003/09/02 19:51:48 mcr * fixes for PR#252. * * Revision 1.131 2003/07/31 22:47:16 mcr * preliminary (untested by FS-team) 2.5 patches. * * Revision 1.130 2003/04/03 17:38:25 rgb * Centralised ipsec_kfree_skb and ipsec_dev_{get,put}. * Clarified logic for non-connected devices. * * Revision 1.129 2003/02/06 02:21:34 rgb * * Moved "struct auth_alg" from ipsec_rcv.c to ipsec_ah.h . * Changed "struct ah" to "struct ahhdr" and "struct esp" to "struct esphdr". * Removed "#ifdef INBOUND_POLICY_CHECK_eroute" dead code. * * Revision 1.128 2002/12/13 20:58:03 rgb * Relegated MCR's recent "_dmp" routine to debug_verbose. * Cleaned up printing of source and destination addresses in debug output. * * Revision 1.127 2002/12/04 16:00:16 rgb * * Fixed AH decapsulation pointer update bug and added some comments and * debugging. * This bug was caught by west-ah-0[12]. * * Revision 1.126 2002/11/04 05:03:43 mcr * fixes for IPCOMP. There were two problems: * 1) the irs->ipp pointer was not being updated properly after * the ESP descryption. The meant nothing for IPIP, as the * later IP header overwrote the earlier one. * 2) the more serious problem was that skb_decompress will * usually allocate a new SKB, so we have to make sure that * it doesn't get lost. * #2 meant removing the skb argument from the ->decrypt routine * and moving it to the irs->skb, so it could be value/result. * * Revision 1.125 2002/11/01 01:53:35 dhr * * fix typo * * Revision 1.124 2002/10/31 22:49:01 dhr * * - eliminate unused variable "hash" * - reduce scope of variable "authenticator" * - add comment on a couple of tricky bits * * Revision 1.123 2002/10/31 22:39:56 dhr * * use correct type for result of function calls * * Revision 1.122 2002/10/31 22:36:25 dhr * * simplify complex test * * Revision 1.121 2002/10/31 22:34:04 dhr * * ipsprev is never used: ditch it * * Revision 1.120 2002/10/31 22:30:21 dhr * * eliminate redundant assignments * * Revision 1.119 2002/10/31 22:27:43 dhr * * make whitespace canonical * * Revision 1.118 2002/10/30 05:47:17 rgb * Fixed cut-and-paste error mis-identifying comp runt as ah. * * Revision 1.117 2002/10/17 16:37:45 rgb * Remove compp intermediate variable and in-line its contents * where used * * Revision 1.116 2002/10/12 23:11:53 dhr * * [KenB + DHR] more 64-bit cleanup * * Revision 1.115 2002/10/07 19:06:58 rgb * Minor fixups and activation to west-rcv-nfmark-set-01 test to check for SA reference properly set on incoming. * * Revision 1.114 2002/10/07 18:31:31 rgb * Set saref on incoming packets. * * Revision 1.113 2002/09/16 21:28:12 mcr * adjust hash length for HMAC calculation - must look at whether * it is MD5 or SHA1. * * Revision 1.112 2002/09/16 21:19:15 mcr * fixes for west-ah-icmp-01 - length of AH header must be * calculated properly, and next_header field properly copied. * * Revision 1.111 2002/09/10 02:45:56 mcr * re-factored the ipsec_rcv function into several functions, * ipsec_rcv_decap_once, and a set of functions for AH, ESP and IPCOMP. * In addition, the MD5 and SHA1 functions are replaced with pointers. * * Revision 1.110 2002/08/30 06:34:33 rgb * Fix scope of shift in AH header length check. * * Revision 1.109 2002/08/27 16:49:20 rgb * Fixed ESP short packet DOS (and AH and IPCOMP). * * Revision 1.108 2002/07/24 18:44:54 rgb * Type fiddling to tame ia64 compiler. * * Revision 1.107 2002/05/27 18:58:18 rgb * Convert to dynamic ipsec device allocation. * Remove final vistiges of tdb references via IPSEC_KLIPS1_COMPAT. * * Revision 1.106 2002/05/23 07:15:21 rgb * Pointer clean-up. * Added refcount code. * * Revision 1.105 2002/05/14 02:35:06 rgb * Change all references to tdb, TDB or Tunnel Descriptor Block to ips, * ipsec_sa or ipsec_sa. * Change references to _TDB to _IPSA. * * Revision 1.104 2002/04/24 07:55:32 mcr * #include patches and Makefiles for post-reorg compilation. * * Revision 1.103 2002/04/24 07:36:30 mcr * Moved from ./klips/net/ipsec/ipsec_rcv.c,v * * Revision 1.102 2002/01/29 17:17:56 mcr * moved include of ipsec_param.h to after include of linux/kernel.h * otherwise, it seems that some option that is set in ipsec_param.h * screws up something subtle in the include path to kernel.h, and * it complains on the snprintf() prototype. * * Revision 1.101 2002/01/29 04:00:52 mcr * more excise of kversions.h header. * * Revision 1.100 2002/01/29 02:13:17 mcr * introduction of ipsec_kversion.h means that include of * ipsec_param.h must preceed any decisions about what files to * include to deal with differences in kernel source. * * Revision 1.99 2002/01/28 21:40:59 mcr * should use #if to test boolean option rather than #ifdef. * * Revision 1.98 2002/01/20 20:19:36 mcr * renamed option to IP_FRAGMENT_LINEARIZE. * * Revision 1.97 2002/01/12 02:55:36 mcr * fix for post-2.4.4 to linearize skb's when ESP packet * was assembled from fragments. * * Revision 1.96 2001/11/26 09:23:49 rgb * Merge MCR's ipsec_sa, eroute, proc and struct lifetime changes. * * Revision 1.93.2.2 2001/10/22 20:54:07 mcr * include des.h, removed phony prototypes and fixed calling * conventions to match real prototypes. * * Revision 1.93.2.1 2001/09/25 02:22:22 mcr * struct tdb -> struct ipsec_sa. * lifetime checks moved to ipsec_life.c * some sa(tdb) manipulation functions renamed. * * Revision 1.95 2001/11/06 19:49:07 rgb * Added variable descriptions. * Removed unauthenticated sequence==0 check to prevent DoS. * * Revision 1.94 2001/10/18 04:45:20 rgb * 2.4.9 kernel deprecates linux/malloc.h in favour of linux/slab.h, * lib/freeswan.h version macros moved to lib/kversions.h. * Other compiler directive cleanups. * * Revision 1.93 2001/09/07 22:17:24 rgb * Fix for removal of transport layer protocol handler arg in 2.4.4. * Fix to accomodate peer non-conformance to IPCOMP rfc2393. * * Revision 1.92 2001/08/27 19:44:41 rgb * Fix error in comment. * * Revision 1.91 2001/07/20 19:31:48 dhr * [DHR] fix source and destination subnets of policy in diagnostic * * Revision 1.90 2001/07/06 19:51:09 rgb * Added inbound policy checking code for IPIP SAs. * Renamed unused function argument for ease and intuitive naming. * * Revision 1.89 2001/06/22 19:35:23 rgb * Disable ipcomp processing if we are handed a ipcomp packet with no esp * or ah header. * Print protocol if we are handed a non-ipsec packet. * * Revision 1.88 2001/06/20 06:30:47 rgb * Fixed transport mode IPCOMP policy check bug. * * Revision 1.87 2001/06/13 20:58:40 rgb * Added parentheses around assignment used as truth value to silence * compiler. * * Revision 1.86 2001/06/07 22:25:23 rgb * Added a source address policy check for tunnel mode. It still does * not check client addresses and masks. * Only decapsulate IPIP if it is expected. * * Revision 1.85 2001/05/30 08:14:02 rgb * Removed vestiges of esp-null transforms. * * Revision 1.84 2001/05/27 06:12:11 rgb * Added structures for pid, packet count and last access time to eroute. * Added packet count to beginning of /proc/net/ipsec_eroute. * * Revision 1.83 2001/05/04 16:45:47 rgb * Remove unneeded code. ipp is not used after this point. * * Revision 1.82 2001/05/04 16:36:00 rgb * Fix skb_cow() call for 2.4.4. (SS) * * Revision 1.81 2001/05/02 14:46:53 rgb * Fix typo for compiler directive to pull IPH back. * * Revision 1.80 2001/04/30 19:46:34 rgb * Update for 2.4.4. We now receive the skb with skb->data pointing to * h.raw. * * Revision 1.79 2001/04/23 15:01:15 rgb * Added spin_lock() check to prevent double-locking for multiple * transforms and hence kernel lock-ups with SMP kernels. * Minor spin_unlock() adjustments to unlock before non-dependant prints * and IPSEC device stats updates. * * Revision 1.78 2001/04/21 23:04:24 rgb * Check if soft expire has already been sent before sending another to * prevent ACQUIRE flooding. * * Revision 1.77 2001/03/16 07:35:20 rgb * Ditch extra #if 1 around now permanent policy checking code. * * Revision 1.76 2001/02/27 22:24:54 rgb * Re-formatting debug output (line-splitting, joining, 1arg/line). * Check for satoa() return codes. * * Revision 1.75 2001/02/19 22:28:30 rgb * Minor change to virtual device discovery code to assert which I/F has * been found. * * Revision 1.74 2000/11/25 03:50:36 rgb * Oops fix by minor re-arrangement of code to avoid accessing a freed tdb. * * Revision 1.73 2000/11/09 20:52:15 rgb * More spinlock shuffling, locking earlier and unlocking later in rcv to * include ipcomp and prevent races, renaming some tdb variables that got * forgotten, moving some unlocks to include tdbs and adding a missing * unlock. Thanks to Svenning for some of these. * * Revision 1.72 2000/11/09 20:11:22 rgb * Minor shuffles to fix non-standard kernel config option selection. * * Revision 1.71 2000/11/06 04:36:18 rgb * Ditched spin_lock_irqsave in favour of spin_lock. * Minor initial protocol check rewrite. * Clean up debug printing. * Clean up tdb handling on ipcomp. * Fixed transport mode null pointer de-reference without ipcomp. * Add Svenning's adaptive content compression. * Disabled registration of ipcomp handler. * * Revision 1.70 2000/10/30 23:41:43 henry * Hans-Joerg Hoexer's null-pointer fix * * Revision 1.69 2000/10/10 18:54:16 rgb * Added a fix for incoming policy check with ipcomp enabled but * uncompressible. * * Revision 1.68 2000/09/22 17:53:12 rgb * Fixed ipcomp tdb pointers update for policy checking. * * Revision 1.67 2000/09/21 03:40:58 rgb * Added more debugging to try and track down the cpi outward copy problem. * * Revision 1.66 2000/09/20 04:00:10 rgb * Changed static functions to DEBUG_NO_STATIC to reveal function names for * debugging oopsen. * * Revision 1.65 2000/09/19 07:07:16 rgb * Added debugging to inbound policy check for ipcomp. * Added missing spin_unlocks (thanks Svenning!). * Fixed misplaced tdbnext pointers causing mismatched ipip policy check. * Protect ipcomp policy check following ipip decap with sysctl switch. * * Revision 1.64 2000/09/18 21:27:29 rgb * 2.0 fixes. * * Revision 1.63 2000/09/18 02:35:50 rgb * Added policy checking to ipcomp and re-enabled policy checking by * default. * Optimised satoa calls. * * Revision 1.62 2000/09/17 21:02:32 rgb * Clean up debugging, removing slow timestamp debug code. * * Revision 1.61 2000/09/16 01:07:55 rgb * Fixed erroneous ref from struct ipcomp to struct ipcomphdr. * * Revision 1.60 2000/09/15 11:37:01 rgb * Merge in heavily modified Svenning Soerensen's <svenning@post5.tele.dk> * IPCOMP zlib deflate code. * * Revision 1.59 2000/09/15 04:56:20 rgb * Remove redundant satoa() call, reformat comment. * * Revision 1.58 2000/09/13 08:00:52 rgb * Flick on inbound policy checking. * * Revision 1.57 2000/09/12 03:22:19 rgb * Converted inbound_policy_check to sysctl. * Re-enabled policy backcheck. * Moved policy checks to top and within tdb lock. * * Revision 1.56 2000/09/08 19:12:56 rgb * Change references from DEBUG_IPSEC to CONFIG_IPSEC_DEBUG. * * Revision 1.55 2000/08/28 18:15:46 rgb * Added MB's nf-debug reset patch. * * Revision 1.54 2000/08/27 01:41:26 rgb * More minor tweaks to the bad padding debug code. * * Revision 1.53 2000/08/24 16:54:16 rgb * Added KLIPS_PRINTMORE macro to continue lines without KERN_INFO level * info. * Tidied up device reporting at the start of ipsec_rcv. * Tidied up bad padding debugging and processing. * * Revision 1.52 2000/08/20 21:36:03 rgb * Activated pfkey_expire() ca
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -