From 7c6cd6b9a3c8200e8da0ae26f76f6666c5405da1 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 24 Oct 2017 20:19:17 +0000 Subject: [PATCH] Dump malformed ingress packets at DEBUG log level. --- src/iface/ethernet.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/iface/ethernet.rs b/src/iface/ethernet.rs index 97681acd..91ac2ea6 100644 --- a/src/iface/ethernet.rs +++ b/src/iface/ethernet.rs @@ -175,6 +175,17 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { Ok(response) => response, Err(err) => { net_debug!("cannot process ingress packet: {}", err); + + if net_log_enabled!(debug) { + match EthernetFrame::new_checked(frame.as_ref()) { + Err(_) => { + net_debug!("packet dump follows:\n{:?}", frame.as_ref()); + } + Ok(frame) => { + net_debug!("packet dump follows:\n{}", frame); + } + } + } return Err(err) } }; @@ -274,7 +285,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { &source_hardware_addr); } else { // Discard packets with non-unicast source addresses. - net_debug!("non-unicast source in {}", arp_repr); + net_debug!("non-unicast source address"); return Err(Error::Malformed) } @@ -305,7 +316,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> { if !ipv4_repr.src_addr.is_unicast() { // Discard packets with non-unicast source addresses. - net_debug!("non-unicast source in {}", ipv4_repr); + net_debug!("non-unicast source address"); return Err(Error::Malformed) }