diff --git a/router/gossip.go b/router/gossip.go index df6ad30a..96f4abe8 100644 --- a/router/gossip.go +++ b/router/gossip.go @@ -269,6 +269,7 @@ func (c *GossipChannel) relayBroadcast(srcName PeerName, update GossipData) erro } func (c *GossipChannel) sendBroadcast(srcName PeerName, update GossipData) { + c.ourself.Router.Routes.EnsureRecalculated() nextHops := c.ourself.Router.Routes.BroadcastAll(srcName) if len(nextHops) == 0 { return diff --git a/router/local_peer.go b/router/local_peer.go index dfde0493..7346c594 100644 --- a/router/local_peer.go +++ b/router/local_peer.go @@ -241,14 +241,7 @@ func (peer *LocalPeer) handleDeleteConnection(conn Connection) { func (peer *LocalPeer) broadcastPeerUpdate(peers ...*Peer) { peer.Router.Routes.Recalculate() - // TODO We should just be invoking TopologyGossip.GossipBroadcast - // here, but route calculation is asynchronous and in this - // particular case would likely result in the broadcast not - // reaching all peers. So instead we slightly break the Gossip - // abstraction (hence the cast) and send a regular update. This is - // less efficient though since it will almost certainly reach - // peers more than once. - peer.Router.TopologyGossip.(*GossipChannel).Send(NewTopologyGossipData(peer.Router.Peers, append(peers, peer.Peer)...)) + peer.Router.TopologyGossip.GossipBroadcast(NewTopologyGossipData(peer.Router.Peers, append(peers, peer.Peer)...)) } func (peer *LocalPeer) checkConnectionLimit() error { diff --git a/router/protocol.go b/router/protocol.go index 9184512c..b9bb9f29 100644 --- a/router/protocol.go +++ b/router/protocol.go @@ -2,7 +2,7 @@ package router const ( Protocol = "weave" - ProtocolVersion = 14 + ProtocolVersion = 15 ) type ProtocolTag byte diff --git a/router/router.go b/router/router.go index 5ba48d7c..2eb9af36 100644 --- a/router/router.go +++ b/router/router.go @@ -378,7 +378,11 @@ func (router *Router) OnGossipUnicast(sender PeerName, msg []byte) error { } func (router *Router) OnGossipBroadcast(update []byte) (GossipData, error) { - return nil, fmt.Errorf("unexpected topology gossip broadcast: %v", update) + origUpdate, _, err := router.applyTopologyUpdate(update) + if err != nil || len(origUpdate) == 0 { + return nil, err + } + return &TopologyGossipData{peers: router.Peers, update: origUpdate}, nil } func (router *Router) Gossip() GossipData {