Commit Graph

2756 Commits

Author SHA1 Message Date
pgoyette
b05cba24c7 Add modular dependency on zlib module. 2016-04-05 23:44:05 +00:00
pgoyette
fb73b1d308 Update dependency: zlib is only needed for the swcrypto device, not for
any other component of opencrypto.
2016-04-05 22:51:01 +00:00
ozaki-r
b7639842cb Unbreak build of kernels without INET 2016-04-05 10:03:33 +00:00
ozaki-r
09973b35ac Separate nexthop caches from the routing table
By this change, nexthop caches (IP-MAC address pair) are not stored
in the routing table anymore. Instead nexthop caches are stored in
each network interface; we already have lltable/llentry data structure
for this purpose. This change also obsoletes the concept of cloning/cloned
routes. Cloned routes no longer exist while cloning routes still exist
with renamed to connected routes.

Noticeable changes are:
- Nexthop caches aren't listed in route show/netstat -r
  - sysctl(NET_RT_DUMP) doesn't return them
  - If RTF_LLDATA is specified, it returns nexthop caches
- Several definitions of routing flags and messages are removed
  - RTF_CLONING, RTF_XRESOLVE, RTF_LLINFO, RTF_CLONED and RTM_RESOLVE
- RTF_CONNECTED is added
  - It has the same value of RTF_CLONING for backward compatibility
- route's -xresolve, -[no]cloned and -llinfo options are removed
  - -[no]cloning remains because it seems there are users
  - -[no]connected is introduced and recommended
    to be used instead of -[no]cloning
- route show/netstat -r drops some flags
  - 'L' and 'c' are not seen anymore
  - 'C' now indicates a connected route
- Gateway value of a route of an interface address is now not
  a L2 address but "link#N" like a connected (cloning) route
- Proxy ARP: "arp -s ... pub" doesn't create a route

You can know details of behavior changes by seeing diffs under tests/.

Proposed on tech-net and tech-kern:
  http://mail-index.netbsd.org/tech-net/2016/03/11/msg005701.html
2016-04-04 07:37:07 +00:00
ozaki-r
2a8dd88007 Don't request returning rtentry if not use it 2016-04-01 09:52:39 +00:00
ozaki-r
8b4ba7b737 Remove unnecessary RTTIMER_CALLOUT macro
rttimer#rtt_func never be NULL.
2016-04-01 09:00:27 +00:00
ozaki-r
2d846e45e6 Make some global variables static 2016-04-01 02:00:14 +00:00
ozaki-r
fb96f2a80f Remove unused global bridge list
Pointed out by riastradh@
2016-03-28 04:38:04 +00:00
ozaki-r
3084fea4ef Constify rt_newmsg's arguments 2016-03-24 06:18:27 +00:00
knakahara
969d82c4f7 add drop count which means the sum of struct if_percpuq's per-CPU queues.
ok by ozaki-r@n.o
2016-03-23 07:05:28 +00:00
ozaki-r
f1d17afed8 Fix LIST_FOREACH argument 2016-03-23 05:44:01 +00:00
ozaki-r
85320fb21e Use LIST_FOREACH instead of LIST_FOREACH_SAFE
No need to use *_SAFE because we don't remove any items in the loop.
2016-03-23 04:56:21 +00:00
mrg
66d72dce7d minimal changes necessary to link into an INET6-less kernel. 2016-03-18 10:09:46 +00:00
ozaki-r
5472fb5b21 Add missing percpu_putref to error path 2016-03-07 01:41:55 +00:00
knakahara
e80f101289 To eliminate gif_softc_list linear search, add extra argument to encapsw.pr_ctlinput(). 2016-02-26 07:35:17 +00:00
roy
72b9424275 Implement a queue for if_link_state_change() calls to fix a race condition
introduced in the prior patch.

The queue has capacity to store 8 link state changes, if it overflows then
the oldest state change is lost, but the oldest DOWN state change is
preserved to ensure any subsequent UP state changes reflect properly.

