Commit Graph

2602 Commits

Author SHA1 Message Date
roy 42900924fd Introduce the routing flag RTF_LOCAL to track local address routes.
Add functions rt_ifa_addlocal() and rt_ifa_remlocal() to add and remove
local routes for the address and announce the new address and route
to the routing socket.

Add in_ifaddlocal() and in_ifremlocal() to use these functions.
Rename in6_if{add,rem}loop() to in6_if{add,rem}local() and use these
functions.

rtinit() no longer announces the address, just the network route for the
address. As such, calls to rt_newaddrmsg() have been removed from
in_addprefix() and in_scrubprefix().

This solves the problem of potentially more than one announcement, or no
announcement at all for the address in certain situations.
2015-02-26 09:54:46 +00:00
roy 1d0df6e404 Rename nd6_rtmsg() to rt_newmsg() and move into the generic routing code
as it's not IPv6 specific and will be used elsewhere.
2015-02-25 12:45:34 +00:00
roy ce0c70c924 Clean comments and style. 2015-02-24 20:06:09 +00:00
alnsn 84db77b722 Copyright year. 2015-02-14 21:32:46 +00:00
alnsn 321f9dd4e2 In some implementations pc->k is signed. Cast it to uint32_t before comparing. 2015-02-14 21:17:05 +00:00
alnsn 7674f27971 Properly track initialisation of registers for BPF_JMP instructions. 2015-02-14 21:14:56 +00:00
alnsn 9c78c5707a Don't emit wrapped-around reads. They're dead code but dead code elimination
logic isn't smart enough to figure it out.

Found by afl fuzzer http://lcamtuf.coredump.cx/afl/.
2015-02-13 15:59:17 +00:00
alnsn f34037ede3 Fix bugs found by afl fuzzer http://lcamtuf.coredump.cx/afl/. 2015-02-12 23:09:55 +00:00
alnsn 36d2b4c46c Fix the build. 2015-02-11 12:53:15 +00:00
alnsn d9eacfd7ae It's not enough to check that a class of the last instruction is BPF_RET.
The opcodes in bpf_validate() must match opcodes understood by bpf_filter().

Found by afl-fuzz http://lcamtuf.coredump.cx/afl/.
2015-02-11 12:03:30 +00:00
rmind e94658962b npf_conn_establish: fix the previous change - drop the reference on error. 2015-02-05 22:04:03 +00:00
rmind f56b8821ba npfctl(8): report dynamic rule ID in a comment, print the case when libpcap
is used correctly.  Also, add npf_ruleset_dump() helper in the kernel.
2015-02-02 00:31:39 +00:00
rmind 518c0b96b2 - npf_conn_establish: remove a rare race condition when we might destroy a
connection when it is still referenced by another thread.
- npf_conn_destroy: remove the backwards entry using the saved key, PR/49488.
- Sprinkle some asserts.
2015-02-01 22:41:22 +00:00
ozaki-r 0ea58c0e8c Remove an outdated snippet for NET_MPSAFE 2015-01-16 10:37:51 +00:00
ozaki-r d850ab5089 Introduce defflag for NET_MPSAFE 2015-01-16 10:36:14 +00:00
christos 3eceacff0e rename variable to avoid conflict with "div" 2015-01-15 16:31:05 +00:00
ozaki-r e85cdef150 Use pserialize for rtlist in bridge
This change enables lockless accesses to bridge rtable lists.
See locking notes in a comment to know how pserialize and
mutexes are used. Some functions are rearranged to use
pserialize. A workqueue is introduced to use pserialize in
bridge_rtage via bridge_timer callout.

As usual, pserialize and mutexes are used only when NET_MPSAFE
on. On the other hand, the newly added workqueue is used
regardless of NET_MPSAFE on or off.
2015-01-08 10:47:44 +00:00
ozaki-r 0af747000e Reset the expire time of a cache on receiving a frame for the cache
The expire time of a cache in a bridge MAC address table was never reset
once it is initialized regardless of traffic for the cache. The behavior
isn't supposed and active caches are unnecessarily expired and removed.

PR kern/49507
2015-01-01 08:43:26 +00:00
ozaki-r cba69a875a Use pserialize in bridge
This change enables lockless accesses to bridge member lists.
See locking notes in a comment to know how pserialize and
mutexes are used.

This change also provides support for softint-based interrupt
handling; pserialize readers can run in both HW interrupt and
softint contexts.

As usual, pserialize is used only when NET_MPSAFE on.
2014-12-31 17:36:24 +00:00
christos 8d8eaf1f35 Don't forget to destroy the mutex before freeing the nat struct on a failed
load.
XXX: pullup -7
2014-12-30 19:11:44 +00:00
ozaki-r 9116f11456 Remove unnecessary variable bc 2014-12-29 13:38:13 +00:00
ozaki-r 1635c5638e Use LIST_FOREACH_SAFE in bridge_rt* functions 2014-12-25 09:10:01 +00:00
ozaki-r df0047d049 Replace malloc/free with kmem_* in if_bridge
Additionally M_NOWAIT is replaced with KM_SLEEP.
2014-12-24 08:55:09 +00:00
ozaki-r 4ad4b3a93d Call ether_input/m_freem without holding a lock or referencing unnecessary objects
When NET_MPSAFE on, a bridge tries to pass up a packet to Layer 3
(or call m_freem) with holding a lock or referencing unnecessary
objects. That causes random lock ups. The change fixes the issue.
2014-12-22 09:42:45 +00:00
rmind 1a89186798 NPF: set the connection flags atomically in the post-creation logic and
fix a tiny race condition window.  Might fix PR/49488.
2014-12-20 16:19:43 +00:00
ozaki-r ae4ecace09 Replace if_attach of if_tap with if_initialize and if_register 2014-12-17 09:41:30 +00:00
ozaki-r 1db1d86128 Introduce if_initialize and if_register as an alternative to if_attach
if_attach initializes an ifnet object and registers it to the system
(e.g., ifnet_list), however, if_attach doesn't complete the
initialization and the rest of it will be done by if_alloc_sadl
that is normally directly called by device drivers or called via
functions like ether_ifattach. So there is a race between
if_attach and if_alloc_sadl (A half-baked ifnet object may be
accessed, for example, via ioctl between them).

