Commit Graph

21 Commits

Author SHA1 Message Date
075ab46d39 Clang: do not use angle brackets for local includes 2019-10-04 00:47:17 +02:00
Martin Stein
304cb290d9 nic_router: rework quota accounting
* Account all RAM/CAP quota of a session except quota for metadata used in
  core. The latter is considered when asking if a session can afford to make
  an operation but it does not get accounted to always be able to pay back all
  quota when a session closes. The general accounting mechanism is moved from
  atop of the allocators down to the level of RAM/RM session operations.
* report statistics about session objects and quota if <report stats="yes"
  quota="yes"/> is configured. (default is yes if <report> is present)

Issue #2953
2018-10-29 09:36:21 +01:00
Martin Stein
bd77bb41df nic_router: improve handling of TCP termination
Like suggested by RFC 2663, reprogram the dissolve timeout of a TCP link
state to 2 times the maximum segment lifetime (by default 1 minute) when
receiving a matching packet with the FIN flag set, or with the ACK flag
set to acknowledge a FIN of the remote side.

Mark a link state as closed (no further reprogramming of the dissolve
timeout) and set the dissolve timeout to 2 times the maximum segment
lifetime when receiving a packet with the RESET flag set.

Issue #2953
2018-10-29 09:36:21 +01:00
Martin Stein
90fcba79c6 nic_router: non-critical logs only when verbose
* Do not log events that are not critical (deadly) to the NIC router if not
  configured to be verbose,
* Print almost all log lines with a prefix of the domain name they are
  related to,
* And, do not use Genode::error and Genode::warning as they make it hard to
  read the log with the domain name prefixes.

Fixes #2840
2018-06-29 10:44:53 +02:00
Martin Stein
19816bcd31 nic_router: when freeing a link log it beforehand
So, it can be located more easily when something goes wrong while
freeing a link.

Fixes #2815
2018-05-30 13:36:36 +02:00
Martin Stein
7b3343c2dc nic_router: NAPT for ICMP echo messages
This follows the guidelines in RFC 5508 to enable ICMP echo through a NAPT
channel of the NIC router. It serves also as blueprint for ICMP queries in
general (they are merely not enabled because we don't test them by now).

Issue #2732
2018-04-10 11:11:53 +02:00
Martin Stein
d2adce7ba6 nic_router: fix bug in Link::handle_config
We updated UDP link states with the wrong idle-timeout value.

Issue #2732
2018-04-10 11:11:53 +02:00
Martin Stein
98617432c3 nic_router: send ICMP error on unroutable packet
Send an ICMP "Destination Network Unreachable" as response to packets that
are not routable by the NIC router.

Issue #2732
2018-04-10 11:11:52 +02:00
Martin Stein
1044c2fcab nic_router: simplify the pointer utility
Instead of Pointer<T>::set use assignment operator with implicit constructor
from T-reference. Instead of Pointer<T>::unset use assignment operator with
Pointer<T>(). Instead of Pointer<T>::deref provide () operator.

Issue #2730
2018-03-29 16:03:28 +02:00
Martin Stein
92a30e0953 nic_router: handle configuration changes
The router reacts as follows to a configuration change:

1) Construct new internal configuration representation (the old one stays
   in place to be able to do comparisons in the following steps)
2) Iterate through all user-dependent objects (interfaces, link states, ARP
   information, DHCP information) and re-check which remain valid with the
   new configuration and which must be dismissed.
3) Adapt the objects that remain valid to the new configuration (re-write
   references) and remove or detach the dismissed objects.
4) Do a link state DOWN at each interface and a link state UP at each
   interface that remains attached to a domain.
5) Replace the old internal configuration representation with the new one

This way, the router keeps as much user dependent states as possible
while going through a configuration change. Thus, overwriting the old
configuration with an exact copy of itself is (almost) transparent to
clients of the router. Almost, because there are things the router must
do on every configuration handling, like re-scheduling the expiration
timeouts of links.

Ref #2670
2018-03-29 15:39:44 +02:00
Martin Stein
869297a672 nic_router: avoid "close" where we mean "dissolve"
In the context of link state objects we often used the term "close" were we
actually meant "dissolve". The term "close" originated from the TCP connection
state and is still used in TCP links in the correct manner.

Issue #2609
2017-12-21 15:01:54 +01:00
Martin Stein
859a5fd208 nic_router: simplify Interface::_new_link
Issue #2609
2017-12-21 15:01:53 +01:00
Martin Stein
4927a6f679 nic_router: multiple interfaces at one domain
Act as hub for the interfaces at a domain. This also changes the roles of the
Domain and Interface classes. By now the Interface held the data structures for
the ARP cache, foreign ARP waiters, and the searchtrees for layer 3 links. All
these structures have moved to the Domain while the memory allocations and
lifetime management for the contents of these structures still come from from
the according Interface object. The mentioned data structures were also adapted
to fit the fact that they now may maintain objects of different interfaces.

Issue #2609
2017-12-21 15:01:53 +01:00
Martin Stein
b63d83e6a3 nic_router: get rid of Interface::print
Actually interfaces have no own human-readable identifier. They shall instead
use the print functionality of their domain.

Issue #2609
2017-12-21 15:01:52 +01:00
Martin Stein
3cdcb528ff nic_router: advanced timeout configuration
Replace former rtt_sec attribute of the <config> tag by more specific
(and still optional) attributes for timeouts used in the NIC router
(these are also the default values):

<config dhcp_discover_timeout_sec="10"
        dhcp_request_timeout_sec="10"
        dhcp_offer_timeout_sec="10"
        udp_idle_timeout_sec="30"
        tcp_idle_timeout_sec="600"
        tcp_max_segm_lifetime_sec="30">

Details about the new attributes can be found in the README of the router.

Issue #2590
2017-12-21 15:01:32 +01:00
Martin Stein
e5b9a6cc8b nic_router: rework round-trip-time handling
Do not use two times the RTT for the lifetime of links but use it as
it is configured to simplify the usage of the router. Internally, use
Microseconds/Duration type instead of plain integers.

Ref #2490
2017-10-19 13:29:45 +02:00
Martin Stein
d0f5838c61 net: clean up header fields and accessors
Apply the style rule that an accessor is named similar to the the underlying
value. Provide read and write accessors for each mandatory header attribute.
Fix some incorrect structure in the headers like with the flags field
in Ipv4_packet.

Ref #2490
2017-10-19 13:29:43 +02:00
Martin Stein
c70fed29f7 os/timer: interpolate time via timestamps
Previously, the Genode::Timer::curr_time always used the
Timer_session::elapsed_ms RPC as back end.  Now, Genode::Timer reads
this remote time only in a periodic fashion independently from the calls
to Genode::Timer::curr_time. If now one calls Genode::Timer::curr_time,
the function takes the last read remote time value and adapts it using
the timestamp difference since the remote-time read. The conversion
factor from timestamps to time is estimated on every remote-time read
using the last read remote-time value and the timestamp difference since
the last remote time read.

This commit also re-works the timeout test. The test now has two stages.
In the first stage, it tests fast polling of the
Genode::Timer::curr_time. This stage checks the error between locally
interpolated and timer-driver time as well as wether the locally
interpolated time is monotone and sufficiently homogeneous. In the
second stage several periodic and one-shot timeouts are scheduled at
once. This stage checks if the timeouts trigger sufficiently precise.

This commit adds the new Kernel::time syscall to base-hw. The syscall is
solely used by the Genode::Timer on base-hw as substitute for the
timestamp. This is because on ARM, the timestamp function uses the ARM
performance counter that stops counting when the WFI (wait for
interrupt) instruction is active. This instruction, however is used by
the base-hw idle contexts that get active when no user thread needs to
be scheduled.  Thus, the ARM performance counter is not a good choice for
time interpolation and we use the kernel internal time instead.

With this commit, the timeout library becomes a basic library. That means
that it is linked against the LDSO which then provides it to the program it
serves. Furthermore, you can't use the timeout library anymore without the
LDSO because through the kernel-dependent LDSO make-files we can achieve a
kernel-dependent timeout implementation.

This commit introduces a structured Duration type that shall successively
replace the use of Microseconds, Milliseconds, and integer types for duration
values.

Open issues:

* The timeout test fails on Raspberry PI because of precision errors in the
  first stage. However, this does not render the framework unusable in general
  on the RPI but merely is an issue when speaking of microseconds precision.

* If we run on ARM with another Kernel than HW the timestamp speed may
  continuously vary from almost 0 up to CPU speed. The Timer, however,
  only uses interpolation if the timestamp speed remained stable (12.5%
  tolerance) for at least 3 observation periods. Currently, one period is
  100ms, so its 300ms. As long as this is not the case,
  Timer_session::elapsed_ms is called instead.

  Anyway, it might happen that the CPU load was stable for some time so
  interpolation becomes active and now the timestamp speed drops. In the
  worst case, we would now have 100ms of slowed down time. The bad thing
  about it would be, that this also affects the timeout of the period.
  Thus, it might "freeze" the local time for more than 100ms.

  On the other hand, if the timestamp speed suddenly raises after some
  stable time, interpolated time can get too fast. This would shorten the
  period but nonetheless may result in drifting away into the far future.
  Now we would have the problem that we can't deliver the real time
  anymore until it has caught up because the output of Timer::curr_time
  shall be monotone. So, effectively local time might "freeze" again for
  more than 100ms.

  It would be a solution to not use the Trace::timestamp on ARM w/o HW but
  a function whose return value causes the Timer to never use
  interpolation because of its stability policy.

Fixes #2400
2017-05-31 13:16:11 +02:00
Martin Stein
64fb2865b0 nic_router: fix compile error "flexible array ..."
Fixes #2384
2017-05-31 13:15:51 +02:00
Norman Feske
29b8d609c9 Adjust file headers to refer to the AGPLv3 2017-02-28 12:59:29 +01:00
Martin Stein
89085096d2 nic_router: new user interface and optimizations
Fixes #2139
2016-11-30 13:38:05 +01:00