Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.
Merged
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
23 changes: 19 additions & 4 deletions drivers/virtualbox/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,15 +363,30 @@ func listHostInterfaces(hif HostInterfaces, excludeNets map[string]*hostOnlyNetw
if err != nil {
return nil, err
}

// Check if an address of the interface is in the list of excluded addresses
ifaceExcluded := false
for _, a := range addrs {
switch ipnet := a.(type) {
case *net.IPNet:
_, hostOnly := excludeNets[ipnet.String()]
if !hostOnly && iface.Flags&net.FlagUp != 0 && iface.Flags&net.FlagLoopback == 0 {
m[ipnet.String()] = ipnet
_, excluded := excludeNets[ipnet.String()]
if excluded {
ifaceExcluded = true
break
}
default:
}
}

// If excluded, or not up, or a loopback interface, skip the interface
if ifaceExcluded || iface.Flags&net.FlagUp == 0 || iface.Flags&net.FlagLoopback != 0 {
continue
}

// This is a host interface, so add all its addresses to the map
for _, a := range addrs {
switch ipnet := a.(type) {
case *net.IPNet:
m[ipnet.String()] = ipnet
}
}
}
Expand Down