Commit Graph

31 Commits

Author SHA1 Message Date
knakahara 7128a14d48 Make pktq_rps_hash() pluggable for each interface type. Reviewed by gdt@n.o, thorpej@n.o, and riastradh@n.o, thanks. 2021-10-11 05:13:10 +00:00
roy 120b194ae9 ipsecif: Set the link state UP if we have a tunnel, otherwise DOWN. 2020-10-14 18:48:05 +00:00
knakahara e8a0215c37 reduce unnecessary reqid of NAT-T ipsecif(4), suggested by ohishi@IIJ. 2020-03-13 02:43:31 +00:00
knakahara 258ba86eac Fix ipsecif(4) SPDADD pfkey message has garbage. Pointed out by ohishi@IIJ.
"setkey -x" output is the following.

========== before ==========
sadb_msg{ version=2 type=14 errno=0 satype=0
  len=15 reserved=0 seq=0 pid=0
sadb_ext{ len=56 type=18 }
sadb_x_policy{ type=2 dir=1 id=9 }
 { len=40 proto=50 mode=1 level=3 reqid=16393
sockaddr{ len=0 family=0  }
sockaddr{ len=0 family=0  }
 }
========== before ==========

========== after ==========
sadb_msg{ version=2 type=14 errno=0 satype=0
  len=11 reserved=0 seq=0 pid=0
sadb_ext{ len=24 type=18 }
sadb_x_policy{ type=2 dir=1 id=9 }
 { len=8 proto=50 mode=1 level=3 reqid=16393
 }
========== after ==========
2020-03-10 10:35:14 +00:00
riastradh 47880c1380 Fix order in rollback case; switch if_ipsec to atomic_load/store_*. 2020-02-01 02:57:55 +00:00
thorpej d99f8f369a Adopt <net/if_stats.h>. 2020-01-29 04:28:27 +00:00
knakahara 93a28c822d Make global and per-interface ipsecif(4) pmtu tunable like gif(4).
And make hop limit tunable same as gif(4).

See http://mail-index.netbsd.org/source-changes/2019/10/30/msg110426.html
2019-11-01 04:28:14 +00:00
knakahara 2da350beca Avoid having a rtcache directly in a percpu storage for tunnel protocols.
percpu(9) has a certain memory storage for each CPU and provides it by the piece
to users.  If the storages went short, percpu(9) enlarges them by allocating new
larger memory areas, replacing old ones with them and destroying the old ones.
A percpu storage referenced by a pointer gotten via percpu_getref can be
destroyed by the mechanism after a running thread sleeps even if percpu_putref
has not been called.

Using rtcache, i.e., packet processing, typically involves sleepable operations
such as rwlock so we must avoid dereferencing a rtcache that is directly stored
in a percpu storage during packet processing.  Address this situation by having
just a pointer to a rtcache in a percpu storage instead.

Reviewed by ozaki-r@ and yamaguchi@
2019-09-19 06:07:24 +00:00
msaitoh 70b25bc928 if_flags is neither int nor short. It's unsigned short. 2019-09-13 07:55:05 +00:00
msaitoh b801416bbd Simplify "LIST_HEAD();" to make the code more understandable.
No functional change.
2019-06-25 12:30:50 +00:00
knakahara d97e48c284 Fix ipsecif(4) memory leak in some ioctl cases. 2019-03-14 03:52:40 +00:00
knakahara 64706e18ff Remove unnecessary addresses in PF_KEY message.
MOBIKE Extensions for PF_KEY draft-schilcher-mobike-pfkey-extension-01.txt says
====================
5.  SPD Update
// snip
   SADB_X_SPDADD:
// snip
      sadb_x_ipsecrequest_reqid:

         An ID for that SA can be passed to the kernel in the
         sadb_x_ipsecrequest_reqid field.


      If tunnel mode is specified, the sadb_x_ipsecrequest structure is
      followed by two sockaddr structures that define the tunnel
      endpoint addresses.  In the case that transport mode is used, no
      additional addresses are specified.
====================
see: https://tools.ietf.org/html/draft-schilcher-mobike-pfkey-extension-01

ipsecif(4) uses transport mode, so it should not add addresses.
2018-12-26 08:55:14 +00:00
knakahara c9c343de7f ipsecif(4) support input drop packet counter. 2018-12-07 05:09:39 +00:00
knakahara ebac3c728d Fix panic when doing ioctl to multiple pseudo interfaces. Pointed out by k-goda@IIJ.
XXX pullup-8
2018-10-19 00:12:56 +00:00
msaitoh 3cd62456f9 Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

 This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.
2018-06-26 06:47:57 +00:00
knakahara 223e9d0020 Reviewd by ohishi@IIJ. Sorry, I jumped the gun and committed.
Fix the following two issues.
    - remove extra padding of sizeof(xisr) when adding ipsec policy
    - add padding for xpl when adding discard policy
2018-05-29 04:45:50 +00:00
knakahara 3fb44db7d4 Fix panic when ipsecif(4) adds discard policy. Pointed out by ohishi@IIJ, thanks. 2018-05-29 03:38:24 +00:00
knakahara c6109391ad ipsecif(4) must not set port number to spidx even if NAT-T. Pointed out by ohishi@IIJ, thanks. 2018-05-24 07:00:28 +00:00
knakahara b0c61d654b Fix LOCKDEBUG kernel panic when many(about 200) tunnel interfaces is created.
The tunnel interfaces are gif(4), l2tp(4), and ipsecif(4). They use mutex
itself in percpu area. When percpu_cpu_enlarge() run, the address of the
mutex in percpu area becomes different from the address which lockdebug
saved. That can cause "already initialized" false detection.
2018-04-27 09:55:27 +00:00
knakahara f6621122fb Fix "how" argument of MGET(). Pointed out by maxv@n.o, thanks.
MGET() does not have M_ZERO flag, so add memset when it is required.
2018-04-27 00:06:40 +00:00
knakahara d83c566ff6 Fix unexpected failure when ipsecif(4) over IPv6 is changed port number only.
Here is an example of the operation which causes this problem.
    # ifconfig ipsec0 create link0
    # ifconfig ipsec0 tunnel fc00:1001::2,4500 fc00:1001::1,4501
    # ifconfig ipsec0 tunnel fc00:1001::2,4500 fc00:1001::1,4502
2018-04-06 10:38:53 +00:00
knakahara c6bcca39f7 fix ipsecif(4) stack overflow.
XXX pullup-8
2018-04-06 09:30:09 +00:00
knakahara 7b815c4232 fix ipsecif(4) unmatch curlwp_bind.
XXX pullup-8
2018-04-06 09:28:26 +00:00
knakahara cc1df90a04 fix ipsec(4) encap_lock leak.
XXX pullup-8
2018-04-06 09:24:13 +00:00
knakahara 51a1e9f49e Fix IPv6 ipsecif(4) ATF regression, sorry.
There must *not* be padding between the src sockaddr and the dst sockaddr
after struct sadb_x_policy.
2018-03-13 02:12:05 +00:00
knakahara 130a306c85 Functionalize duplicated code. No functional changes. 2018-03-09 11:03:26 +00:00
knakahara 6be8939a62 Fix missing sadb_x_ipsecrequest informations for PF_KEY message. 2018-03-09 11:01:41 +00:00
knakahara fceccdc8f9 NAT-T src and dst port in ipsec_variant should be network byte order. 2018-03-09 10:59:36 +00:00
mrg 11a8456034 apply a little more #ifdef INET/INET6. fixes !INET6 builds. 2018-01-31 07:33:18 +00:00
knakahara 42796cd760 Fix PR kern/52920. Pointed out by David Binderman, thanks. 2018-01-15 02:39:53 +00:00
knakahara 4ab3af3e3e add ipsec(4) interface, which is used for route-based VPN.
man and ATF are added later, please see man for details.

reviewed by christos@n.o, joerg@n.o and ozaki-r@n.o, thanks.
https://mail-index.netbsd.org/tech-net/2017/12/18/msg006557.html
2018-01-10 10:56:30 +00:00