Commit Graph

21 Commits

Author SHA1 Message Date
knakahara ee84f251f9 Fix l2tp(4) alignment check. Pointed out and reviewed by k-goda@IIJ.
The alignment check should be done for the address of m_data instead of
the value of m_data.

XXX pullup-8
2018-04-09 10:06:59 +00:00
maxv 6f47d7d82c Use MH_ALIGN instead, ok knakahara@. 2018-01-26 14:10:15 +00:00
maxv 7bd67feaa8 Several fixes in L2TP:
* l2tp_input(): use m_copydata, and ensure there is enough space in the
   chain. Otherwise overflow.

 * l2tp_tcpmss_clamp(): ensure there is enough space in the chain.

 * in_l2tp_output(): don't check 'sc' against NULL, it can't be NULL.

 * in_l2tp_input(): no need to call m_pullup since we use m_copydata.
   Just check the space in the chain.

 * in_l2tp_input(): if there is a cookie, make sure the chain has enough
   space.

 * in6_l2tp_input(): same changes as in_l2tp_input().

Ok knakahara@
2018-01-26 07:49:15 +00:00
maxv 8aca1b685f style 2018-01-25 10:33:37 +00:00
ozaki-r 436bca6c47 Don't set IFEF_MPSAFE unless NET_MPSAFE at this point
Because recent investigations show that interfaces with IFEF_MPSAFE need to
follow additional restrictions to work with the flag safely. We should enable it
on an interface by default only if the interface surely satisfies the
restrictions, which are described in if.h.

Note that enabling IFEF_MPSAFE solely gains a few benefit on performance because
the network stack is still serialized by the big kernel locks by default.
2017-12-19 03:32:35 +00:00
knakahara d4228bae36 unify processing to check nesting count for some tunnel protocols. 2017-12-06 08:23:17 +00:00
ozaki-r ab3cd725ea Unify IFEF_*_MPSAFE into IFEF_MPSAFE
There are already two flags for if_output and if_start, however, it seems such
MPSAFE flags are eventually needed for all if_XXX operations. Having discrete
flags for each operation is wasteful of if_extflags bits. So let's unify
the flags into one: IFEF_MPSAFE.

Fortunately IFEF_*_MPSAFE flags have never been included in any releases, so
we can change them without breaking backward compatibility of the releases
(though the kernel version of -current should be bumped).

Note that if an interface have both MP-safe and non-MP-safe operations at a
time, we have to set the IFEF_MPSAFE flag and let callees of non-MP-safe
opeartions take the kernel lock.

Proposed on tech-kern@ and tech-net@
2017-11-16 03:07:17 +00:00
ozaki-r 7010c5b04d Set IFEF_NO_LINK_STATE_CHANGE flag to pseudo devices that don't use if_link_state_change 2017-10-30 16:01:19 +00:00
knakahara a90a862765 If if_attach() failed in the attach function, return. Add comments about if_initialize().
suggested by ozaki-r@n.o.
2017-10-30 11:24:04 +00:00
knakahara e810bcfb9c fix l2tp panic when l2tp session id is changed (same as if_vlan.c:r1.104)
E.g. the following operation causes this panic.
    ====================
    # ifconfig l2tp0 create
    # ifconfig l2tp0 session 140 140
    # ifconfig l2tp1 create
    # ifconfig l2tp1 session 200 200
    # ifconfig l2tp1 session 300 300
    panic: kernel diagnostic assertion "new->ple_next == NULL" failed: file "/disk4/home/k-nakahara/repos/netbsd-src/sys/sys/pslist.h", line 118
    ====================

Pointed out by s-yamaguchi@IIJ, thanks.

XXX need pullup-8
2017-10-19 11:28:30 +00:00
chs fd34ea77eb remove checks for failure after memory allocation calls that cannot fail:
kmem_alloc() with KM_SLEEP
  kmem_zalloc() with KM_SLEEP
  percpu_alloc()
  pserialize_create()
  psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
2017-06-01 02:45:05 +00:00
knakahara 29209776f3 missing if_extflags of l2tp(4). l2tp(4) is already MP-safe. 2017-04-20 09:11:58 +00:00
knakahara d5d260eb06 l2tp(4) support when hashinit() cannot allocate requried hash size.
pointed out by s-yamaguchi@IIJ
2017-04-13 00:12:10 +00:00
knakahara 685eeb51f1 fix module build 2017-04-04 23:49:17 +00:00
sevan cb2085f041 Revert change to allow builds to continue until the missing vlan.h file is committed.
https://mail-index.netbsd.org/source-changes/2017/04/04/msg083283.html
2017-04-04 16:49:15 +00:00
knakahara 6f4f1b05e1 remove unnecessary if_vlanvar.h. add missing include "vlan.h".
pointed out by s-yamaguchi@IIJ, thanks.
2017-04-04 10:25:38 +00:00
knakahara 87a1dfd1ed fix atf failed. 2017-04-04 04:34:43 +00:00
knakahara bafe7eeef8 fix missing mutex_destroy when modunload.
pointed out by s-yamaguchi@IIJ, thanks.
2017-04-03 10:17:17 +00:00
knakahara 0715c4c5fb fix potentially use after free between "ifconfig l2tpX destroy" and l2tp Tx.
It is protected by KERNEL_LOCK in soo_ioctl() between "ioctl destory" and
other ioctls. And, it is protected by encap_lock() between "ioctl destroy"
and Rx. However, it was not protected between "ioctl destroy" and Tx.
That is,
    + CPU#A
      - do "ifconfig l2tpX destroy"
        - call l2tp_clone_destroy()
        - done l2tp_delete_tunnel()
    + CPU#B
      - begin l2tp output processing
        - call l2tp_transmit()
        - done l2tp_getref_variant()
    + CPU#A
        - done kmem_free(sc->l2tp_var, )
    + CPU#B
        - access to sc->l2tp_var after free

pointed out by s-yamaguchi@IIJ, thanks.
2017-04-03 10:08:24 +00:00
knakahara 90af23d20d KNF. pointed out by s-yamaguchi@IIJ 2017-03-30 06:42:05 +00:00
knakahara 706b73f634 add missing files. 2017-02-16 08:23:35 +00:00