datapath: Few minor improvements to DevicesController #28887
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pulls out couple improvemenst from #28712 to its own PR:
statedb: Add NewPrivateRWTableCell
: Add ability for a constructor to provide theTable[T]
and thus allow populating a table before readers can access it.datapath: Ensure device and route tables are populated before readers
: Make sure DevicesController has initially populated the devices table before anything reads it. Note that this was not a bug earlier as we didn't useTable[*Device]
directly but rather viaoption.Config.GetDevices
which came fromDeviceManager
wrapper aroundDevicesController
and that did enforce the ordering.datapath/devices: Flush routes on device delete
: Fix cleaning of route entries when device is deleted. Surprisingly Linux doesn't send netlink notifications for each deleted route when link is removed. This was not a big issue yet as routes were only used to figure out if a 'veth' device should be selected based on if it had a default route or not.datapath/devices: Avoid adding duplicate address
: As DevicesController needs to populate the devices table before readers see it, it needs to do a Subscribe and List. This leads to a race where one might see an address both in listing and as an update. Fix this by not adding the address twice. (I did also think about using asets.Set
for addresses, but I prefer that they're in a slice and in a stable order. Happy to reconsider though).