nic_router: verbose_packet_drop attribute

The log messages covered by verbose_packet_drop were previously
configured by the verbose attribute. This isn't the case anymore. Now,
you can configure them as follows:

! <config verbose_packet_drop="no" ... >
!     <domain verbose_packet_drop="no" ... />
! <config/>

The new attribute determines whether to log each packet drop and the
rational behind it. The <config> value affects all domains without a
<domain> local value.

Issue #2857
This commit is contained in:
Martin Stein 2018-06-19 16:20:47 +02:00 committed by Norman Feske
parent e139c52262
commit 2733d3fea5
8 changed files with 57 additions and 35 deletions

View File

@ -481,6 +481,13 @@ Whether to log most important protocol header fields of each packet that is
received or sent (ETH, IPv4, ARP, UDP, TCP, DHCP, ICMP). The <config> value received or sent (ETH, IPv4, ARP, UDP, TCP, DHCP, ICMP). The <config> value
affects all domains without a <domain> local value. affects all domains without a <domain> local value.
! <config verbose_packet_drop="no" ... >
! <domain verbose_packet_drop="no" ... />
! <config/>
Whether to log each packet drop and the rational behind it. The <config> value
affects all domains without a <domain> local value.
! <config verbose_domain_state="no"> ! <config verbose_domain_state="no">
Whether to log most important changes in the state of a domain (number of NIC Whether to log most important changes in the state of a domain (number of NIC

View File

@ -155,6 +155,7 @@
<xs:attribute name="interface" type="Ipv4_address_prefix" /> <xs:attribute name="interface" type="Ipv4_address_prefix" />
<xs:attribute name="gateway" type="Ipv4_address" /> <xs:attribute name="gateway" type="Ipv4_address" />
<xs:attribute name="verbose_packets" type="Boolean" /> <xs:attribute name="verbose_packets" type="Boolean" />
<xs:attribute name="verbose_packet_drop" type="Boolean" />
<xs:attribute name="label" type="Session_label" /> <xs:attribute name="label" type="Session_label" />
<xs:attribute name="icmp_echo_server" type="Boolean" /> <xs:attribute name="icmp_echo_server" type="Boolean" />
</xs:complexType> </xs:complexType>
@ -163,6 +164,7 @@
</xs:choice> </xs:choice>
<xs:attribute name="verbose" type="Boolean" /> <xs:attribute name="verbose" type="Boolean" />
<xs:attribute name="verbose_packets" type="Boolean" /> <xs:attribute name="verbose_packets" type="Boolean" />
<xs:attribute name="verbose_packet_drop" type="Boolean" />
<xs:attribute name="verbose_domain_state" type="Boolean" /> <xs:attribute name="verbose_domain_state" type="Boolean" />
<xs:attribute name="dhcp_discover_timeout_sec" type="Seconds" /> <xs:attribute name="dhcp_discover_timeout_sec" type="Seconds" />
<xs:attribute name="dhcp_request_timeout_sec" type="Seconds" /> <xs:attribute name="dhcp_request_timeout_sec" type="Seconds" />

View File

@ -67,6 +67,7 @@ Configuration::Configuration(Env &env,
_alloc(alloc), _alloc(alloc),
_verbose (node.attribute_value("verbose", false)), _verbose (node.attribute_value("verbose", false)),
_verbose_packets (node.attribute_value("verbose_packets", false)), _verbose_packets (node.attribute_value("verbose_packets", false)),
_verbose_packet_drop (node.attribute_value("verbose_packet_drop", false)),
_verbose_domain_state (node.attribute_value("verbose_domain_state", false)), _verbose_domain_state (node.attribute_value("verbose_domain_state", false)),
_icmp_echo_server (node.attribute_value("icmp_echo_server", true)), _icmp_echo_server (node.attribute_value("icmp_echo_server", true)),
_dhcp_discover_timeout(read_sec_attr(node, "dhcp_discover_timeout_sec", DEFAULT_DHCP_DISCOVER_TIMEOUT_SEC)), _dhcp_discover_timeout(read_sec_attr(node, "dhcp_discover_timeout_sec", DEFAULT_DHCP_DISCOVER_TIMEOUT_SEC)),

View File

@ -36,6 +36,7 @@ class Net::Configuration
Genode::Allocator &_alloc; Genode::Allocator &_alloc;
bool const _verbose { false }; bool const _verbose { false };
bool const _verbose_packets { false }; bool const _verbose_packets { false };
bool const _verbose_packet_drop { false };
bool const _verbose_domain_state { false }; bool const _verbose_domain_state { false };
bool const _icmp_echo_server { true }; bool const _icmp_echo_server { true };
Genode::Microseconds const _dhcp_discover_timeout { DEFAULT_DHCP_DISCOVER_TIMEOUT_SEC }; Genode::Microseconds const _dhcp_discover_timeout { DEFAULT_DHCP_DISCOVER_TIMEOUT_SEC };
@ -87,6 +88,7 @@ class Net::Configuration
bool verbose() const { return _verbose; } bool verbose() const { return _verbose; }
bool verbose_packets() const { return _verbose_packets; } bool verbose_packets() const { return _verbose_packets; }
bool verbose_packet_drop() const { return _verbose_packet_drop; }
bool verbose_domain_state() const { return _verbose_domain_state; } bool verbose_domain_state() const { return _verbose_domain_state; }
bool icmp_echo_server() const { return _icmp_echo_server; } bool icmp_echo_server() const { return _icmp_echo_server; }
Genode::Microseconds dhcp_discover_timeout() const { return _dhcp_discover_timeout; } Genode::Microseconds dhcp_discover_timeout() const { return _dhcp_discover_timeout; }

View File

@ -205,6 +205,8 @@ Domain::Domain(Configuration &config, Xml_node const node, Allocator &alloc)
Ipv4_address()), Ipv4_address()),
_verbose_packets(_node.attribute_value("verbose_packets", _verbose_packets(_node.attribute_value("verbose_packets",
_config.verbose_packets())), _config.verbose_packets())),
_verbose_packet_drop(_node.attribute_value("verbose_packet_drop",
_config.verbose_packet_drop())),
_icmp_echo_server(_node.attribute_value("icmp_echo_server", _icmp_echo_server(_node.attribute_value("icmp_echo_server",
_config.icmp_echo_server())), _config.icmp_echo_server())),
_label(_node.attribute_value("label", String<160>()).string()) _label(_node.attribute_value("label", String<160>()).string())

View File

@ -93,6 +93,7 @@ class Net::Domain : public Domain_base,
Genode::size_t _tx_bytes { 0 }; Genode::size_t _tx_bytes { 0 };
Genode::size_t _rx_bytes { 0 }; Genode::size_t _rx_bytes { 0 };
bool const _verbose_packets; bool const _verbose_packets;
bool const _verbose_packet_drop;
bool const _icmp_echo_server; bool const _icmp_echo_server;
Genode::Session_label const _label; Genode::Session_label const _label;
@ -168,6 +169,7 @@ class Net::Domain : public Domain_base,
***************/ ***************/
bool verbose_packets() const { return _verbose_packets; } bool verbose_packets() const { return _verbose_packets; }
bool verbose_packet_drop() const { return _verbose_packet_drop; }
bool icmp_echo_server() const { return _icmp_echo_server; } bool icmp_echo_server() const { return _icmp_echo_server; }
Genode::Session_label const &label() const { return _label; } Genode::Session_label const &label() const { return _label; }
Ipv4_config const &ip_config() const { return *_ip_config; } Ipv4_config const &ip_config() const { return *_ip_config; }

View File

@ -1177,7 +1177,7 @@ void Interface::_handle_arp_reply(Ethernet_frame &eth,
Arp_waiter &waiter = *waiter_le->object(); Arp_waiter &waiter = *waiter_le->object();
waiter_le = waiter_le->next(); waiter_le = waiter_le->next();
if (ip != waiter.ip()) { continue; } if (ip != waiter.ip()) { continue; }
waiter.src()._continue_handle_eth(waiter.packet()); waiter.src()._continue_handle_eth(local_domain, waiter.packet());
destroy(waiter.src()._alloc, &waiter); destroy(waiter.src()._alloc, &waiter);
} }
} }
@ -1284,13 +1284,14 @@ void Interface::_ready_to_submit()
} }
void Interface::_continue_handle_eth(Packet_descriptor const &pkt) void Interface::_continue_handle_eth(Domain const &domain,
Packet_descriptor const &pkt)
{ {
Size_guard size_guard(pkt.size()); Size_guard size_guard(pkt.size());
try { _handle_eth(_sink.packet_content(pkt), size_guard, pkt); } try { _handle_eth(_sink.packet_content(pkt), size_guard, pkt); }
catch (Packet_postponed) { catch (Packet_postponed) {
if (_config().verbose()) { if (domain.verbose_packet_drop()) {
log("[", _domain(), "] drop packet (handling postponed twice)"); } log("[", domain, "] drop packet (handling postponed twice)"); }
} }
_ack_packet(pkt); _ack_packet(pkt);
} }
@ -1381,7 +1382,7 @@ void Interface::_handle_eth(void *const eth_base,
} }
} }
catch (Drop_packet exception) { catch (Drop_packet exception) {
if (_config().verbose()) { if (local_domain.verbose_packet_drop()) {
log("[", local_domain, "] drop packet (", log("[", local_domain, "] drop packet (",
exception.reason, ")"); exception.reason, ")");
} }
@ -1799,9 +1800,13 @@ void Interface::_ack_packet(Packet_descriptor const &pkt)
void Interface::cancel_arp_waiting(Arp_waiter &waiter) void Interface::cancel_arp_waiting(Arp_waiter &waiter)
{ {
if (_config().verbose()) { try {
try { log("[", _domain(), "] drop packet (ARP got cancelled)"); } Domain &domain = _domain();
if (domain.verbose_packet_drop()) {
log("[", domain, "] drop packet (ARP got cancelled)"); }
}
catch (Pointer<Domain>::Invalid) { catch (Pointer<Domain>::Invalid) {
if (_config().verbose_packet_drop()) {
log("[?] drop packet (ARP got cancelled)"); } log("[?] drop packet (ARP got cancelled)"); }
} }
_ack_packet(waiter.packet()); _ack_packet(waiter.packet());

View File

@ -239,7 +239,8 @@ class Net::Interface : private Interface_list::Element
Size_guard &size_guard, Size_guard &size_guard,
Ipv4_packet &ip); Ipv4_packet &ip);
void _continue_handle_eth(Packet_descriptor const &pkt); void _continue_handle_eth(Domain const &domain,
Packet_descriptor const &pkt);
Ipv4_address const &_router_ip() const; Ipv4_address const &_router_ip() const;