mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-28 03:20:11 +00:00
Preserve guest NICs when only filtered addresses are reported (#1319)
This commit is contained in:
parent
01f916dcb5
commit
3d214c80a7
2 changed files with 14 additions and 6 deletions
|
|
@ -565,6 +565,7 @@ func processGuestNetworkInterfaces(raw []proxmox.VMNetworkInterface) ([]string,
|
|||
for _, iface := range raw {
|
||||
ifaceName := strings.TrimSpace(iface.Name)
|
||||
mac := strings.TrimSpace(iface.HardwareAddr)
|
||||
hadRawAddresses := len(iface.IPAddresses) > 0
|
||||
|
||||
addrSet := make(map[string]struct{})
|
||||
addresses := make([]string, 0, len(iface.IPAddresses))
|
||||
|
|
@ -604,13 +605,18 @@ func processGuestNetworkInterfaces(raw []proxmox.VMNetworkInterface) ([]string,
|
|||
}
|
||||
|
||||
if len(addresses) == 0 && rxBytes == 0 && txBytes == 0 {
|
||||
if len(iface.IPAddresses) > 0 {
|
||||
lowerName := strings.ToLower(ifaceName)
|
||||
if lowerName == "lo" || lowerName == "loopback" {
|
||||
continue
|
||||
}
|
||||
lowerName := strings.ToLower(ifaceName)
|
||||
if ifaceName == "" || lowerName == "lo" || lowerName == "loopback" {
|
||||
if ifaceName == "" && mac == "" {
|
||||
continue
|
||||
}
|
||||
if hadRawAddresses {
|
||||
// Preserve interface identity even when every reported address was filtered
|
||||
// (for example, link-local-only early guest-agent payloads). Proxmox still
|
||||
// considers this a real guest NIC and the UI should not hide it entirely.
|
||||
}
|
||||
// Preserve named non-loopback interfaces even when early/partial guest-agent
|
||||
// payloads have not populated MAC or IP details yet. The interface identity
|
||||
// is still useful for the VM Summary view and should not wait for a later poll.
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ func TestProcessGuestNetworkInterfaces(t *testing.T) {
|
|||
wantIfaces: []models.GuestNetworkInterface{},
|
||||
},
|
||||
{
|
||||
name: "filter link-local fe80",
|
||||
name: "preserve named interface when only link-local addresses are reported",
|
||||
raw: []proxmox.VMNetworkInterface{
|
||||
{
|
||||
Name: "eth0",
|
||||
|
|
@ -425,8 +425,10 @@ func TestProcessGuestNetworkInterfaces(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
wantIPs: []string{},
|
||||
wantIfaces: []models.GuestNetworkInterface{},
|
||||
wantIPs: []string{},
|
||||
wantIfaces: []models.GuestNetworkInterface{
|
||||
{Name: "eth0", MAC: "00:11:22:33:44:55", Addresses: nil},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "filter IPv6 loopback ::1",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue