Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VXLAN race condition #2260

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static checks complained about this const being unused.

/shrug

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