Skip to content
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

Remove Service hairpin table ServiceHairpinTable and HairpinSNATTable #2842

Closed
wants to merge 1 commit into from

Conversation

hongliangl
Copy link
Contributor

@hongliangl hongliangl commented Sep 26, 2021

Since a SNAT ct zone is added in PR #2599, hairpin Service
traffic can make use of the SNAT ct zone instead of current
stateless SNAT by modifying source and destination IPs.
By removing hairpin table ServiceHairpinTable and
HairpinSNATTable, the OVS pipeline can be simpler.

Pipeline modifications:

  • Remove table serviceHairpinTable 23.
  • Remove table HairpinSNATTable 108.
  • Add table hairpinMarkTable 81 after table
    l2ForwardingCalcTable 80.

When a local Endpoint is referenced by a Service, then a
flow that matches the packet whose input and output
interfaces are the same and makes mark HairpinRegMark,
will be installed on table hairpinMarkTable. Packets with
mark HairpinRegMark will be performed SNAT with Antrea
gateway IP on table snatConntrackCommitTable.

Signed-off-by: Hongliang Liu lhongliang@vmware.com

@codecov-commenter
Copy link

codecov-commenter commented Sep 26, 2021

Codecov Report

Merging #2842 (e879ea7) into main (5480b68) will decrease coverage by 0.15%.
The diff coverage is 93.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2842      +/-   ##
==========================================
- Coverage   61.42%   61.26%   -0.16%     
==========================================
  Files         284      284              
  Lines       23470    23483      +13     
==========================================
- Hits        14417    14388      -29     
- Misses       7496     7553      +57     
+ Partials     1557     1542      -15     
Flag Coverage Δ
kind-e2e-tests 48.90% <93.00%> (-0.09%) ⬇️
unit-tests 40.86% <11.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/agent/openflow/client.go 57.70% <66.66%> (+0.05%) ⬆️
pkg/agent/openflow/pipeline.go 76.12% <98.78%> (-0.01%) ⬇️
pkg/apiserver/certificate/certificate.go 69.86% <0.00%> (-6.85%) ⬇️
pkg/agent/controller/traceflow/packetin.go 59.49% <0.00%> (-5.49%) ⬇️
...agent/controller/traceflow/traceflow_controller.go 69.85% <0.00%> (-3.55%) ⬇️
pkg/controller/traceflow/controller.go 70.30% <0.00%> (-2.43%) ⬇️
pkg/monitor/controller.go 27.61% <0.00%> (-1.50%) ⬇️
pkg/ovs/openflow/ofctrl_action.go 68.33% <0.00%> (-1.25%) ⬇️
...gent/controller/noderoute/node_route_controller.go 55.33% <0.00%> (-1.13%) ⬇️
... and 5 more

