mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-09 04:15:52 +00:00
nic_router: report link state
This adds two new boolean attributes to the <report> tag of the NIC router configuration 'link_state' and 'link_state_triggers'. The former decides whether to report the link state of each NIC interface (downlink, uplinks) at the NIC router. The other decides whether to trigger reporting each time the link state of an interface changes. Fixes #3527
This commit is contained in:
parent
58247737fd
commit
27c2a66bbd
@ -298,6 +298,8 @@ append config {
|
||||
config="yes"
|
||||
quota="no"
|
||||
stats="no"
|
||||
link_state="yes"
|
||||
link_state_triggers="yes"
|
||||
interval_sec="60" />
|
||||
|
||||
<uplink domain="uplink"/>
|
||||
|
@ -57,12 +57,14 @@
|
||||
|
||||
<xs:element name="report">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="config" type="Boolean" />
|
||||
<xs:attribute name="config_triggers" type="Boolean" />
|
||||
<xs:attribute name="bytes" type="Boolean" />
|
||||
<xs:attribute name="stats" type="Boolean" />
|
||||
<xs:attribute name="quota" type="Boolean" />
|
||||
<xs:attribute name="interval_sec" type="Seconds" />
|
||||
<xs:attribute name="config" type="Boolean" />
|
||||
<xs:attribute name="config_triggers" type="Boolean" />
|
||||
<xs:attribute name="bytes" type="Boolean" />
|
||||
<xs:attribute name="stats" type="Boolean" />
|
||||
<xs:attribute name="link_state" type="Boolean" />
|
||||
<xs:attribute name="link_state_triggers" type="Boolean" />
|
||||
<xs:attribute name="quota" type="Boolean" />
|
||||
<xs:attribute name="interval_sec" type="Seconds" />
|
||||
</xs:complexType>
|
||||
</xs:element><!-- report -->
|
||||
|
||||
|
@ -870,6 +870,10 @@ void Interface::handle_link_state()
|
||||
}
|
||||
catch (Domain::Ip_config_static) { }
|
||||
catch (Keep_ip_config) { }
|
||||
|
||||
/* force report if configured */
|
||||
try { _config().report().handle_link_state(); }
|
||||
catch (Pointer<Report>::Invalid) { }
|
||||
}
|
||||
|
||||
|
||||
@ -2017,21 +2021,28 @@ Interface::~Interface()
|
||||
|
||||
void Interface::report(Genode::Xml_generator &xml)
|
||||
{
|
||||
bool const stats = _config().report().stats();
|
||||
if (stats) {
|
||||
xml.node("interface", [&] () {
|
||||
bool empty = true;
|
||||
xml.attribute("label", _policy.label());
|
||||
try { _policy.report(xml); empty = false; } catch (Report::Empty) { }
|
||||
xml.node("interface", [&] () {
|
||||
bool empty { true };
|
||||
xml.attribute("label", _policy.label());
|
||||
if (_config().report().link_state()) {
|
||||
xml.attribute("link_state", link_state());
|
||||
empty = false;
|
||||
}
|
||||
if (_config().report().stats()) {
|
||||
try {
|
||||
_policy.report(xml);
|
||||
empty = false;
|
||||
}
|
||||
catch (Report::Empty) { }
|
||||
|
||||
try { xml.node("tcp-links", [&] () { _tcp_stats.report(xml); }); empty = false; } catch (Report::Empty) { }
|
||||
try { xml.node("udp-links", [&] () { _udp_stats.report(xml); }); empty = false; } catch (Report::Empty) { }
|
||||
try { xml.node("icmp-links", [&] () { _icmp_stats.report(xml); }); empty = false; } catch (Report::Empty) { }
|
||||
try { xml.node("arp-waiters", [&] () { _arp_stats.report(xml); }); empty = false; } catch (Report::Empty) { }
|
||||
try { xml.node("dhcp-allocations", [&] () { _dhcp_stats.report(xml); }); empty = false; } catch (Report::Empty) { }
|
||||
if (empty) { throw Report::Empty(); }
|
||||
});
|
||||
}
|
||||
}
|
||||
if (empty) { throw Report::Empty(); }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -28,18 +28,20 @@ Net::Report::Report(bool const &verbose,
|
||||
Pd_session &pd,
|
||||
Reporter &reporter)
|
||||
:
|
||||
_verbose { verbose },
|
||||
_config { node.attribute_value("config", true) },
|
||||
_config_triggers { node.attribute_value("config_triggers", false) },
|
||||
_bytes { node.attribute_value("bytes", true) },
|
||||
_stats { node.attribute_value("stats", true) },
|
||||
_quota { node.attribute_value("quota", true) },
|
||||
_shared_quota { shared_quota },
|
||||
_pd { pd },
|
||||
_reporter { reporter },
|
||||
_domains { domains },
|
||||
_timeout { timer, *this, &Report::_handle_report_timeout,
|
||||
read_sec_attr(node, "interval_sec", 5) }
|
||||
_verbose { verbose },
|
||||
_config { node.attribute_value("config", true) },
|
||||
_config_triggers { node.attribute_value("config_triggers", false) },
|
||||
_bytes { node.attribute_value("bytes", true) },
|
||||
_stats { node.attribute_value("stats", true) },
|
||||
_link_state { node.attribute_value("link_state", false) },
|
||||
_link_state_triggers { node.attribute_value("link_state_triggers", false) },
|
||||
_quota { node.attribute_value("quota", true) },
|
||||
_shared_quota { shared_quota },
|
||||
_pd { pd },
|
||||
_reporter { reporter },
|
||||
_domains { domains },
|
||||
_timeout { timer, *this, &Report::_handle_report_timeout,
|
||||
read_sec_attr(node, "interval_sec", 5) }
|
||||
{
|
||||
_reporter.enabled(true);
|
||||
}
|
||||
@ -86,3 +88,11 @@ void Net::Report::handle_config()
|
||||
|
||||
_report();
|
||||
}
|
||||
|
||||
void Net::Report::handle_link_state()
|
||||
{
|
||||
if (!_link_state_triggers) {
|
||||
return; }
|
||||
|
||||
_report();
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ class Net::Report
|
||||
bool const _config_triggers;
|
||||
bool const _bytes;
|
||||
bool const _stats;
|
||||
bool const _link_state;
|
||||
bool const _link_state_triggers;
|
||||
bool const _quota;
|
||||
Quota const &_shared_quota;
|
||||
Genode::Pd_session &_pd;
|
||||
@ -73,14 +75,18 @@ class Net::Report
|
||||
|
||||
void handle_config();
|
||||
|
||||
void handle_link_state();
|
||||
|
||||
|
||||
/***************
|
||||
** Accessors **
|
||||
***************/
|
||||
|
||||
bool config() const { return _config; }
|
||||
bool bytes() const { return _bytes; }
|
||||
bool stats() const { return _stats; }
|
||||
bool config() const { return _config; }
|
||||
bool bytes() const { return _bytes; }
|
||||
bool stats() const { return _stats; }
|
||||
bool link_state() const { return _link_state; }
|
||||
bool link_state_triggers() const { return _link_state_triggers; }
|
||||
};
|
||||
|
||||
#endif /* _REPORT_H_ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user