-
Notifications
You must be signed in to change notification settings - Fork 882
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
Ensure purging neighbor cache for stale deletes #1433
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,14 +168,14 @@ func (d *driver) peerDbAdd(nid, eid string, peerIP net.IP, peerIPMask net.IPMask | |
} | ||
|
||
func (d *driver) peerDbDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMask, | ||
peerMac net.HardwareAddr, vtep net.IP) bool { | ||
peerMac net.HardwareAddr, vtep net.IP) peerEntry { | ||
peerDbWg.Wait() | ||
|
||
d.peerDb.Lock() | ||
pMap, ok := d.peerDb.mp[nid] | ||
if !ok { | ||
d.peerDb.Unlock() | ||
return false | ||
return peerEntry{} | ||
} | ||
d.peerDb.Unlock() | ||
|
||
|
@@ -186,19 +186,20 @@ func (d *driver) peerDbDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPM | |
|
||
pMap.Lock() | ||
|
||
if pEntry, ok := pMap.mp[pKey.String()]; ok { | ||
pEntry, ok := pMap.mp[pKey.String()] | ||
if ok { | ||
// Mismatched endpoint ID(possibly outdated). Do not | ||
// delete peerdb | ||
if pEntry.eid != eid { | ||
pMap.Unlock() | ||
return false | ||
return pEntry | ||
} | ||
} | ||
|
||
delete(pMap.mp, pKey.String()) | ||
pMap.Unlock() | ||
|
||
return true | ||
return pEntry | ||
} | ||
|
||
func (d *driver) peerDbUpdateSandbox(nid string) { | ||
|
@@ -312,10 +313,9 @@ func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMas | |
return err | ||
} | ||
|
||
var pEntry peerEntry | ||
if updateDb { | ||
if !d.peerDbDelete(nid, eid, peerIP, peerIPMask, peerMac, vtep) { | ||
return nil | ||
} | ||
pEntry = d.peerDbDelete(nid, eid, peerIP, peerIPMask, peerMac, vtep) | ||
} | ||
|
||
n := d.network(nid) | ||
|
@@ -328,14 +328,24 @@ func (d *driver) peerDelete(nid, eid string, peerIP net.IP, peerIPMask net.IPMas | |
return nil | ||
} | ||
|
||
// Delete fdb entry to the bridge for the peer mac | ||
if err := sbox.DeleteNeighbor(vtep, peerMac); err != nil { | ||
return fmt.Errorf("could not delete fdb entry into the sandbox: %v", err) | ||
// Delete fdb entry to the bridge for the peer mac only if the | ||
// entry existed in local peerdb. If it is a stale delete | ||
// request, still call DeleteNeighbor but only to cleanup any | ||
// leftover sandbox neighbor cache and not actually delete the | ||
// kernel state. | ||
if (eid == pEntry.eid && vtep.Equal(pEntry.vtep)) || | ||
(eid != pEntry.eid && !vtep.Equal(pEntry.vtep)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As a curiosity, this could be compacted to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That will be clever but it will be awfully lot difficult to decipher the intent. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though the logic in the PR may be a little hard to follow it is absolutely necessary because even if endpoint Ids did not match we need to remove state in sandbox neighbor case (look for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. yeah, I see why we can't bail out on a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No it should not. If we do we will delete the vtep for the current valid entry which is specifically why we are doing the eid match to avoid a stale(out of order) delete from actually deleting anything. About the only thing that a stale delete should do is remove a stale sandbox neighbor cache. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I was thinking of the case where the task gets rescheduled and placed on the same node. But in that case the neighbor entry is actually correct and not stale. LGTM. Good that you caught this in the testing. It would have been impossible to debug in live setups. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
if err := sbox.DeleteNeighbor(vtep, peerMac, | ||
eid == pEntry.eid && vtep.Equal(pEntry.vtep)); err != nil { | ||
return fmt.Errorf("could not delete fdb entry into the sandbox: %v", err) | ||
} | ||
} | ||
|
||
// Delete neighbor entry for the peer IP | ||
if err := sbox.DeleteNeighbor(peerIP, peerMac); err != nil { | ||
return fmt.Errorf("could not delete neighbor entry into the sandbox: %v", err) | ||
if eid == pEntry.eid { | ||
if err := sbox.DeleteNeighbor(peerIP, peerMac, true); err != nil { | ||
return fmt.Errorf("could not delete neighbor entry into the sandbox: %v", err) | ||
} | ||
} | ||
|
||
if err := d.checkEncryption(nid, vtep, 0, false, false); err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrjana The key for
peerEntry
in peerNetworkMap.mp is just the peer IP & macIn the case of out of order delete we will end up deleting the entry for the newly created peer entry. I think we need eid as part of the key because it will change in this case where we get an add before the delete of the old ep ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We won't delete it incorrectly. We do check for eid match below and that is needed in the caller as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, sorry... its right below.