Commit Graph

97 Commits

Author SHA1 Message Date
christos ed3efbbd44 PR/50905: Henning Petersen: Fix useless comparison (from FreeBSD) 2016-03-07 13:08:48 +00:00
christos 9ad1c4b588 Simplify the port comparison code further. 2016-03-06 04:19:51 +00:00
christos 1f725e84a4 kill stray & 2016-03-05 20:26:07 +00:00
christos 4495e307bd Fix port matching; we need to ignore ports when they are 0 not only in
the second saidx but the first one too. Fixes NAT-T issue with NetBSD
being the host behind NAT.
2016-03-05 20:13:40 +00:00
christos 0ab2237aab gather more information from mbuf. 2016-03-05 20:12:23 +00:00
christos 9347deb6cb Add more debugging, no functional change. 2016-03-05 20:11:09 +00:00
christos bdca82a2cd cleanup debugging printfs and fix port endianness printing issue. 2014-06-16 03:34:45 +00:00
christos ee557bb8ce CID 1220169: Reverse NULL 2014-06-05 17:18:19 +00:00
christos 96991fb554 CID 274353: Forward NULL 2014-06-05 17:11:54 +00:00
christos 5d61e6c015 Introduce 2 new variables: ipsec_enabled and ipsec_used.
Ipsec enabled is controlled by sysctl and determines if is allowed.
ipsec_used is set automatically based on ipsec being enabled, and
rules existing.
2014-05-30 01:39:03 +00:00
rmind 4ae03c1815 - Split off PRU_ATTACH and PRU_DETACH logic into separate functions.
- Replace malloc with kmem and eliminate M_PCB while here.
- Sprinkle more asserts.
2014-05-19 02:51:24 +00:00
joerg 6d24f3c134 Remove modification of an unused uninitialized variable. 2014-03-01 12:55:23 +00:00
pooka 4f6fb3bf35 Ensure that the top level sysctl nodes (kern, vfs, net, ...) exist before
the sysctl link sets are processed, and remove redundancy.

Shaves >13kB off of an amd64 GENERIC, not to mention >1k duplicate
lines of code.
2014-02-25 18:30:08 +00:00
mrg a370d57c87 - apply some __diagused
- remove unused variables
- move some variables inside their relevant use #ifdef
2013-11-03 18:37:10 +00:00
christos bcc300a35d make debugging code use __func__
remove stray printf
2013-09-19 19:29:35 +00:00
riastradh 82db4b9858 Replace consttime_bcmp/explicit_bzero by consttime_memequal/explicit_memset.
consttime_memequal is the same as the old consttime_bcmp.
explicit_memset is to memset as explicit_bzero was to bcmp.

Passes amd64 release and i386/ALL, but I'm sure I missed some spots,
so please let me know.
2013-06-24 04:21:19 +00:00
christos 27fe772ddc IPSEC has not come in two speeds for a long time now (IPSEC == kame,
FAST_IPSEC). Make everything refer to IPSEC to avoid confusion.
2013-06-05 19:01:26 +00:00
christos 213e873fd6 PR/47886: Dr. Wolfgang Stukenbrock: IPSEC_NAT_T enabled kernels may access
outdated pointers and pass ESP data to UPD-sockets.
While here, simplify the code and remove the IPSEC_NAT_T option; always
compile nat-traversal in so that it does not bitrot.
2013-06-04 22:47:37 +00:00
gdt d2966f6e1d Fix whitespace (mostly removing trailing).
This commit changes only whitespace (trailing, tabs vs spaces,
removing spurious newlines).  From Bev Schwartz of BBN.
2012-09-20 23:50:05 +00:00
drochner 8588929dc5 Add "consttime_bcmp" and "explicit_bzero" functions for both kernel
abd userland, as proposed on tech-security, with explicit_bzero using
a volatile function pointer as suggested by Alan Barrett.
Both do what the name says. For userland, both are prefixed by "__"
to keep them out of the user namespace.
Change some memset/memcmp uses to the new functions where it makes
sense -- these are just some examples, more to come.
2012-08-30 12:16:48 +00:00
drochner a01fe2e22b g/c unused struct member 2012-08-29 20:37:50 +00:00
drochner e3fa29b8b1 allow the ESP fragment length in the NAT-T case to be reported back
through the pfkey interface, kernel part of PR kern/44952
by Wolfgang Stukenbrock
2012-01-09 15:42:08 +00:00
drochner 25b72c320c as in netkey/key.c, just use cprng_fast() to get a random number
(which is used to choose an SPI), kill the dummy seeding code
2011-12-19 11:47:16 +00:00
joerg 3eb244d801 Retire varargs.h support. Move machine/stdarg.h logic into MI
sys/stdarg.h and expect compiler to provide proper builtins, defaulting
to the GCC interface. lint still has a special fallback.
Reduce abuse of _BSD_VA_LIST_ by defining __va_list by default and
derive va_list as required by standards.
2011-07-17 20:54:30 +00:00
drochner 2cd69bbbad more "const" 2011-06-09 19:54:18 +00:00
drochner a46f4db6fd remove a limitation that inner and outer IP version must be equal
for an ESP tunnel, and add some fixes which make v4-in-v6 work
(v6 as inner protocol isn't ready, even v6-in-v6 can never have worked)

being here, fix a statistics counter and kill an unused variable
2011-06-06 16:48:35 +00:00
drochner fe35ba177e g/c remainders of IV handling in pfkey code -- this is done in
opencrypto now
2011-05-23 15:17:25 +00:00
drochner 582edd8b2a include the SHA2 hashs into the proposal which goes out with
SADB_ACQUIRE -- this doesn't change much because racoon ignores
the proposal from the kernel anyway and applies its own configuration,
but having MD5 and SHA1 in the list but SHA2 not looks strange
2011-05-18 18:56:02 +00:00
drochner 184e1b20e6 use monotonic time rather than wall time for lifetime related timestamps,
to make key expiration robust against time changes
2011-05-18 18:36:15 +00:00
drochner 8ec435e6ba cleanup some error handling to avoid memory leaks and doube frees,
from Wolfgang Stukenbrock per PR kern/44948, and part of kern/44952
2011-05-17 18:57:02 +00:00
drochner d1cd4a3eb4 fix lookup of SAs for outgoing packets in the !prefered_oldsa case,
as done in KAME and FAST_IPSEC after NetBSD imported the code
(The default differs: KAME uses the oldest valid SA while FAST_IPSEC
in NetBSD uses the newest one. I'm not changing this -- there is a lack
of specification and behavior can be changed with the "oldsa" sysctl.)
For incoming packets it shouldn't matter but I made it look similar
just to avoid unnecessary differences.
2011-05-17 18:43:02 +00:00
drochner bc5ee3cb6d treat "struct secpolicyindex" and "struct secasindex" as "const" once
they are initialized -- during lifetime, no changes are expected
plus some constification of input to comparision functions etc
mostly required by the former
2011-02-21 22:28:18 +00:00
drochner 909a8e8346 more "const" 2011-02-18 19:56:01 +00:00
spz 445e6acd20 fix two bugs in the PFKEY interface:
1) RFC2367 says in 2.3.3 Address Extension: "All non-address
   information in the sockaddrs, such as sin_zero for AF_INET sockaddrs,
   and sin6_flowinfo for AF_INET6 sockaddrs, MUST be zeroed out."
   the IPSEC_NAT_T code was expecting the port information it needs
   to be conveyed in the sockaddr instead of exclusively by
   SADB_X_EXT_NAT_T_SPORT and SADB_X_EXT_NAT_T_DPORT,
   and was not zeroing out the port information in the non-nat-traversal
   case.
   Since it was expecting the port information to reside in the sockaddr
   it could get away with (re)setting the ports after starting to use them.
   -> Set the natt ports before setting the SA mature.

