nic_router: fix interface-local quota reporting

The router used to ignore the value of the <report quota=".."/> attribute when
it came to determining whether an interface's report is empty or not.
Therefore, merely configuring <report quota="yes"/> didn't cause interfaces
(and their quota) to show up in the report. Instead, interface quota was
reported as side effect of <report stats="yes"/>. The commit fixes this
inconsistency with the README.
This commit is contained in:
Martin Stein 2024-06-06 15:35:11 +02:00 committed by Norman Feske
parent 09b3fa389d
commit 84bbde2879
2 changed files with 8 additions and 4 deletions

View File

@ -2280,12 +2280,13 @@ Interface::~Interface()
bool Interface::report_empty(Report const &report_cfg) const bool Interface::report_empty(Report const &report_cfg) const
{ {
bool quota = report_cfg.quota() && !_policy.report_empty();
bool stats = report_cfg.stats() && ( bool stats = report_cfg.stats() && (
!_policy.report_empty() || !_tcp_stats.report_empty() || !_udp_stats.report_empty() || !_tcp_stats.report_empty() || !_udp_stats.report_empty() || !_icmp_stats.report_empty() ||
!_icmp_stats.report_empty() || !_arp_stats.report_empty() || _dhcp_stats.report_empty()); !_arp_stats.report_empty() || _dhcp_stats.report_empty());
bool lnk_state = report_cfg.link_state(); bool lnk_state = report_cfg.link_state();
bool fragm_ip = report_cfg.dropped_fragm_ipv4() && _dropped_fragm_ipv4; bool fragm_ip = report_cfg.dropped_fragm_ipv4() && _dropped_fragm_ipv4;
return !lnk_state && !stats && !fragm_ip; return !quota && !lnk_state && !stats && !fragm_ip;
} }
@ -2295,8 +2296,10 @@ void Interface::report(Genode::Xml_generator &xml, Report const &report_cfg) con
if (report_cfg.link_state()) if (report_cfg.link_state())
xml.attribute("link_state", link_state()); xml.attribute("link_state", link_state());
if (report_cfg.stats()) { if (report_cfg.quota())
_policy.report(xml); _policy.report(xml);
if (report_cfg.stats()) {
if (!_tcp_stats.report_empty()) xml.node("tcp-links", [&] { _tcp_stats.report(xml); }); if (!_tcp_stats.report_empty()) xml.node("tcp-links", [&] { _tcp_stats.report(xml); });
if (!_udp_stats.report_empty()) xml.node("udp-links", [&] { _udp_stats.report(xml); }); if (!_udp_stats.report_empty()) xml.node("udp-links", [&] { _udp_stats.report(xml); });
if (!_icmp_stats.report_empty()) xml.node("icmp-links", [&] { _icmp_stats.report(xml); }); if (!_icmp_stats.report_empty()) xml.node("icmp-links", [&] { _icmp_stats.report(xml); });

View File

@ -88,6 +88,7 @@ class Net::Report
bool config() const { return _config; } bool config() const { return _config; }
bool bytes() const { return _bytes; } bool bytes() const { return _bytes; }
bool stats() const { return _stats; } bool stats() const { return _stats; }
bool quota() const { return _quota; }
bool dropped_fragm_ipv4() const { return _dropped_fragm_ipv4; } bool dropped_fragm_ipv4() const { return _dropped_fragm_ipv4; }
bool link_state() const { return _link_state; } bool link_state() const { return _link_state; }
bool link_state_triggers() const { return _link_state_triggers; } bool link_state_triggers() const { return _link_state_triggers; }