Commit Graph

2324 Commits

Author SHA1 Message Date
ozaki-r
e72fec577e Fix db_print_llinfo
rt_llinfo is now struct llentry.
2015-11-06 08:55:49 +00:00
ozaki-r
60defe31a6 Fix inappropriate rt_flags check
It depended on either RTF_CLONED or RTF_CLONING must be set, however,
the assumption didn't meet for userland problems that create a route
via RTM_ADD.

This fixes an issue that running rarpd causes the following kernel panic
reported by nonaka@:
  panic: kernel diagnostic assertion "(la->la_flags & LLE_STATIC) == 0"
  failed: file "/usr/src/sys/netinet/if_arp.c", line 1339
2015-11-06 08:38:43 +00:00
ozaki-r
847c251da6 Stop callout in arp_rtrequest(RTM_DELETE)
This change fixes arptimer panic after removing an interface
(say by drvctl -d), which is reported by Takahiro Hayashi.

This change also fixes llentry's reference counting; we have
to take into account rtentry#rt_llinfo as well as arptimer.
2015-10-20 07:46:59 +00:00
ozaki-r
e4a5751875 Stop using softnet_lock (fix possible deadlock)
Using softnet_lock for mutual exclusion between lltable_free and
arptimer was wrong and had an issue causing a deadlock between
them;  lltable_free waits arptimer completion by calling
callout_halt with softnet_lock that is held in arptimer, however
lltable_free also holds llentry's lock that is also held in
arptimer so arptimer never obtain the lock and both never go
forward eventually.  We have to pass llentry's lock to
callout_halt instead.
2015-10-20 07:35:15 +00:00
roy
a2d314543b In the event of an error within arpresolve(), delete the cloned route
otherwise it would never be deleted.
2015-10-14 11:22:55 +00:00
roy
b0f4622d81 Save and clear the la route while we have a write lock 2015-10-14 11:17:57 +00:00
rjs
8c2654abca Add core networking support for SCTP. 2015-10-13 21:28:34 +00:00
roy
222d6fab6a arpresolve() now returns 0 on success otherwise an error code.
Callers of arpresolve() now pass the error code back to their caller,
masking out EWOULDBLOCK.

This allows applications such as ping(8) to display a suitable error
condition.
2015-10-13 12:33:07 +00:00
roy
9ba2bef003 Move the NOARP check up a bit so that it works when an la is created
but hasn't been resolved yet.
Fixes PR kern/17611.
2015-10-13 11:13:37 +00:00
roy
c47c3c3042 Include arp.h to restore the sysctl net.inet.ip.dad_count.
Fixes PR kern/49883 thanks to HITOSHI Osada.
2015-10-13 09:46:42 +00:00
roy
b61ebcc9c7 Simplify la handling in arpresolve() by asking arplookup() not to create
a la. If a la is needed arpresolve() will then create it or mark the
current la as writable.
2015-10-13 09:33:35 +00:00
roy
620387577c Create a temporary define involving IFF_STATICARP if we have it
instead of just testing for __FreeBSD__.
No functional change.

ok: ozaki-r@
2015-10-08 08:17:37 +00:00
ozaki-r
98c468dd77 Create an llentry after fixing an interface to store
In case of RTF_LOCAL routes, we change an output interface
of a route from original one to lo0ifp. An llentry also
has to be stored to lo0ifp in such cases.

Problem reported by roy@
2015-10-07 00:33:27 +00:00
ozaki-r
a7ed97a295 Fix arplookup logic
It should first lookup and then create an entry if not found (and if
creation is requested).
2015-10-05 08:17:31 +00:00
skrll
e22ecac88e Make this compile again 2015-09-21 13:32:26 +00:00
roy
f3b0c038a1 If, for whatever reason, a local interface route is removed and then
re-added, mark it as a local route.

While here, if changing the route to go via the loopback interface
remove any inherited MTU value.
2015-09-11 10:33:32 +00:00
ozaki-r
4c03bf20c9 Remove wrong KASSERT in arptfree
la_rt can be NULL because arptimer that calls arptfree doesn't always
free llentry so llentry can remain with la_rt == NULL. So we instead
check whether la_rt is NULL or not and do arptfree if not.

