From 17c8dc93819001dc6088add5ae5ae889b12885ee Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Sun, 10 Jul 2016 22:24:04 +0100 Subject: [PATCH] MacCache.AddForced needs to return conflicting peer otherwise NetworkRouter.handleForwardedPacket fails to clear out the now invalid flows. --- router/mac_cache.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/router/mac_cache.go b/router/mac_cache.go index 31510c6e9a..6d4dd39ee4 100644 --- a/router/mac_cache.go +++ b/router/mac_cache.go @@ -51,11 +51,13 @@ func (cache *MacCache) add(mac net.HardwareAddr, peer *mesh.Peer, force bool) (b return true, nil } + var conflictPeer *mesh.Peer + if entry.peer != peer { + conflictPeer = entry.peer if !force { - return false, entry.peer + return false, conflictPeer } - entry.peer = peer } @@ -63,7 +65,7 @@ func (cache *MacCache) add(mac net.HardwareAddr, peer *mesh.Peer, force bool) (b entry.lastSeen = now } - return false, nil + return false, conflictPeer } func (cache *MacCache) Add(mac net.HardwareAddr, peer *mesh.Peer) (bool, *mesh.Peer) {