From 84bbde28792dd98e20f76f377739d002b13dea16 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 6 Jun 2024 15:35:11 +0200 Subject: [PATCH] nic_router: fix interface-local quota reporting The router used to ignore the value of the attribute when it came to determining whether an interface's report is empty or not. Therefore, merely configuring didn't cause interfaces (and their quota) to show up in the report. Instead, interface quota was reported as side effect of . The commit fixes this inconsistency with the README. --- repos/os/src/server/nic_router/interface.cc | 11 +++++++---- repos/os/src/server/nic_router/report.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/repos/os/src/server/nic_router/interface.cc b/repos/os/src/server/nic_router/interface.cc index e0af66dd76..4951e95ed3 100644 --- a/repos/os/src/server/nic_router/interface.cc +++ b/repos/os/src/server/nic_router/interface.cc @@ -2280,12 +2280,13 @@ Interface::~Interface() bool Interface::report_empty(Report const &report_cfg) const { + bool quota = report_cfg.quota() && !_policy.report_empty(); bool stats = report_cfg.stats() && ( - !_policy.report_empty() || !_tcp_stats.report_empty() || !_udp_stats.report_empty() || - !_icmp_stats.report_empty() || !_arp_stats.report_empty() || _dhcp_stats.report_empty()); + !_tcp_stats.report_empty() || !_udp_stats.report_empty() || !_icmp_stats.report_empty() || + !_arp_stats.report_empty() || _dhcp_stats.report_empty()); bool lnk_state = report_cfg.link_state(); 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()) xml.attribute("link_state", link_state()); - if (report_cfg.stats()) { + if (report_cfg.quota()) _policy.report(xml); + + if (report_cfg.stats()) { 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 (!_icmp_stats.report_empty()) xml.node("icmp-links", [&] { _icmp_stats.report(xml); }); diff --git a/repos/os/src/server/nic_router/report.h b/repos/os/src/server/nic_router/report.h index 8981c4bcb3..df88500907 100644 --- a/repos/os/src/server/nic_router/report.h +++ b/repos/os/src/server/nic_router/report.h @@ -88,6 +88,7 @@ class Net::Report bool config() const { return _config; } bool bytes() const { return _bytes; } bool stats() const { return _stats; } + bool quota() const { return _quota; } bool dropped_fragm_ipv4() const { return _dropped_fragm_ipv4; } bool link_state() const { return _link_state; } bool link_state_triggers() const { return _link_state_triggers; }