nic_router: domain-state-verbose flag

When this flag is set in the config tag, the NIC router will print a
short information to the log for each general state change of a domain.
This includes currently the IP-configuration state and the number of
connected NIC sessions. This a useful addition as the normal verbose
flag's purpose is a very deep insight into almost every activity in the
router, which is cool for debugging sophisticated problems but normally
floods the log and therefore discards this option for, e.g., desktop
systems. In such systems, the new verbosity is pretty discreet but
already gives a good hint on why packets may get dropped by the router
although the routing rules are correct.

Issue #2534
This commit is contained in:
Martin Stein 2017-12-04 19:38:39 +01:00 committed by Christian Helmuth
parent fc7999a62a
commit c3853494c8
6 changed files with 20 additions and 10 deletions

View File

@ -84,6 +84,7 @@ append config {
<resource name="RAM" quantum="10M"/>
<provides><service name="Nic"/></provides>
<config verbose="no"
verbose_domain_state="yes"
dhcp_discover_timeout_sec="3"
dhcp_request_timeout_sec="3"
dhcp_offer_timeout_sec="3"

View File

@ -140,6 +140,7 @@
</xs:choice>
<xs:attribute name="verbose" type="Boolean" />
<xs:attribute name="verbose_domain_state" type="Boolean" />
<xs:attribute name="dhcp_discover_timeout_sec" type="Seconds" />
<xs:attribute name="dhcp_request_timeout_sec" type="Seconds" />
<xs:attribute name="dhcp_offer_timeout_sec" type="Seconds" />

View File

@ -49,6 +49,7 @@ Configuration::Configuration(Xml_node const node,
Allocator &alloc)
:
_alloc(alloc), _verbose(node.attribute_value("verbose", false)),
_verbose_domain_state(node.attribute_value("verbose_domain_state", false)),
_dhcp_discover_timeout(read_sec_attr(node, "dhcp_discover_timeout_sec", DEFAULT_DHCP_DISCOVER_TIMEOUT_SEC)),
_dhcp_request_timeout (read_sec_attr(node, "dhcp_request_timeout_sec", DEFAULT_DHCP_REQUEST_TIMEOUT_SEC )),
_dhcp_offer_timeout (read_sec_attr(node, "dhcp_offer_timeout_sec", DEFAULT_DHCP_OFFER_TIMEOUT_SEC )),

View File

@ -31,6 +31,7 @@ class Net::Configuration
Genode::Allocator &_alloc;
bool const _verbose;
bool const _verbose_domain_state;
Genode::Microseconds const _dhcp_discover_timeout;
Genode::Microseconds const _dhcp_request_timeout;
Genode::Microseconds const _dhcp_offer_timeout;
@ -57,6 +58,7 @@ class Net::Configuration
***************/
bool verbose() const { return _verbose; }
bool verbose_domain_state() const { return _verbose_domain_state; }
Genode::Microseconds dhcp_discover_timeout() const { return _dhcp_discover_timeout; }
Genode::Microseconds dhcp_request_timeout() const { return _dhcp_request_timeout; }
Genode::Microseconds dhcp_offer_timeout() const { return _dhcp_offer_timeout; }

View File

@ -118,6 +118,9 @@ Domain::Domain(Configuration &config, Xml_node const node, Allocator &alloc)
error("Domain cannot act as DHCP client and server at once");
throw Invalid();
}
if (_config.verbose_domain_state()) {
log("\033[32m(", *this, ")\033[0m NIC sessions: 0");
}
_ip_config_changed();
}
@ -125,12 +128,16 @@ Domain::Domain(Configuration &config, Xml_node const node, Allocator &alloc)
void Domain::_ip_config_changed()
{
if (!ip_config().valid) {
if (_config.verbose_domain_state()) {
log("\033[32m(", *this, ")\033[0m IP config: none");
}
return;
}
if (_config.verbose()) {
log("New IP config at domain \"", *this, "\":"
if (_config.verbose_domain_state()) {
log("\033[32m(", *this, ")\033[0m IP config:"
" interface ", ip_config().interface,
" gateway ", ip_config().gateway);
", gateway ", ip_config().gateway);
}
/* try to find configuration for DHCP server role */
try {

View File

@ -907,11 +907,8 @@ Interface::Interface(Entrypoint &ep,
_router_mac(router_mac), _mac(mac), _timer(timer), _alloc(alloc),
_domain(domain)
{
if (_config().verbose()) {
log("Interface connected ", *this);
log(" MAC ", _mac);
log(" Router identity: MAC ", _router_mac, " IP ",
_router_ip(), "/", _ip_config().interface.prefix);
if (_config().verbose_domain_state()) {
log("\033[32m(", _domain, ")\033[0m NIC sessions: 1");
}
_domain.interface().set(*this);
}
@ -946,8 +943,9 @@ void Interface::_cancel_arp_waiting(Arp_waiter &waiter)
Interface::~Interface()
{
_domain.interface().unset();
if (_config().verbose()) {
log("Interface disconnected ", *this); }
if (_config().verbose_domain_state()) {
log("\033[32m(", _domain, ")\033[0m NIC sessions: 0");
}
/* destroy ARP waiters */
while (_own_arp_waiters.first()) {