This fixes PR kern/50184 (confirmed by martin@) and
PR kern/50186 (maybe).
2015-09-09 01:24:01 +00:00
ozaki-r
c2ed920b63 Revert v1.176 for further proper fix 2015-09-09 01:22:28 +00:00
ozaki-r
cac0e9c370 Refactor tcp_mtudisc
No functional change.
2015-09-07 01:56:50 +00:00
ozaki-r
6c5982b876 CID 1322880: remove unnecessary m != NULL checks 2015-09-07 01:18:27 +00:00
ozaki-r
d5ad433b2c CID 1322878: simplify log output flow 2015-09-07 01:17:37 +00:00
ozaki-r
54c4f3b688 Do rt_refcnt++ when set a rtentry to another rtentry's rt_gwroute
And also do rtfree when deref a rtentry from rt_gwroute.
2015-09-02 11:35:11 +00:00
christos
00158cce6d XXX: Disable KASSERT for now since locking is broken for interface removals. 2015-09-02 09:28:13 +00:00
ozaki-r
13b8e486ae Fix building kernels w/o ether 2015-08-31 16:46:14 +00:00
ozaki-r
ac75483513 Fix building kernels w/o DIAGNOSTIC 2015-08-31 09:21:55 +00:00
ozaki-r
7dc37e542b Remove obsolete global variables and sysctl MIBs 2015-08-31 08:06:30 +00:00
ozaki-r
8997ac8f09 Replace ARP cache (llinfo) with lltable/llentry
Highlights of the change are:
- Use llentry instead of llinfo to manage ARP caches
  - ARP specific data are stored in the hashed list
    of an interface instead of the global list (llinfo_arp)
- Fine-grain locking on llentry
- arptimer (callout) per ARP cache
  - the global timer callout with the big locks can be
    removed (though softnet_lock is still required for now)
- net.inet.arp.prune is now obsoleted
  - it was the interval of the global timer callout
- net.inet.arp.refresh is now obsoleted
  - it was a parameter that prevents expiration of active caches
  - Removed to simplify the timer logic, but we may be able to
    restore the feature if really needed

Proposed on tech-kern and tech-net.
2015-08-31 08:05:20 +00:00
ozaki-r
879526da38 Hook up lltable/llentry with the kernel (and rumpkernel)
It is built and initialized on bootup, but there is no user for now.

Most codes in in.c are imported from FreeBSD as well as lltable/llentry.
2015-08-31 08:02:44 +00:00
ozaki-r
3aedc74443 Make rt_refcnt take into account rt_timer 2015-08-31 06:25:15 +00:00
pooka
1c4a50f192 sprinkle _KERNEL_OPT 2015-08-24 22:21:26 +00:00
christos
e7ae23fd9e include "ioconf.h" to get the 'void <driver>attach(int count);' prototype. 2015-08-20 14:40:16 +00:00
ozaki-r
f818671bf4 Move insane goto label 2015-08-12 07:13:14 +00:00
ozaki-r
55140c1926 Use time_uptime instead of time_second to avoid time leaps
Some codes in sys/net* use time_second to manage time periods such as
cache expirations. However, time_second doesn't increase monotonically
and can leap by say settimeofday(2) according to time_second(9). We
should use time_uptime instead of it to avoid such time leaps.

This change replaces time_second with time_uptime. Additionally it
converts a time based on time_uptime to a time based on time_second
when the kernel passes the time to userland programs that expect
the latter, and vice versa.

Note that we shouldn't leak time_uptime to other hosts over the
netowrk. My investigation shows there is no such leak:
http://mail-index.netbsd.org/tech-net/2015/08/06/msg005332.html

Discussed on tech-kern and tech-net.
2015-08-07 08:11:33 +00:00
matt
49cb8763aa If we are sending a window probe and there's unacked data in the socket, make
sure at least the persist timer is running.
2015-07-24 04:33:50 +00:00
matt
6de0fc0ff8 Make sure that snd_win doesn't go negative. 2015-07-24 04:31:20 +00:00
ozaki-r
9eae87d0c8 Reform use of rt_refcnt
rt_refcnt of rtentry was used in bad manners, for example, direct rt_refcnt++
and rt_refcnt-- outside route.c, "rt->rt_refcnt++; rtfree(rt);" idiom, and
touching rt after rt->rt_refcnt--.

These abuses seem to be needed because rt_refcnt manages only references
between rtentry and doesn't take care of references during packet processing
(IOW references from local variables). In order to reduce the above abuses,
the latter cases should be counted by rt_refcnt as well as the former cases.

This change improves consistency of use of rt_refcnt:
- rtentry is always accessed with rt_refcnt incremented
- rtentry's rt_refcnt is decremented after use (rtfree is always used instead
  of rt_refcnt--)
- functions returning rtentry increment its rt_refcnt (and caller rtfree it)

Note that rt_refcnt prevents rtentry from being freed but doesn't prevent
rtentry from being updated. Toward MP-safe, we need to provide another
protection for rtentry, e.g., locks. (Or introduce a better data structure
allowing concurrent readers during updates.)
2015-07-17 02:21:08 +00:00
ozaki-r
fcda92b6be Remove unused arguments and the associated code from nd6_nud_hint()
from OpenBSD
2015-07-15 09:20:18 +00:00
ozaki-r
bd4fe18031 Make global variables static 2015-07-15 08:49:15 +00:00
ozaki-r
f2abd6a2e3 Move rt_gwroute operation out of stripoutput
We should do it in ip_hresolv_needed.
2015-07-14 08:44:59 +00:00
ozaki-r
f81368b844 Use ip_hresolv_output for if_token as well
I thought we cannot apply ip_hresolv_output to if_token because
rt0 looked being needed by arpresolve in token_output. However,
rt0 is actually not used by arpresolve in NetBSD (see obsolete
ARPRESOLVE macro).
2015-07-01 03:39:36 +00:00
roy
938235dc97 errno -> error, spotted by the hawk skrll 2015-06-08 08:19:20 +00:00
roy
17aa5fe87d It's possible we could not have any ready addresses. 2015-06-08 08:02:43 +00:00
roy
be5b0a3a89 Don't set errno. Thanks to skrll@ 2015-06-08 07:59:54 +00:00
ozaki-r
6ea8c2e666 Pull out route lookups from L2 output routines
Route lookups for routes of RTF_GATEWAY were done in L2 output
routines such as ether_output, but they should be done in L3
i.e., before L2 output routines. This change places the lookups
between L3 output routines (say ip_output) and the L2 output
routines.

The change is based on dyoung's patch submitted in the thread:
https://mail-index.netbsd.org/tech-net/2013/02/01/msg003847.html
You can find out detailed investigations by dyoung about the
issue in there.

Note that the change introduces a workaround for MPLS. ether_output
knew that it needs to fill the ethertype of a frame as MPLS,
based on a tag of an original route (rtentry), but now we don't
pass it to ehter_output. So we have to tell that in another way.
We use mtag to do so for now, which introduces some overhead.
We should fix it somehow in the future.

Discussed on tech-kern and tech-net.
2015-06-04 09:19:59 +00:00
rtr
e7083d7a4b remove transitional functions in{,6}_pcbconnect_m() that were used in
converting protocol user requests to accept sockaddr instead of mbufs.

remove tcp_input copy in to mbuf from sockaddr and just copy to sockaddr
to make it possible for the transitional functions to go away.

no version bump since these functions only existed for a short time and
were commented as adapters (they appeared in 7.99.15).
2015-05-24 15:43:45 +00:00
ozaki-r
423491c235 Replace NARC with NARCNET to follow renaming at 2007
Hmm, is anyone using this?
2015-05-22 07:44:46 +00:00
ozaki-r
b41c75c271 Use LIST_FOREACH{,_SAFE}
The first loop doesn't remove any items in it, so we can use
LIST_FOREACH instead of LIST_FOREACH_SAFE.
2015-05-21 09:29:51 +00:00
ozaki-r
442b227d9f Use NULL instead of 0 for pointers 2015-05-21 09:27:10 +00:00
ozaki-r
2c0e34375a Make arp_init, in_revarpinput and revarprequest static 2015-05-21 09:26:18 +00:00
kefren
f3bd20e96c Use RUN_ONCE to initialize iss secret. Suggested by riastradh@ 2015-05-19 17:33:43 +00:00