-
Notifications
You must be signed in to change notification settings - Fork 373
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 OVS flows for implementing Egress #1969
Conversation
e9716c6
to
495dba8
Compare
Codecov Report
@@ Coverage Diff @@
## main #1969 +/- ##
==========================================
+ Coverage 65.05% 65.21% +0.15%
==========================================
Files 195 197 +2
Lines 16882 17275 +393
==========================================
+ Hits 10983 11266 +283
- Misses 4729 4836 +107
- Partials 1170 1173 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Code logic LGTM. CI detects some syntax errors.
pkg/agent/openflow/client.go
Outdated
func (c *client) InstallPodSNATFlows(ofPort uint32, snatMark uint32, isIPv6 bool) error { | ||
c.replayMutex.RLock() | ||
defer c.replayMutex.RUnlock() | ||
flows := make([]binding.Flow, 0, 2) |
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.
why make it 2? I see only one flow
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.
Fixed it.
Originally I thought we might need to add a flow for both v4 and v6 in the dual stack case.
pkg/agent/openflow/client_windows.go
Outdated
@@ -39,13 +38,13 @@ func (c *client) InstallLoadBalancerServiceFromOutsideFlows(svcIP net.IP, svcPor | |||
defer c.replayMutex.RUnlock() | |||
var flows []binding.Flow | |||
flows = append(flows, c.loadBalancerServiceFromOutsideFlow(svcIP, svcPort, protocol)) | |||
cacheKey := fmt.Sprintf("L%s%s%x", svcIP, protocol, svcPort) | |||
cacheKey := fmt.Sprintf("LoadBalancerService_%s_%d_%s", svcIP, svcPort, protocol) |
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.
Unintended update?
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 one and another error were introduced by rebasing. Thanks for pointing out.
d4527a7
to
57615a9
Compare
pkg/agent/openflow/client.go
Outdated
// which set the SNAT IP mark on the packets from the ofPort to external. | ||
// As of now, a Pod can be configured with a single SNAT IP in a single | ||
// address family (IPv4 or IPv6). | ||
InstallPodSNATFlows(ofPort uint32, snatMark uint32, isIPv6 bool) error |
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.
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.
You are right! I missed the flow. Added it.
680eae2
to
93b50a9
Compare
Add flows that set pkt_mark for egress traffic that should be SNAT'd using a SNAT IP, including egress traffic from a local Pod to which the Egress is applied, and traffic from a remote Node that is tunnelled to the egress Node with the SNAT IP; and flows that tunnel egress traffic to the remote Node, when the SNAT IP for the traffic is on the local Node. Each SNAT IP on the Node will be allocated with a unique integer ID, which is set to the pkt_mark, and so the SNAT implementation can look up the right SNAT IP from the pkt_mark. On Linux, SNAT will be implemented by iptables SNAT rules; on Windows, SNAT is implemented by OVS NAT.
b42e93f
to
4fa781e
Compare
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-all |
Add flows that set pkt_mark for egress traffic that should be SNAT'd
using a SNAT IP, including egress traffic from a local Pod to which the
Egress is applied, and traffic from a remote Node that is tunnelled to
the egress Node with the SNAT IP.
Each SNAT IP on the Node will be allocated with a unique integer ID,
which is set to the pkt_mark, and so the SNAT implementation can look
up the right SNAT IP from the pkt_mark. On Linux, SNAT will be
implemented by iptables SNAT rules; on Windows, SNAT is implemented
by OVS NAT.
#1924