The aim of this fix is to register an initializing ifnet object
after completing its initializations. To this end, this fix
separates if_attach into an initialization part (if_initialize)
and a registration part (if_register) and call the latter after
if_alloc_sadl (ether_ifattach). So a typical usage of the two
new APIs is like this:

  if_initialize(ifp);  // was if_attach
  ether_ifattach(ifp, enaddr);
  if_register(ifp);

Nonetheless, changing every drivers to do so at once isn't
feasible. So we keep if_attach working as it used to be and
will change only some drivers that we need at this point.
Once we know the fix really works well, we'll change all
the others.

Some more information of the fix can be found here:
http://mail-index.netbsd.org/tech-kern/2014/12/10/msg018242.html

No objection on tech-kern and tech-net.
2014-12-15 06:52:25 +00:00
martin 0cb17482c5 Avoid a race when the ifp->if_slowtimo pointer is changed while we are
running in if_slowtimo already. Suggested by Masao Uebayashi
in PR kern/49462.
2014-12-14 08:57:14 +00:00
martin 46965919cf Avoid scheduling more slow timeouts while we are in the process of detaching
the interface: set if_slowtimo to NULL before doing the callout_halt()
and test for that in the callout. Fixes PR kern/49462.
2014-12-11 14:33:22 +00:00
ozaki-r f0c27b59aa Tweak ifconf (retry)
The tweak makes the code intention clear and further changes easy.

No functional change.

The first trial broke SIOCGIFCONF (PR 49437). So as not to repeat the mistake,
t_ifconf was added. It should warn if something goes wrong on ifconf.
2014-12-08 04:55:47 +00:00
justin a25ec9451f Help gcc by initialising variable 2014-12-08 00:44:45 +00:00
christos c72e0db104 add DL_PRINT macro 2014-12-03 01:31:37 +00:00
christos 3bfbf6e926 fix debugging printf. 2014-12-02 21:28:31 +00:00
christos f89df58b37 use the new printing code. 2014-12-02 20:25:47 +00:00
christos cedc6be518 zero out the sockaddrs when dup'ing. 2014-12-02 19:57:11 +00:00
christos 2c1c80163c missed _ 2014-12-02 19:34:33 +00:00
christos 2510f73d33 - split struct dladdr out of struct sockaddr_dl
- add routines to print struct sockaddr_dl and struct dladdr
- make if_dl.h idempotent
2014-12-02 19:32:09 +00:00
ozaki-r 087b8cc474 Revert "Pull if_drain routine out of m_reclaim"
The commit broke dlopen()'d rumpnet on platforms where ld.so does not
override weak aliases (e.g. musl, Solaris, potentially OS X, ...).

Requested by pooka@.
2014-12-02 04:43:35 +00:00
ozaki-r 1e2ac880ec Make more functions static
No functional change.
2014-12-01 07:15:42 +00:00
christos 7e587a9675 PR/49437: jmcneill: revert broken changes that broke SIOCGIFCONF (mdnsd uses it) 2014-12-01 00:27:05 +00:00
rmind 9e6a3bf60e - npf_config_load: if loading the connections, do not perform any actice
NAT policy take over or or portmap sharing - just replace them all.
- npf_config_fini: flush with the empty connection database.
- npf_nat_import: fix the stat counter.
2014-11-30 01:37:53 +00:00
rmind ff2240e4b2 NPF:
- npf_nat_import: take the port only if using the portmap.
- Sprinkle some comments and asserts.
2014-11-30 00:40:55 +00:00
ozaki-r 7ccd75e01e Remove dead codes and make if_free_sadl static
No functional change.
2014-11-28 08:29:00 +00:00
ozaki-r 0b2631673e Pull if_drain routine out of m_reclaim
It's if-specific and should be in if.c.

No functional change.
2014-11-27 03:15:51 +00:00
rmind 0f9c6f0017 NPF: fix the reference counting and share the active NAT portmap correctly
when performing the reload.  Should fixes PR/49412, reported by kardel@.
2014-11-26 21:25:35 +00:00
ozaki-r 1d0321acf8 Tweak ifconf variants
The tweaks make the code intention clear and make further changes easy.

No functional change.
2014-11-26 09:53:53 +00:00
ozaki-r e45b80861c Change if_slowtimo_ch to a pointer
One benefit to do so is to reduce memory used for struct callout;
we can avoid to allocate struct callout for interfaces that don't
use callout.

Requested by uebayasi@.
2014-11-26 09:38:42 +00:00
ozaki-r 3f6a7c52ac Create if_slowtimo (if_watchdog) callout for each interface
This change is to obviate the need to run if_slowtimo callbacks that
may sleep inside IFNET_FOREACH. And also by this change we can turn
on MPSAFE of callouts individually.

Discussed with uebayasi@ and riastradh@.
2014-11-26 07:43:04 +00:00
ozaki-r af22e70cfc Rename if_watchdog to if_slowtimo
if_watchdog callbacks do a little more than what "watchdog" suggests.

Discussed with uebayasi@ (the idea originally from openbsd-tech).
2014-11-26 07:22:05 +00:00
ozaki-r 1ceb2f0443 Make if_slowtimo static 2014-11-26 07:06:03 +00:00