Commit Graph

115 Commits

Author SHA1 Message Date
ozaki-r 0df8f574e7 Provide IPSEC_DIR_* validation macros 2017-04-20 03:41:47 +00:00
ozaki-r 07cdf4ae58 Reduce return points (NFC) 2017-04-19 09:23:19 +00:00
ozaki-r da67e76875 Return early, reduce identation (NFCI) 2017-04-19 09:22:17 +00:00
ozaki-r 1d3af2e6cf Use KASSERT for sanity checks of function arguments 2017-04-19 07:19:46 +00:00
ozaki-r 6208c22585 Tweak KEYDEBUG macros
Let's avoid passing statements to a macro.
2017-04-19 03:42:11 +00:00
ozaki-r 50d790a0e8 Change panic if DIAGNOSTIC to KASSERT
One can be changed to CTASSERT.
2017-04-19 03:40:58 +00:00
ozaki-r ef67739a78 Retire ipsec_osdep.h
We don't need to care other OSes (FreeBSD) anymore.

Some macros are alive in ipsec_private.h.
2017-04-19 03:39:14 +00:00
ozaki-r 2620e166df Convert IPSEC_ASSERT to KASSERT or KASSERTMSG
IPSEC_ASSERT just discarded specified message...
2017-04-18 05:26:41 +00:00
ozaki-r b4d2d2c260 Remove __FreeBSD__ and __NetBSD__ switches
No functional changes (except for a debug printf).

Note that there remain some __FreeBSD__ for sysctl knobs which counerparts
to NetBSD don't exist. And ipsec_osdep.h isn't touched yet; tidying it up
requires actual code changes.
2017-04-18 05:25:32 +00:00
ozaki-r 0d3ed86269 Accept AH with NULL algorithm of zero-length key 2017-04-17 05:48:18 +00:00
ozaki-r 51b95f5900 Fix assertion failure in in6_lookup_multi via key_ismyaddr
in6_lookup_multi was forgotten to be migrated to in6_multi_group.
Also psz should be changed to psz/psref because in6_multi_group is
sleepable.

Fix PR kern/52151
2017-04-10 14:02:25 +00:00
ozaki-r 80d40a78b4 Prepare netipsec for rump-ification
- Include "opt_*.h" only if _KERNEL_OPT is defined
- Allow encapinit to be called twice (by ifinit and ipe4_attach)
  - ifinit didn't call encapinit if IPSEC is enabled (ipe4_attach called
    it instead), however, on a rump kernel ipe4_attach may not be called
    even if IPSEC is enabled. So we need to allow ifinit to call it anyway
- Setup sysctls in ipsec_attach explicitly instead of using SYSCTL_SETUP
- Call ip6flow_invalidate_all in key_spdadd only if in6_present
  - It's possible that a rump kernel loads the ipsec library but not
    the inet6 library
2017-04-06 09:20:07 +00:00
ozaki-r 00a9cf741d Remove mkludge stuffs
For unknown reasons, IPv6 multicast addresses are linked to a first
IPv6 address assigned to an interface. Due to the design, when removing
a first address having multicast addresses, we need to save them to
somewhere and later restore them once a new IPv6 address is activated.
mkludge stuffs support the operations.

This change links multicast addresses to an interface directly and
throws the kludge away.

Note that as usual some obsolete member variables remain for kvm(3)
users. And also sysctl net.inet6.multicast_kludge remains to avoid
breaking old ifmcstat.

TODO: currently ifnet has a list of in6_multi but obviously the list
should be protocol independent. Provide a common structure (if_multi
or something) to handle in6_multi and in_multi together as well as
ifaddr does for in_ifaddr and in6_ifaddr.
2017-02-23 07:57:09 +00:00
ozaki-r 40914f019e Stop using useless IN6_*_MULTI macros 2017-02-22 07:46:00 +00:00
ozaki-r 4f21a42704 Apply pserialize to some iterations of IP address lists 2016-07-20 07:37:51 +00:00
ozaki-r 89e0e151d3 Restore const qualifier dropped due to switching to IN_ADDRLIST_READER_FOREACH
IN_ADDRLIST_READER_FOREACH (pslist(9)) now allows const variables.
2016-07-07 06:59:30 +00:00
ozaki-r 350c782980 Switch the IPv4 address list to pslist(9)
Note that we leave the old list just in case; it seems there are some
kvm(3) users accessing the list. We can remove it later if we confirmed
nobody does actually.
2016-07-06 08:42:34 +00:00
ozaki-r 6cf9fce745 Use pslist(9) for the global in6_ifaddr list
psz and psref will be applied in another commit.

No functional change intended.
2016-07-04 06:48:14 +00:00
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