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

Whitelist failsafe port response traffic in the raw table only #1718

Merged
merged 3 commits into from
Mar 6, 2018

Conversation

fasaxc
Copy link
Member

@fasaxc fasaxc commented Mar 2, 2018

Description

This fixes a nasty interaction between do-not-track policy and failsafe ports. Previously, adding do-not-track policy to a host endpoint resulted in failsafe port traffic being blocked because one leg of the connection would get conntracked, but the return leg would hit the do-not-track policy, which would either drop it (thus breaking the failsafe port) or mark it as NOTRACK, which results in future outbound packets failing the --ctstate INVALID test (because conntrack has only seen an outbound SYN, it isn't expecting the outbound to move past the SYN stage of the handshake).

This change whitelists the response traffic in the raw table only so that failsafe ports are now forced to be conntracked, bypassing any do-not-track policy in both directions. Since the change is made only in the raw table (and we don't mark failsafe port traffic with the accepted mark), the response traffic still has to pass the --ctstate ESTABLISHED test in the filter table.

Todos

  • Unit tests (full coverage)
  • Integration tests (delete as appropriate) In plan/Not needed/Done
  • Documentation
  • Backport
  • Release note

Release Note

Fixes an interaction between failsafe inbound/outbound ports and do-not-track policy that resulted in failsafe ports being blocked if do-not-track policy was added.

@fasaxc fasaxc added this to the Calico v3.1.0 milestone Mar 2, 2018
@fasaxc fasaxc requested a review from nelljerram March 2, 2018 16:26
Copy link
Member

@nelljerram nelljerram left a comment

Choose a reason for hiding this comment

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

Just a few nits.

@@ -0,0 +1,275 @@
// +build fvtests

// Copyright (c) 2017-2018 Tigera, Inc. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Just 2018, unless you secretly have a TARDIS.

fmt.Sprintf("host%d", ii),
"", // No interface name means "run in the host's namespace"
felixes[ii].IP,
"8055,2379,22", // Extra ports are out/in and inbound failsafes.
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what is meant here by "out/in and inbound".

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see now, but I think better to be more explicit here: "2379 is a failsafe port both inbound and outbound; 22 is a failsafe port for inbound only; 8055 is not a failsafe."

host0Pol, err = client.GlobalNetworkPolicies().Update(ctx, host0Pol, options.SetOptions{})
Expect(err).NotTo(HaveOccurred())

host1Pol, err = client.GlobalNetworkPolicies().Update(ctx, host1Pol, options.SetOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

Does this update do anything?

@@ -492,5 +500,5 @@ func (c *ConnectivityChecker) CheckConnectivityWithTimeout(timeout time.Duration
strings.Join(actualConn, "\n "),
strings.Join(expConnectivity, "\n "),
)
Fail(message, 1)
Fail(message, callerSkip)
Copy link
Member

Choose a reason for hiding this comment

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

Note: I think default callerSkip here has changed from 1 to 2 - but I presume that that is what you want (for nicest debugging/reporting).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, exactly, I want it to report the failure on the test case line, not in workload.go.

@fasaxc fasaxc merged commit da11a06 into projectcalico:master Mar 6, 2018
@fasaxc fasaxc deleted the failsafe-donottrack branch March 6, 2018 11:07
fasaxc added a commit to fasaxc/felix that referenced this pull request Mar 23, 2018
(cherry-picked from commit da11a06)
Whitelist failsafe port response traffic in the raw table only
fasaxc added a commit to fasaxc/felix that referenced this pull request Apr 6, 2018
This fixes a nasty interaction between do-not-track policy and
failsafe ports. Previously, adding do-not-track policy to a host
endpoint resulted in failsafe port traffic being blocked because
one leg of the connection would get conntracked, but the return
leg would hit the do-not-track policy, which would either drop
it (thus breaking the failsafe port) or mark it as NOTRACK,
which results in future outbound packets failing the
--ctstate INVALID test (because conntrack has only seen an
outbound SYN, it isn't expecting the outbound to move past the
SYN stage of the handshake).

This change whitelists the response traffic in the raw table
only so that failsafe ports are now forced to be conntracked,
bypassing any do-not-track policy in both directions. Since
the change is made only in the raw table (and we don't mark
failsafe port traffic with the accepted mark), the response
traffic still has to pass the --ctstate ESTABLISHED test in
the filter table.

Merge pull request projectcalico#1718 from fasaxc/failsafe-donottrack

(cherry picked from commit da11a06)

Whitelist failsafe port response traffic in the raw table only
fasaxc added a commit to fasaxc/felix that referenced this pull request Apr 10, 2018
This fixes a nasty interaction between do-not-track policy and
failsafe ports. Previously, adding do-not-track policy to a host
endpoint resulted in failsafe port traffic being blocked because
one leg of the connection would get conntracked, but the return
leg would hit the do-not-track policy, which would either drop
it (thus breaking the failsafe port) or mark it as NOTRACK,
which results in future outbound packets failing the
--ctstate INVALID test (because conntrack has only seen an
outbound SYN, it isn't expecting the outbound to move past the
SYN stage of the handshake).

This change whitelists the response traffic in the raw table
only so that failsafe ports are now forced to be conntracked,
bypassing any do-not-track policy in both directions. Since
the change is made only in the raw table (and we don't mark
failsafe port traffic with the accepted mark), the response
traffic still has to pass the --ctstate ESTABLISHED test in
the filter table.

Merge pull request projectcalico#1718 from fasaxc/failsafe-donottrack

(cherry picked from commit da11a06)

Whitelist failsafe port response traffic in the raw table only
fasaxc added a commit to fasaxc/felix that referenced this pull request Apr 10, 2018
This fixes a nasty interaction between do-not-track policy and
failsafe ports. Previously, adding do-not-track policy to a host
endpoint resulted in failsafe port traffic being blocked because
one leg of the connection would get conntracked, but the return
leg would hit the do-not-track policy, which would either drop
it (thus breaking the failsafe port) or mark it as NOTRACK,
which results in future outbound packets failing the
--ctstate INVALID test (because conntrack has only seen an
outbound SYN, it isn't expecting the outbound to move past the
SYN stage of the handshake).

This change whitelists the response traffic in the raw table
only so that failsafe ports are now forced to be conntracked,
bypassing any do-not-track policy in both directions. Since
the change is made only in the raw table (and we don't mark
failsafe port traffic with the accepted mark), the response
traffic still has to pass the --ctstate ESTABLISHED test in
the filter table.

Merge pull request projectcalico#1718 from fasaxc/failsafe-donottrack

(cherry picked from commit da11a06)

Whitelist failsafe port response traffic in the raw table only
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants