mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 05:37:54 +00:00
nic_router: reset uplink IP on link state change
This commit is contained in:
parent
fe21ab48e0
commit
4802d22527
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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<Update_domain>::Invalid) {
|
||||
|
||||
/* if the interface moved to another domain, finish the operation */
|
||||
try { _attach_to_domain_finish(); }
|
||||
try { attach_to_domain_finish(); }
|
||||
catch (Pointer<Domain>::Invalid) { }
|
||||
}
|
||||
}
|
||||
|
@ -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 **
|
||||
|
@ -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) { }
|
||||
}
|
||||
|
@ -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<Uplink> _link_state_handler;
|
||||
|
||||
Ipv4_address_prefix _read_interface();
|
||||
|
||||
void _handle_link_state();
|
||||
|
||||
|
||||
/********************
|
||||
** Net::Interface **
|
||||
|
Loading…
Reference in New Issue
Block a user