Skip to content

Commit

Permalink
Merge pull request #2260 from caseydavenport/casey-vxlan
Browse files Browse the repository at this point in the history
Fix VXLAN race condition
  • Loading branch information
caseydavenport authored Apr 16, 2020
2 parents aa0a22d + c55f425 commit 194a04f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 2 additions & 3 deletions bpf/ut/bpf_prog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,8 @@ func init() {

// Constants that are shared with the UT binaries that we build.
const (
natTunnelMTU = uint16(700)
ethernetHeaderSize = 14
testVxlanPort = uint16(5665)
natTunnelMTU = uint16(700)
testVxlanPort = uint16(5665)
)

var (
Expand Down
11 changes: 7 additions & 4 deletions calc/vxlan_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ func (c *VXLANResolver) OnResourceUpdate(update api.Update) (_ bool) {
logCxt := logrus.WithField("node", nodeName).WithField("update", update)
logCxt.Debug("OnResourceUpdate triggered")
if update.Value != nil && update.Value.(*apiv3.Node).Spec.BGP != nil {
// Calculate the pending and sent sets before adding 'node' to nodeNameToNode.
pendingSet, sentSet := c.routeSets()

node := update.Value.(*apiv3.Node)
bgp := node.Spec.BGP
c.nodeNameToNode[nodeName] = node
Expand All @@ -192,7 +195,7 @@ func (c *VXLANResolver) OnResourceUpdate(update api.Update) (_ bool) {
return
}

c.onNodeIPUpdate(nodeName, ipv4.String())
c.onNodeIPUpdate(nodeName, ipv4.String(), pendingSet, sentSet)
} else {
delete(c.nodeNameToNode, nodeName)
c.onRemoveNode(nodeName)
Expand All @@ -210,20 +213,20 @@ func (c *VXLANResolver) OnHostIPUpdate(update api.Update) (_ bool) {
logrus.WithField("node", nodeName).Debug("OnHostIPUpdate triggered")

if update.Value != nil {
c.onNodeIPUpdate(nodeName, update.Value.(*cnet.IP).String())
pendingSet, sentSet := c.routeSets()
c.onNodeIPUpdate(nodeName, update.Value.(*cnet.IP).String(), pendingSet, sentSet)
} else {
c.onRemoveNode(nodeName)
}
return
}

func (c *VXLANResolver) onNodeIPUpdate(nodeName string, newIP string) {
func (c *VXLANResolver) onNodeIPUpdate(nodeName string, newIP string, pendingSet set.Set, sentSet set.Set) {
logCxt := logrus.WithField("node", nodeName)
// Host IP updated or added. If it was added, we should check to see if we're ready
// to send a VTEP and associated routes. If we already knew about this one, we need to
// see if it has changed. If it has, we should remove and reprogram the VTEP and routes.
currIP := c.nodeNameToIPAddr[nodeName]
pendingSet, sentSet := c.routeSets()
logCxt = logCxt.WithFields(logrus.Fields{"newIP": newIP, "currIP": currIP})
if c.vtepSent(nodeName) {
if currIP == newIP {
Expand Down

0 comments on commit 194a04f

Please sign in to comment.