nic_router: attribute report.config_triggers

This commit is contained in:
Martin Stein 2018-05-24 20:00:53 +02:00 committed by Christian Helmuth
parent c32c584f65
commit 44d97986a2
5 changed files with 39 additions and 12 deletions

View File

@ -435,22 +435,24 @@ However, there are still some differences that are visible to the user:
Configuring reporting functionality
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The NIC router can be configured to periodically send reports.
The NIC router can be configured to send reports about its state.
Configuration example (shows default values of attributes):
<config>
<report interval_sec="5" bytes="yes" config="yes">
<report interval_sec="5" bytes="yes" config="yes" config_triggers="no">
</config>
If the 'report' tag is not available, no reports are send.
The attributes of the 'report' tag:
'bytes' : Boolean : Whether to report sent bytes and received bytes per
domain
'config' : Boolean : Whether to report ipv4 interface and gateway per
domain
'interval_sec' : 1..3600 : Interval of sending reports in seconds
'bytes' : Boolean : Whether to report sent bytes and received bytes
per domain
'config' : Boolean : Whether to report IPv4 interface and gateway per
domain
'config_triggers' : Boolean : Wether to force a report each time the IPv4
config changes
'interval_sec' : 1..3600 : Interval of sending reports in seconds
Verbosity

View File

@ -96,9 +96,10 @@
<xs:element name="report">
<xs:complexType>
<xs:attribute name="config" type="Boolean" />
<xs:attribute name="bytes" 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="interval_sec" type="Seconds" />
</xs:complexType>
</xs:element><!-- report -->

View File

@ -94,6 +94,9 @@ void Domain::ip_config(Ipv4_config const &new_ip_config)
interface.attach_to_domain_finish();
});
}
/* force report if configured */
try { _config.report().handle_config(); }
catch (Pointer<Report>::Invalid) { }
}

View File

@ -26,7 +26,8 @@ Net::Report::Report(Xml_node const node,
Reporter &reporter)
:
_config(node.attribute_value("config", true)),
_bytes (node.attribute_value("bytes", true)),
_config_triggers(node.attribute_value("config_triggers", false)),
_bytes(node.attribute_value("bytes", true)),
_reporter(reporter),
_domains(domains),
_timeout(timer, *this, &Report::_handle_report_timeout,
@ -36,7 +37,7 @@ Net::Report::Report(Xml_node const node,
}
void Net::Report::_handle_report_timeout(Duration)
void Net::Report::_report()
{
try {
Reporter::Xml_generator xml(_reporter, [&] () {
@ -48,3 +49,18 @@ void Net::Report::_handle_report_timeout(Duration)
Genode::warning("Failed to generate report");
}
}
void Net::Report::_handle_report_timeout(Duration)
{
_report();
}
void Net::Report::handle_config()
{
if (!_config_triggers) {
return; }
_report();
}

View File

@ -36,6 +36,7 @@ class Net::Report
private:
bool const _config;
bool const _config_triggers;
bool const _bytes;
Genode::Reporter &_reporter;
Domain_tree &_domains;
@ -43,6 +44,8 @@ class Net::Report
void _handle_report_timeout(Genode::Duration);
void _report();
public:
Report(Genode::Xml_node const node,
@ -50,6 +53,8 @@ class Net::Report
Domain_tree &domains,
Genode::Reporter &reporter);
void handle_config();
/***************
** Accessors **