📄 ipsec_rcv.c
字号:
* 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() calls. * Added a hard/soft expiry parameter to pfkey_expire(). * Added sanity checking to avoid propagating zero or smaller-length skbs * from a bogus decryption. * Re-arranged the order of soft and hard expiry to conform to RFC2367. * Clean up references to CONFIG_IPSEC_PFKEYv2. * * Revision 1.51 2000/08/18 21:23:30 rgb * Improve bad padding warning so that the printk buffer doesn't get * trampled. * * Revision 1.50 2000/08/01 14:51:51 rgb * Removed _all_ remaining traces of DES. * * Revision 1.49 2000/07/28 13:50:53 rgb * Changed enet_statistics to net_device_stats and added back compatibility * for pre-2.1.19. * * Revision 1.48 2000/05/10 19:14:40 rgb * Only check usetime against soft and hard limits if the tdb has been * used. * Cast output of ntohl so that the broken prototype doesn't make our * compile noisy. * * Revision 1.47 2000/05/09 17:45:43 rgb * Fix replay bitmap corruption bug upon receipt of bogus packet * with correct SPI. This was a DoS. * * Revision 1.46 2000/03/27 02:31:58 rgb * Fixed authentication failure printout bug. * * Revision 1.45 2000/03/22 16:15:37 rgb * Fixed renaming of dev_get (MB). * * Revision 1.44 2000/03/16 08:17:24 rgb * Hardcode PF_KEYv2 support. * Fixed minor bug checking AH header length. * * Revision 1.43 2000/03/14 12:26:59 rgb * Added skb->nfct support for clearing netfilter conntrack bits (MB). * * Revision 1.42 2000/01/26 10:04:04 rgb * Fixed inbound policy checking on transport mode bug. * Fixed noisy 2.0 printk arguments. * * Revision 1.41 2000/01/24 20:58:02 rgb * Improve debugging/reporting support for (disabled) inbound * policy checking. * * Revision 1.40 2000/01/22 23:20:10 rgb * Fixed up inboud policy checking code. * Cleaned out unused crud. * * Revision 1.39 2000/01/21 06:15:29 rgb * Added sanity checks on skb_push(), skb_pull() to prevent panics. * Fixed cut-and-paste debug_tunnel to debug_rcv. * Added inbound policy checking code, disabled. * Simplified output code by updating ipp to post-IPIP decapsulation. * * elided pre-2000 comments. Use "cvs log" * * * Local Variables: * c-style: linux * End: * */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -