In this code, either c.IPv4.Equal(podIPv4) or c.IPv6.Equal(podIPv6) return true in almost case.
In the case of IPv4(or IPv6) single stack, this condition always returns true, and netNsPath is updated in every loop.
As a result, the wrong network namespace is picked.
This PR is related: #253
Background
From coil v2.5,
coild
runsEgressWatcher
to watchEgress
resources.When
Egress
resources are modified(or created, deleted), EgressWatcher reflects its configuration to pods that use its Egress.What
When reflecting the change to the pod, EgressWatcher picks the wrong network namespace and creates a device for the wrong pod.
Why
EgressWatcher
gets the network namespace associated with the target pod by the pods' IP addresses.https://github.com/cybozu-go/coil/blob/ea4d2acd1c80362477472a42bf682b5678f1aa9d/v2/pkg/nodenet/pod.go#L425
In this code, either
c.IPv4.Equal(podIPv4)
orc.IPv6.Equal(podIPv6)
return true in almost case. In the case of IPv4(or IPv6) single stack, this condition always returns true, andnetNsPath
is updated in every loop. As a result, the wrong network namespace is picked.