From 846bc54c0e11b1fd28be2aba7e3f9dc3ed599929 Mon Sep 17 00:00:00 2001 From: Martynas Pumputis Date: Fri, 25 Nov 2016 18:32:43 +0000 Subject: [PATCH] Add sanity check to detect when receiving own packets --- router/network_router.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/router/network_router.go b/router/network_router.go index e9a85e16a3..a7c83dba82 100644 --- a/router/network_router.go +++ b/router/network_router.go @@ -124,6 +124,13 @@ func (router *NetworkRouter) handleCapturedPacket(key PacketKey) FlowOp { } func (router *NetworkRouter) handleForwardedPacket(key ForwardPacketKey) FlowOp { + srcMac := net.HardwareAddr(key.SrcMAC[:]) + dstMac := net.HardwareAddr(key.DstMAC[:]) + + if key.SrcPeer == router.Ourself.Peer { + log.Warn("Received own packet to peer ", key.DstPeer, " from MAC (", srcMac, ") to (", dstMac, ")") + } + if key.DstPeer != router.Ourself.Peer { // it's not for us, we're just relaying it router.PacketLogging.LogForwardPacket("Relaying", key) @@ -134,9 +141,6 @@ func (router *NetworkRouter) handleForwardedPacket(key ForwardPacketKey) FlowOp // (because the DstPeer on a forwarded broadcast packet is // always set to the peer being forwarded to) - srcMac := net.HardwareAddr(key.SrcMAC[:]) - dstMac := net.HardwareAddr(key.DstMAC[:]) - switch newSrcMac, conflictPeer := router.Macs.AddForced(srcMac, key.SrcPeer); { case newSrcMac: log.Print("Discovered remote MAC ", srcMac, " at ", key.SrcPeer)