Because there are only 3 states to queue, the queue itself is implemented
by storing 2-bit numbers in a bigger one.
To increase the size of the queue, just increase the size of the backing
store to a bigger number.
2016-02-19 20:05:43 +00:00
ozaki-r
1926a64c9e Remove workaround for GATEWAY
The workaround was introduced because lltable/llentry uses rwlock
but it may be executed in hardware interrupt due to fast forward.
Now we don't run fast forward in hardware interrupt anymore, so
we can remove the workaround.
2016-02-16 01:31:26 +00:00
ozaki-r
297068212d Run if_link_state_change in softint
if_link_state_change can execute the network stack that is expected to
not run in hardware interrupt (at least now), however network drivers
may call it in hardware interrupt. Avoid that by introducing a new
softint for if_link_state_change.

The original patch is provided by mlelstv@ and tweaked a bit by me.

Should fix PR kern/50602.
2016-02-15 08:08:04 +00:00
ozaki-r
b7a310ca27 Simplify bridge(4)
Thanks to introducing softint-based if_input, the entire bridge code now
never run in hardware interrupt context. So we can simplify the code.

- Remove spin mutexes
  - They were needed because some code of bridge could run in
    hardware interrupt context
  - We now need only an adaptive mutex for each shared object
    (a member list and a forwarding table)
- Remove pktqueue
  - bridge_input is already in softint, using another softint
    (for bridge_forward) is useless
  - Packet distribution should be down at device drivers
2016-02-15 01:11:41 +00:00
ozaki-r
057a6a480f Don't share struct work, instead have one per softc
Pointed out by riastradh@
2016-02-10 06:30:23 +00:00
ozaki-r
28e7d22e93 Fix build 2016-02-09 14:43:16 +00:00
ozaki-r
9c4cd06355 Introduce softint-based if_input
This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!
2016-02-09 08:32:07 +00:00
christos
654889b793 Do less work under the kernel lock, otherwise dhcpcd aborting causes us
to deadlock.
2016-02-01 16:32:28 +00:00
ozaki-r
a8e10f3452 Tidy up
- KNF
- Remove obsolete ifdefs for other OSes
- Remove unnecessary else block

No functional change.
2016-01-28 04:37:01 +00:00
knakahara
2656d88eb3 fix my wrong modification 2016-01-28 00:28:11 +00:00
knakahara
b546d5277b implement encapsw instead of protosw and uniform prototype.
suggested and advised by riastradh@n.o, thanks.

BTW, It seems in_stf_input() had bugs...
2016-01-26 05:58:05 +00:00
riastradh
e588d95c25 Back out previous change to introduce struct encapsw.
This change was intended, but Nakahara-san had already made a better
one locally!  So I'll let him commit that one, and I'll try not to
step on anyone's toes again.
2016-01-22 23:27:12 +00:00
riastradh
87bc652e3d Don't abuse struct protosw for ip_encap -- introduce struct encapsw.
Mostly mechanical change to replace it, culling some now-needless
boilerplate around all the users.

This does not substantively change the ip_encap API or eliminate
abuse of sketchy pointer casts -- that will come later, and will be
easier now that it is not tangled up with struct protosw.
2016-01-22 05:15:10 +00:00
riastradh
7c7b1739c8 Revert previous: ran cvs commit when I meant cvs diff. Sorry!
Hit up-arrow one too few times.
2016-01-21 15:41:29 +00:00
riastradh
b41d562bd0 Give proper prototype to ip_output. 2016-01-21 15:27:48 +00:00
riastradh
65a8f527af Eliminate struct protosw::pr_output.
You can't use this unless you know what it is a priori: the formal
prototype is variadic, and the different instances (e.g., ip_output,
route_output) have different real prototypes.

Convert the only user of it, raw_send in net/raw_cb.c, to take an
explicit callback argument.  Convert the only instances of it,
route_output and key_output, to such explicit callbacks for raw_send.
Use assertions to make sure the conversion to explicit callbacks is
warranted.

Discussed on tech-net with no objections:
https://mail-index.netbsd.org/tech-net/2016/01/16/msg005484.html
2016-01-20 21:43:59 +00:00
knakahara
d7b9bb29c0 Refactor protosw codes in gif(4). No functional change.
- remove unnecessary include
    - reduce scopes