@@ -34,9 +34,9 @@ type connTrackOvsCtlWindows struct {
func (ct *connTrackOvsCtlWindows) GetMaxConnections() (int, error) {
var zoneID int
if ct.serviceCIDRv4 != nil {
zoneID = openflow.CtZone
zoneID = openflow.DNATCtZone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows doesn't support IPv6 now, so it is not necessary to leverage DNATCtZoneV6 on Windows.

Cookie(c.cookieAllocator.Request(category).Raw()).
Done(),
connectionTrackCommitTable.BuildFlow(priorityLow).MatchProtocol(proto).
MatchCTStateTrk(true).
dnatConnectionTrackCommitTable.BuildFlow(priorityHigh).MatchProtocol(proto).
MatchCTMark(ServiceCTMark).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks you want all the DNATed connections to goto snatConntrackCommitTable? Is it better to redirect only the ones has HairpinRegMark for established connections and redirect all new DNATed connections?

// Service CT_MARK). Since the reply packets should be output to the port on which it was received and the
// CT_MARK value for hairpin will be lost, HairpinRegMark is used.
dnatConnectionTrackTable.BuildFlow(priorityHigh).MatchProtocol(proto).
MatchCTStateRpl(true).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to load the regMark in snatConnectionTrackTable or maybe you can a sequencing table after snatConnectionTrackTable to check the snat conntrack track state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flow is for reply packets. Without passing SNAT ct zone on table snatConnectionTrackTable, we cannot get the CT_MARK which is set on SNAT ct zone.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

snatConnectionTrackTable is prior to dnatConnectionTrackTable, so the reply packet is possible to enter snatConnectionTrackTable first?

// value set in SNAT ct zone will be lost after passing DNAT ct zone, before
// passing DNAT ct zone, HairpinRegMark is set and is used to match the reply
// packets.
func (c *client) l2ForwardOutputServiceHairpinFlows() []binding.Flow {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it is better to use a single flow in L2ForwardingOutTable for Hairpin traffic. I guess you add a flow to match condition "ServiceHairpinCTMark" for the first traffic for such flows. Maybe you can load the regmark in the flow action when committing the connection to snatConntrackZone

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not only for the first packet of hairpin connections. It's also for the third, fifth .. packets (requests packets except the first one). The request packets (except the first one) cannot get the value of CT_MARK when passing through SNAT ct zone on table snatConntrackTable (but reply packets can get). When passing through SNAT ct zone on table snatConntrackCommitTable, the value of CT_MARK can be got. However, the next table L2ForwardingOutTable. I think we'd better add a flow rather than a new table.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I don't prefer to use ct mark in L2ForwardingOutTable, as I thought this table is possible to focus on L2 operations... Since the target ofport number is decided after L2FwdCalcTable, is it possible to set the regMark after that table?

@antoninbas antoninbas added area/ovs/openflow Issues or PRs related to Open vSwitch Open Flow. area/proxy Issues or PRs related to proxy functions in Antrea review-manager-test labels Sep 27, 2021
@antoninbas
Copy link
Contributor

Could you provide information about this change in the commit message & PR description? I have no context for this change and there is no linked issue.

@hongliangl hongliangl force-pushed the remove-hairpin branch 3 times, most recently from 60fca2b to 6ee76a7 Compare September 28, 2021 10:48
@hongliangl
Copy link
Contributor Author

Could you provide information about this change in the commit message & PR description? I have no context for this change and there is no linked issue.

Updated.

Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Antonin means to explain why we make the changes.

In the commit message:

flow that matches the packet whose input and output
interfaces are the same and makes mark HairpinRegMark,
will be installed on table hairpinMarkTable.
a flow will be installed into hairpinMarkTable, which sets HairpinRegMark for the packets whose input and output ports are the same.

mark HairpinRegMark will be performed SNAT with Antrea
Packets with HairpinRegMark set will be SNAT'd

gateway IP on table snatConntrackCommitTable.
in snatConntrackCommitTable

@hongliangl
Copy link
Contributor Author

I think Antonin means to explain why we make the changes.

In the commit message:

flow that matches the packet whose input and output
interfaces are the same and makes mark HairpinRegMark,
will be installed on table hairpinMarkTable.
a flow will be installed into hairpinMarkTable, which sets HairpinRegMark for the packets whose input and output ports are the same.

mark HairpinRegMark will be performed SNAT with Antrea
Packets with HairpinRegMark set will be SNAT'd

gateway IP on table snatConntrackCommitTable.
in snatConntrackCommitTable

@jianjuns, Thanks. Since a SNAT ct zone is added in PR #2599, hairpin Service traffic can make use of the SNAT ct zone instead of current stateless SNAT by modifying source and destination IPs. By removing hairpin table ServiceHairpinTable and HairpinSNATTable, the OVS pipeline can be simpler.

@hongliangl hongliangl force-pushed the remove-hairpin branch 3 times, most recently from 2d515eb to 0d032f8 Compare September 29, 2021 10:57
Since a SNAT ct zone is added in PR antrea-io#2599, hairpin Service
traffic can make use of the SNAT ct zone instead of current
stateless SNAT by modifying source and destination IPs.
By removing hairpin table ServiceHairpinTable and
HairpinSNATTable, the OVS pipeline can be simpler.

Pipeline modifications:
- Remove table serviceHairpinTable #23.
- Remove table HairpinSNATTable #108.
- Add table hairpinMarkTable #81 after table
  l2ForwardingCalcTable #80.

When a local Endpoint is referenced by a Service, then a
flow that matches the packet whose input and output
interfaces are the same and makes mark HairpinRegMark,
will be installed on table hairpinMarkTable. Packets with
mark HairpinRegMark will be performed SNAT with Antrea
gateway IP on table snatConntrackCommitTable.

Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
@github-actions
Copy link
Contributor

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 30, 2021
@hongliangl hongliangl closed this Jan 11, 2022
@hongliangl hongliangl deleted the remove-hairpin branch April 21, 2022 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ovs/openflow Issues or PRs related to Open vSwitch Open Flow. area/proxy Issues or PRs related to proxy functions in Antrea lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. review-manager-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants