From 79cc9af2121442a7933cebe749b5a8f05306c679 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Wed, 7 Sep 2022 20:24:10 +0200 Subject: [PATCH] nic_router: intf. con/destruct reports link state Creating and destructing an interface was not considered a change of its real link state as defined in the description of the config attribute in the router's README. In case of Uplink sessions this is obviously a problem as they communicate their real link state through session lifetime. But also in case of NIC sessions it's a possible to create an interface that is immediately "up" after creation or destruct an interface without its link state going "down" beforehand. Taking into account also the practical application of the attribute, reporting only on destruction and construction of interfaces that are "up" seems shorthanded. This is because a report-receiver most likely needs to be able to synchronize the lifetime of the objects that keep track of the link states with the lifetime of the corresponding sessions. That said, with this commit, the router triggers a report update on each session construction/destruction when is set. Fixes #4462 --- repos/os/src/server/nic_router/README | 8 ++++---- repos/os/src/server/nic_router/interface.cc | 4 ++++ repos/os/src/server/nic_router/uplink_session_root.cc | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/repos/os/src/server/nic_router/README b/repos/os/src/server/nic_router/README index 3f37f74e38..fd28c047ef 100644 --- a/repos/os/src/server/nic_router/README +++ b/repos/os/src/server/nic_router/README @@ -720,10 +720,10 @@ information on that, refer to [Behavior regarding the NIC-session link state]. 'link_state_triggers' -A boolean value that controls whether to enforce sending a report each time the -state that is controlled through the 'link_state' attribute of the tag -changes. I.e., whenever the real link state of any interface at the router has -changed. +A boolean value that controls whether to enforce sending a report whenever the +real link state (see description of the 'link_state' attribute) of any +interface at the router has changed. Note that whenever an interface is created +or destroyed this is considered a change of its real link state. 'interval_sec' diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index 25b74247af..8d0958fddd 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -1923,6 +1923,8 @@ Interface::Interface(Genode::Entrypoint &ep, _interfaces { interfaces } { _interfaces.insert(this); + try { _config().report().handle_interface_link_state(); } + catch (Pointer::Invalid) { } } @@ -2375,6 +2377,8 @@ void Interface::cancel_arp_waiting(Arp_waiter &waiter) Interface::~Interface() { + try { _config().report().handle_interface_link_state(); } + catch (Pointer::Invalid) { } _detach_from_domain(); _interfaces.remove(this); } diff --git a/repos/os/src/server/nic_router/uplink_session_root.cc b/repos/os/src/server/nic_router/uplink_session_root.cc index a0f4f75085..28ee10e798 100644 --- a/repos/os/src/server/nic_router/uplink_session_root.cc +++ b/repos/os/src/server/nic_router/uplink_session_root.cc @@ -106,8 +106,8 @@ Net::Uplink_session_component::Uplink_session_component(Session_env _rx.sigh_ack_avail (_interface.pkt_stream_signal_handler()); /* - * We do not install ready_to_submit because submission is only triggered by - * incoming packets (and dropped if the submit queue is full). + * We do not install ready_to_submit because submission is only triggered + * by incoming packets (and dropped if the submit queue is full). * The ack queue should never be full otherwise we'll be leaking packets. */ }