2016-01-18 06:08:26 +00:00
knakahara
1c5d304e9c eliminate ip_input.c and ip6_input.c dependency on gif(4) 2016-01-08 03:55:39 +00:00
ozaki-r
db10df1ae6 Fix the destruction of the afdata lock
Pointed out by mlelstv@
2016-01-04 09:08:38 +00:00
knakahara
143a395d31 Revert extra wating codes.
PR kern/50522 is actually fixed by sys/kern/kern_softint.c:r1.42, so waiting
codes in if_gif.c is not required.
2016-01-04 07:50:08 +00:00
alnsn
40bda2ee5c Replace the nsaveds() function with #define NSAVEDS 3. No functional change.
Patch from Michael McConville.
2015-12-29 21:49:58 +00:00
ozaki-r
a532303129 Tweak return value handling
rtrequest1 ensures to return an rtentry on success.
2015-12-22 01:59:21 +00:00
mlelstv
30470de52f make DDB print ipv6 addresses too 2015-12-17 12:17:13 +00:00
mlelstv
378c085bac handle delayed cksums also for ipv6 2015-12-17 12:16:21 +00:00
ozaki-r
66d9895f20 Fix memory leak of llentry#la_opaque
llentry#la_opaque which is for token ring is allocated in arp.c
and freed in arp.c when freeing llentry. However, llentry can be
freed from other places, e.g., lltable_free. In such cases,
la_opaque is never freed.

To fix that, add a new callback (lle_ll_free) to llentry and
register a destruction function of la_opque to it. On freeing a
llentry, we can surely free la_opque via the callback.
2015-12-17 02:38:33 +00:00
christos
43eac92e53 don't free mbuf twice.
XXX: pullup 7.
2015-12-16 23:14:42 +00:00
ozaki-r
213b8d3cc6 Fix token_rif extractions from llentry 2015-12-16 05:44:59 +00:00
knakahara
a00e94f4ff PR kern/50522: gif(4) ioctl causes panic while someone is using the gif(4) interface.
It is required to wait other CPU's softint completion before disestablishing
the softint handler.
2015-12-11 07:59:14 +00:00
knakahara
ef0c59f955 revert KASSERT. It should use 'if' instead of KASSERT.
see updated(later than r1.18) kmem(9) man.
2015-12-11 04:29:24 +00:00
knakahara
5b880df5ec kmem_zalloc(, KM_SLEEP) must not return NULL. 2015-12-10 08:11:03 +00:00
knakahara
eaf1fb5902 add NULL check 2015-12-10 01:20:12 +00:00
knakahara
849e83fa25 gif(4) uses kmem_alloc APIs instead of malloc. 2015-12-09 05:56:24 +00:00
knakahara
5e4601c62c Refactor gif_set_tunnel(). No functional change. 2015-12-09 03:33:32 +00:00
knakahara
118f179f3d Improve gif_set_tunnel() rollback code. 2015-12-09 03:31:28 +00:00
knakahara
c705cd3ca5 gif(4): Infinite recursion calls prevention code works again now.
The prevention code haven't worked since gif(4) was changed
to use softint(9). To work this prevention, git_output uses
m_tag(9) like FreeBSD and OpenBSD.

I tested with following code.
====================
# ifconfig gif0 create
# ifconfig gif0 tunnel 10.1.1.1  10.1.1.2
# ifconfig gif0 inet 192.168.100.1 192.168.100.100

# ifconfig gif1 create
# ifconfig gif1 tunnel 192.168.100.1 192.168.100.100
# ifconfig gif1 inet 192.168.101.1 192.168.101.101

# ifconfig gif2 create
# ifconfig gif2 tunnel 192.168.101.1 192.168.101.101
# ifconfig gif2 inet 192.168.102.1 192.168.102.102

# ping -w 1 -c 1 192.168.102.102
# dmesg | tail -n 1
gif0: recursively called too many times(2)
====================
2015-12-04 02:26:11 +00:00