2) RFC3947 has two Original Address fields, initiator and responder,
   so we need SADB_X_EXT_NAT_T_OAI and SADB_X_EXT_NAT_T_OAR and not just
   SADB_X_EXT_NAT_T_OA

The change has been created using vanhu's patch for FreeBSD as reference.

Note that establishing actual nat-t sessions has not yet been tested.

Likely fixes the following:
PR bin/41757
PR net/42592
PR net/42606
2010-09-05 06:52:53 +00:00
hubertf af120bb199 Replace more printfs with aprint_normal / aprint_verbose
Makes "boot -z" go mostly silent for me.
2010-01-31 00:43:37 +00:00
cegger 35fb64746b bcmp -> memcmp 2009-03-18 15:14:29 +00:00
cegger df7f595ecd Ansify function definitions w/o arguments. Generated with sed. 2009-03-18 10:22:21 +00:00
christos f794ad1e52 remove 2038 comment. 2009-02-14 20:53:58 +00:00
skd 8d41ac5617 Back out my previous change. The problem I'm chasgin is with the
initialization of ports in saidx's when IPSEC_NAT_T is defined but the
association connection is not using nat traversal.  Stay tuned.
2009-02-09 15:06:37 +00:00
skd 744626ac10 These comparison functions return 0 on match. Fix sense of test. 2009-01-28 19:06:03 +00:00
dsl a8f5b9cfc2 Comment out the 'do' and 'while (0)' from KEY_CHKSASTATE().
The expansion contains a 'continue' which is expected to continue
a loop in the callling code, not just abort the #define.
2008-07-25 20:55:43 +00:00
mlelstv be6f2a4b87 Ignore freed rtcache entries. 2008-07-01 20:18:45 +00:00
thorpej b129a80c20 Simplify the interface to netstat_sysctl() and allocate space for
the collated counters using kmem_alloc().

PR kern/38577
2008-05-04 07:22:14 +00:00
degroote b6a04a1973 In key_do_allocsa_policy, fix a bad usage of key_setsadbmsg. The third argument
is an SADB_SATYPE_*, not an IPPROTO_* .

Fix PR/38405. Thanks for the report
2008-05-03 21:53:23 +00:00
ad 15e29e981b Merge the socket locking patch:
- Socket layer becomes MP safe.
- Unix protocols become MP safe.
- Allows protocol processing interrupts to safely block on locks.
- Fixes a number of race conditions.

With much feedback from matt@ and plunky@.
2008-04-24 11:38:36 +00:00
thorpej 02f63fe1bf PF_KEY stats for IPSEC and FAST_IPSEC are now per-CPU. 2008-04-23 07:29:47 +00:00
elad 5a24b726ae Let this code compile.
Hi, liamjfoy@. :)
2007-12-07 19:44:38 +00:00
ad 88ab7da936 Merge some of the less invasive changes from the vmlocking branch:
- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements
2007-07-09 20:51:58 +00:00
degroote a382db0aa9 Ansify
Remove useless extern
bzero -> memset, bcopy -> memcpy

No functionnal changes
2007-07-07 18:38:22 +00:00
degroote 4ddfe916ff Add support for options IPSEC_NAT_T (RFC 3947 and 3948) for fast_ipsec(4).
No objection on tech-net@
2007-06-27 20:38:32 +00:00