-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ignored interfaces names when getting interface by IP #3219
Conversation
7eabe74
to
aeed963
Compare
Codecov Report
@@ Coverage Diff @@
## main #3219 +/- ##
==========================================
- Coverage 60.09% 52.23% -7.87%
==========================================
Files 331 303 -28
Lines 28420 36323 +7903
==========================================
+ Hits 17080 18973 +1893
- Misses 9476 15552 +6076
+ Partials 1864 1798 -66
Flags with carried forward coverage won't be shown. Click here to find out more.
|
pkg/agent/util/net.go
Outdated
@@ -111,8 +111,11 @@ func dialUnix(address string) (net.Conn, error) { | |||
return net.Dial("unix", address) | |||
} | |||
|
|||
// GetIPNetDeviceFromIP returns local IPs/masks and associated device from IP. | |||
func GetIPNetDeviceFromIP(localIPs *ip.DualStackIPs) (v4IPNet *net.IPNet, v6IPNet *net.IPNet, iface *net.Interface, err error) { | |||
// GetIPNetDeviceFromIP returns local IPs/masks and associated device from IP, and ignore the interfaces which has a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore->ignores
has->have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, except for the lint error in ip_assigner_windows.go
caused by unused import.
/test-all |
/test-e2e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall, have a suggestion about the readability
pkg/agent/agent.go
Outdated
@@ -1114,3 +1115,7 @@ func (i *Initializer) patchNodeAnnotations(nodeName, key string, value interface | |||
} | |||
return nil | |||
} | |||
|
|||
func (i *Initializer) getIgnoredHostInterfaces() sets.String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hard to tell what's the method used for from the method name when looking at it without knowing its callers, but I cannot think of a more understandable name either.
How about creating a method and use it in the 3 callers, then comment why we need to exclude the device in single place:
func (i *Initializer) getNodeInterfaceFromIP(ips *ip.DualStackIPs) sets.String {
// Exclude i.hostGateway to resolve an issue that two interfaces are configured with the same IPs in NetworkPolicyOnly mode.
return getIPNetDeviceFromIP(ips, sets.NewString(i.hostGateway))
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
pkg/agent/util/net.go
Outdated
func GetIPNetDeviceFromIP(localIPs *ip.DualStackIPs) (v4IPNet *net.IPNet, v6IPNet *net.IPNet, iface *net.Interface, err error) { | ||
// GetIPNetDeviceFromIP returns local IPs/masks and associated device from IP, and ignores the interfaces which have | ||
// names in the ignoredInterfaces. | ||
// Use ignoredInterfaces to resolve an issue that two interfaces are configured with the same IPs in NetworkPolicyOnly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be on caller side as the util is generic, having no idea why some interfaces should be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move it to caller.
/test-e2e |
/test-windows-all |
/test-conformance |
pkg/agent/agent.go
Outdated
@@ -1114,3 +1115,7 @@ func (i *Initializer) patchNodeAnnotations(nodeName, key string, value interface | |||
} | |||
return nil | |||
} | |||
|
|||
func (i *Initializer) getIgnoredHostInterfaces() sets.String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't it be removed?
This is to resolve an issue that caused by two interfaces configured with the same IP address (different masks) on the host. The issue occurred in AKE setup with NetworkPolicyOnly mode, and antrea-gw0 is configured with Node's IP with 32bit mask. The changes include, 1. Provide a set of ignored interface names (e.g., antrea-gw0) when getting the Node's transport interface with Node's IP in agentInitializer. 2. Use Node's transport interface name to get the accurate interface in Egress feature instead of Node's IP. Signed-off-by: wenyingd <[email protected]>
/test-all |
/test-e2e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/test-e2e |
…3219) This is to resolve an issue that caused by two interfaces configured with the same IP address (different masks) on the host. The issue occurred in AKE setup with NetworkPolicyOnly mode, and antrea-gw0 is configured with Node's IP with 32bit mask. The changes include, 1. Provide a set of ignored interface names (e.g., antrea-gw0) when getting the Node's transport interface with Node's IP in agentInitializer. 2. Use Node's transport interface name to get the accurate interface in Egress feature instead of Node's IP. Signed-off-by: wenyingd <[email protected]>
This is to resolve an issue that caused by two interfaces configured
with the same IP address (different masks) on the host. The issue
occurred in AKE setup with NetworkPolicyOnly mode, and antrea-gw0 is
configured with Node's IP with 32bit mask.
The changes include,
getting the Node's transport interface with Node's IP in
agentInitializer.
Egress feature instead of Node's IP.
Fixes #3217
Signed-off-by: wenyingd [email protected]