Commit Graph

3180 Commits

Author SHA1 Message Date
ozaki-r f25a9e702b Remove unnecessary splsoftnet 2017-10-25 04:33:15 +00:00
ozaki-r 375edaeabf Don't free sc_rthash twice 2017-10-25 04:17:34 +00:00
msaitoh 351c2b7262 - If if_attach() failed in the attach function, free resources and return.
- KNF
2017-10-23 09:32:55 +00:00
msaitoh 2223ce7058 - If if_initialize() failed in the attach function, free resources and return.
- KNF
2017-10-23 09:32:33 +00:00
msaitoh 803d5cc88a If if_attach() failed in the attach function, free resources and return. 2017-10-23 09:32:00 +00:00
msaitoh 916c83ee9b If if_initialize() failed in the attach function, free resources and return. 2017-10-23 09:31:17 +00:00
msaitoh a40cbde039 - If if_initialize() failed in the attach function, free resources and return.
- Add some missing frees in bridge_clone_destroy().
- KNF
2017-10-23 09:22:51 +00:00
msaitoh cb49e3c2fa If if_attach() failed in the attach function, return. 2017-10-23 09:22:24 +00:00
msaitoh 37822dfae5 if_initalize() and if_attach() failed when resource allocation failed
(e.g. allocating softint). Without this change, it panics. It's bad because
resource shortage really occured when a lot of pseudo interface is created.
To avoid this problem, don't panic and change return value of if_initialize()
and if_attach() to int. Caller fanction will be recover from error cleanly by
checking the return value.
2017-10-23 09:21:20 +00:00
msaitoh ae10948226 Clear ifm_cur and ifm_media after removing all ifmedia entries(IFM_INST_ANY)
in ifmedia_delete_instance() like if_media.c rev. 1.32.
Now if_media_delete_instance(IFM_INST_ANY) is the same as ifmedia_removeall().
2017-10-23 03:54:40 +00:00
msaitoh 428e217142 No functional change:
- Simplify ifmedia_removeall using with ifmedia_delete_instance(IFM_INST_ANY).
 - KNF.
2017-10-20 08:04:39 +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
knakahara d71c6de37e fix vlan panic when vlan is re-configured without destroy.
E.g. the following operation causes this panic.
    ====================
    # ifconfig vlan0 create
    # ifconfig vlan0 vlan 1 vlanif ixg3
    # ifconfig vlan1 create
    # ifconfig vlan1 vlan 1 vlanif ixg2
    # ifconfig vlan1 -vlanif
    # ifconfig vlan1 vlan 1 vlanif ixg2

    panic: kernel diagnostic assertion "new->ple_next == NULL" failed: file "/git/netbsd-src/sys/sys/pslist.h", line 118
    ====================

Pointed out and tested by msaitoh@n.o, fixed by s-yamaguchi@IIJ, thanks.

XXX need pullup-8
2017-10-19 07:02:00 +00:00
ozaki-r 7107584815 Turn on D_MPSAFE flag of bpf_cdevsw that is already MP-safe
Pointed out by k-goda@IIJ
2017-10-19 01:57:15 +00:00
knakahara 7963b39c7e fix no INET6 build. 2017-10-13 03:11:50 +00:00
knakahara b168165350 Add a locking notes for if_spppsubr 2017-10-12 09:53:55 +00:00
knakahara 3cdb7bbdc5 Add a locking notes for if_pppoe 2017-10-12 09:50:55 +00:00
knakahara 5fa45178cf sppp_lock is changed from mutex to rwlock now. Contributed by s-yamaguchi@IIJ.
Add locking notes later.
2017-10-12 09:49:43 +00:00
knakahara 45be2dc76a Integrate two locks used to protect PPPoE softc. Contributed by s-yamaguchi@IIJ.
PPPOE_SESSION_LOCK protects variables used in PPP packet
processing, on the other hand PPPOE_PARAM_LOCK protects
the other variables used to establish a PPPoE session id.

Those locks isn't acquired in the same time because the
PPP packet processing doesn't work without PPPoE session id.
By the reason, the locks can be integrated into PPPOE_LOCK.

Add locking notes later.
2017-10-12 09:47:21 +00:00
ozaki-r a46eb3599f Set IFEF_START_MPSAFE by default
Because vlan_start is already MP-safe, there is no reason to not do so.

Acked by s-yamaguchi@IIJ
2017-10-12 02:40:59 +00:00
msaitoh 51840268ca Remove accidentally added code (for VLAN hardware filter). 2017-10-11 08:29:17 +00:00
msaitoh 5c71a28134 Check if VLAN ID isn't duplicated on a same parent interface and return
EEXIST if it failed.
2017-10-11 08:10:00 +00:00
msaitoh 3a978cd9a9 Add 2.5GBASE-T and 5GBASE-T. 2017-10-04 07:08:01 +00:00
msaitoh 14fe90e75f All Ethernet media more than 1000Mbps don't support half duplex.
For the convinience, ifconfig without "mediaopt fullduplex" sets IFM_FDX
automatically for those medias. Without this change, "ifconfig xxN mediaopt
10Gbase-T" (without "mediaopt fullduplex") returns EINVAL if a
driver doesn't call ifmedia_add() without IFM_FDX because ifmedia_match()
returns NULL.
2017-10-04 07:07:16 +00:00
ozaki-r 5c4a769336 Add curlwp_bind to bridge_input for psref
It can be called in a thread context via tap (tap_dev_write).

Fix PR kern/52587
2017-10-02 07:40:24 +00:00
christos a52d29cf5f - add a constant for the vlan mask.
- enforce that we have a tag before we get it.
2017-09-28 16:26:14 +00:00
knakahara a6e88d7809 VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.
I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch
2017-09-26 07:42:05 +00:00
ozaki-r 856a12a96d Synchronize on rtcache_generation with rtlock
It's racy if NET_MPSAFE is enabled.

Pointed out by joerg@
2017-09-25 04:15:33 +00:00
ozaki-r 4cfe7ee520 Use a dedicated mutex for rt_rawcb instead of softnet_lock if NET_MPSAFE 2017-09-25 01:57:54 +00:00
ozaki-r 475ed81624 Fix race condition on the rawcb list shared by rtsock and keysock
keysock now protects itself by its own mutex, which means that
the rawcb list is protected by two different mutexes (keysock's one
and softnet_lock for rtsock), of course it's useless.

Fix the situation by having a discrete rawcb list for each.
2017-09-25 01:56:22 +00:00
ozaki-r 82d5516b2e Remove the global lock for rtcache
Thanks to removal of LIST_ENTRY of struct route, rtcaches are accessed only by
their users. And in existing usages a rtcache is guranteed to be not accessed
simultaneously. So the rtcache framework doesn't need any exclusion controls
in itself.
2017-09-22 05:05:32 +00:00
knakahara 5d0cdef5b4 loop_clone_create() must be called after ncpu is counted up for all CPUs.
loop_clone_create() uses ncpu in the following call-path.
    - loop_clone_create()
      - if_attach()
        - if_percpuq_create()
          - softint_establish() // use ncpu
          - percpu_foreach() // use ncpu

However, loopinit() of built-in module is called from
module_init_class(MODULE_CLASS_DRIVER) which is called before ncpu is counted
up in some architectures. So, It is too fast.
On the other hand, it is too late for rump netinet component to call
loop_clone_create() in config_finalize().

As the result, loop_clone_create() shuld be called in loopattach() for built-in
module, and in loopinit() for dynamic module.

XXX need pullup -8 branch
2017-09-21 11:42:17 +00:00
knakahara 9cd884509f update locking notes. 2017-09-21 09:48:15 +00:00
knakahara 1cc266b88d add lock for sclist to exclude ifconfig gifX add/delete and ifconfig gifX tunnel 2017-09-21 09:46:14 +00:00
knakahara 56188c2a5a add lock for percpu route like l2tp(4). 2017-09-21 09:42:03 +00:00
ozaki-r 0092eb7df6 Invalidate rtcache based on a global generation counter
The change introduces a global generation counter that is incremented when any
routes have been added or deleted. When a rtcache caches a rtentry into itself,
it also stores a snapshot of the generation counter. If the snapshot equals to
the global counter, the cache is still valid, otherwise invalidated.

One drawback of the change is that all rtcaches of all protocol families are
invalidated when any routes of any protocol families are added or deleted.
If that matters, we should have separate generation counters based on
protocol families.

This change removes LIST_ENTRY from struct route, which fixes a part of
PR kern/52515.
2017-09-21 07:15:34 +00:00
ozaki-r 6b704eed1f Remove unnecessary NULL check of rt_ifp
It's always non-NULL.
2017-09-21 04:44:32 +00:00
christos 5cf79e57be Add one more not supported error 2017-09-17 20:39:04 +00:00
knakahara 29967db593 Fix vlan(4) obytes counter. Implemented by s-yamaguchi@IIJ, thanks. 2017-08-09 06:17:23 +00:00
knakahara 038b619438 fix leak when encap_attach() fails twice.
XXX need pullup to -8 branch
2017-08-08 03:14:50 +00:00
ozaki-r 689811efa2 Let PF_KEY socks hold their own lock instead of softnet_lock
Operations on SAD and SPD are executed via PF_KEY socks. The operations
include deletions of SAs and SPs that will use synchronization mechanisms
such as pserialize_perform to wait for references to SAs and SPs to be
released. It is known that using such mechanisms with holding softnet_lock
causes a dead lock. We should avoid the situation.
2017-07-27 09:53:57 +00:00
para e3902ee896 kmem_intr_free kmem_intr_[z]alloced memory
the underlying pools are the same but api-wise those should match
2017-07-23 10:55:00 +00:00
pgoyette c829d7a088 The nof module depends on some stuff from the bpf module, so set the
required modules list accordingly.
2017-07-20 23:37:56 +00:00
knakahara 51973a4e30 fix panic when PPPOE_DEBUG enabled. implemented by s-yamaguchi@IIJ, thanks.
XXX need pullup to -8 branch
2017-07-20 02:34:24 +00:00
ozaki-r c18aa5892a Introduce and use SADB_SASTATE_USABLE_P 2017-07-04 08:11:32 +00:00
christos 7700e78cab put the code that returns the sizeof the socket by family in one place. 2017-07-01 16:59:12 +00:00
christos 5ca98f2167 Avoid DIAGNOSTIC warning with previous fix and simplify it (don't require
memory alloc/free).
2017-06-30 18:28:31 +00:00
ozaki-r f0a30a5d8f Restore the original length of a sockaddr for netmask
route(8) passes a sockaddr for netmask that is truncated with its
prefixlen. However the kernel basically doesn't expect such format
and may read beyond the data. So restore the original length of the
the data at the beginning of the kernel for the rest components.

Failures of ATF tests such as route_flags_blackhole6 should
be fixed.
2017-06-30 09:11:22 +00:00
ozaki-r da803ed70d Restore ARP/NDP entries to route show and netstat -r
Requested by dyoung@ some time ago
2017-06-28 04:14:53 +00:00
ozaki-r fcbd6bf4fa Drop RTF_LLINFO flag (now it's RTF_LLDATA) from local routes
They don't have llinfo anymore. And also the change fixes unexpected
behavior of ARP proxy.
2017-06-28 04:10:47 +00:00