diff --git a/repos/os/src/server/nic_router/domain.cc b/repos/os/src/server/nic_router/domain.cc index 3e88fd863f..a39f3e5e59 100644 --- a/repos/os/src/server/nic_router/domain.cc +++ b/repos/os/src/server/nic_router/domain.cc @@ -53,6 +53,9 @@ Domain_base::Domain_base(Xml_node const node) void Domain::ip_config(Ipv4_config const &new_ip_config) { + if (!_ip_config_dynamic) { + throw Ip_config_static(); } + /* discard old IP config if any */ if (ip_config().valid) { @@ -86,6 +89,10 @@ void Domain::ip_config(Ipv4_config const &new_ip_config) interface.attach_to_remote_ip_config(); }); }); + } else { + _interfaces.for_each([&] (Interface &interface) { + interface.attach_to_domain_finish(); + }); } } @@ -93,7 +100,8 @@ void Domain::ip_config(Ipv4_config const &new_ip_config) void Domain::discard_ip_config() { /* install invalid IP config */ - ip_config(Ipv4_address(), Ipv4_address(), Ipv4_address(), Ipv4_address()); + Ipv4_config const new_ip_config; + ip_config(new_ip_config); } diff --git a/repos/os/src/server/nic_router/domain.h b/repos/os/src/server/nic_router/domain.h index 2b1b6f5a53..8335e6d583 100644 --- a/repos/os/src/server/nic_router/domain.h +++ b/repos/os/src/server/nic_router/domain.h @@ -129,8 +129,9 @@ class Net::Domain : public Domain_base, public: - struct Invalid : Genode::Exception { }; - struct No_next_hop : Genode::Exception { }; + struct Invalid : Genode::Exception { }; + struct Ip_config_static : Genode::Exception { }; + struct No_next_hop : Genode::Exception { }; Domain(Configuration &config, Genode::Xml_node const node, diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index 8395b29fad..453a57e7e1 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -256,11 +256,11 @@ void Interface::_detach_from_domain_raw() void Interface::_attach_to_domain(Domain_name const &domain_name) { _attach_to_domain_raw(domain_name); - _attach_to_domain_finish(); + attach_to_domain_finish(); } -void Interface::_attach_to_domain_finish() +void Interface::attach_to_domain_finish() { /* if domain has yet no IP config, participate in requesting one */ Domain &domain = _domain(); @@ -1631,7 +1631,7 @@ void Interface::handle_config_3() catch (Pointer::Invalid) { /* if the interface moved to another domain, finish the operation */ - try { _attach_to_domain_finish(); } + try { attach_to_domain_finish(); } catch (Pointer::Invalid) { } } } diff --git a/repos/os/src/server/nic_router/interface.h b/repos/os/src/server/nic_router/interface.h index ac54921757..e56a5e9042 100644 --- a/repos/os/src/server/nic_router/interface.h +++ b/repos/os/src/server/nic_router/interface.h @@ -271,8 +271,6 @@ class Net::Interface : private Interface_list::Element void _attach_to_domain_raw(Domain_name const &domain_name); - void _attach_to_domain_finish(); - void _apply_foreign_arp(); void _send_icmp_dst_unreachable(Ipv4_address_prefix const &local_intf, @@ -382,6 +380,8 @@ class Net::Interface : private Interface_list::Element void init(); + void attach_to_domain_finish(); + /*************** ** Accessors ** diff --git a/repos/os/src/server/nic_router/uplink.cc b/repos/os/src/server/nic_router/uplink.cc index 4160c49136..5ab6defda3 100644 --- a/repos/os/src/server/nic_router/uplink.cc +++ b/repos/os/src/server/nic_router/uplink.cc @@ -34,10 +34,19 @@ Net::Uplink::Uplink(Env &env, Nic::Connection(env, this, BUF_SIZE, BUF_SIZE, label.string()), Net::Interface(env.ep(), timer, mac_address(), alloc, Mac_address(), config, interfaces, _intf_policy), - _label(label) + _label(label), + _link_state_handler(env.ep(), *this, &Uplink::_handle_link_state) { rx_channel()->sigh_ready_to_ack(_sink_ack); rx_channel()->sigh_packet_avail(_sink_submit); tx_channel()->sigh_ack_avail(_source_ack); tx_channel()->sigh_ready_to_submit(_source_submit); + Nic::Connection::link_state_sigh(_link_state_handler); +} + + +void Net::Uplink::_handle_link_state() +{ + try { domain().discard_ip_config(); } + catch (Domain::Ip_config_static) { } } diff --git a/repos/os/src/server/nic_router/uplink.h b/repos/os/src/server/nic_router/uplink.h index 9ba8ce12ad..d63b02ecdb 100644 --- a/repos/os/src/server/nic_router/uplink.h +++ b/repos/os/src/server/nic_router/uplink.h @@ -62,10 +62,13 @@ class Net::Uplink : public Uplink_base, BUF_SIZE = Nic::Session::QUEUE_SIZE * PKT_SIZE, }; - Genode::Session_label const &_label; + Genode::Session_label const &_label; + Genode::Signal_handler _link_state_handler; Ipv4_address_prefix _read_interface(); + void _handle_link_state(); + /******************** ** Net::Interface **