Explain in comments how popSRIOVPCIAddress works
@@ -519,12 +519,21 @@ func filterAddress(addrs []string, addr string) []string {
}
func reserveAddress(addrsMap map[string][]string, addr string) {
+ // Sometimes the same address is available to multiple networks,
+ // specifically when two networks refer to the same resourceName. In this
+ // case, we should make sure that a reserved address is removed from *all*
+ // per-network lists of available devices, to avoid configuring the same
+ // device ID for multiple interfaces.
for networkName, addrs := range addrsMap {
addrsMap[networkName] = filterAddress(addrs, addr)
}
return
}
+// Get the next PCI address available to a particular network. The function
+// makes sure that the allocated address is not allocated to next callers,
+// whether they request an address for the same network or another network that
+// is backed by the same resourceName.
func popSRIOVPCIAddress(networkName string, addrsMap map[string][]string) (string, map[string][]string, error) {
if len(addrsMap[networkName]) > 0 {
addr := addrsMap[networkName][0]
