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

more proxy tests and fixes #822

Merged
merged 5 commits into from
May 26, 2017
Merged

more proxy tests and fixes #822

merged 5 commits into from
May 26, 2017

Conversation

jrfastab
Copy link
Contributor

The previous pull request fixed up the build error this pull request adds additional tests and then fixes the code to handle the additional cases.

Note I made a design decision here to drop the local/global CT distinction. The caveat is in the local case we now use an 'IP address' worth of extra memory in the local CT case. The result is the code is much simpler and easier to read.

Thanks!

@jrfastab jrfastab requested review from tgraf and borkmann May 25, 2017 22:03
@jrfastab
Copy link
Contributor Author

At this point conntrack_local set via 'cilium config conntrack_local={false|true}' no longer appears to impact anything. If we want to remove it then the attached test case modifications are not needed and a couple additional deletes from endpoint.go could be added.

@borkmann
Copy link
Member

Still need to change tuples on the Go side. See 9cf0ee2. Can you elaborate on no longer impact anything? Wouldn't a switch to local still be a separate map as opposed the commonly shared map for global.

@jrfastab
Copy link
Contributor Author

OK, I need a few more fixes on the go side like @borkmann notes.

@@ -16,26 +16,27 @@ CLIENT_LABEL="id.client"
cleanup
logs_clear

docker network inspect $TEST_NET 2> /dev/null || {
Copy link
Member

Choose a reason for hiding this comment

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

Can we merge 10-proxy.sh and 14-proxy-ingress.sh together?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. patches collapse easy enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

aha you are not worried about the patches you mean the actual *.sh files, sure I can do that. Follow up PR though.

Proxy tests for conntrack local case.

Signed-off-by: John Fastabend <[email protected]>
Proxy tests for conntrack local case.

Note, I avoided building a larger unified test function and
bash helpers because I like being able to see an entire test
in a single file when debugging.

Signed-off-by: John Fastabend <[email protected]>
There is a bug in the proxy code when local conntrack is enabled.
The issue is the proxy{4,6} map uses the original source IP in the key
when configuring the proxy. This allows the key to be matched by
the proxy on the 'from-netdev' side by using the 'dip' (which is
the client's IP) to lookup the address translation. The result
from the lookup is then used to translate the ports and source IP.

In the global CT case the ct_lookup{4,6} path reverses the saddr and
daddr in the ipv{4,6}_ct_tuple and, assuming no match is found in
the table, calls ct_create{4,6} to add a new key/value pair to the
proxy{4,6} map. When the key is created for this entry the 'daddr'
in the tuple is used which is actually the 'source' IP from the
packet (in other words its the clients IP address).

However, in the local CT case the tuple only has a single addr
and it is not swapped by the tuple reverse logic in ct_lookup{4,6}.
The result is ct_create{4,6} creates a key using the only available
address, which is the destination IP from the packet which corresponds
to the server. Then when the proxy sends packets, using the
'from-netdev' code path, a key is built using the destination IP
(the client IP from this direction) but there is no match in the
proxy{4,6} map due to the above bug (specifically the key being built
with the server IP).

To resolve this we came up with two solutions. One is to pass
the original source IP and use this in ct_create{4,6} as the source
address. But this gets ugly and we already pass by value the
orig_dip and orig_was_proxy so adding yet another value is getting
a bit awkward. The other option, and the one we implemented, is
to convert local CT over to use the same tuple structure as the
global CT implementation so that both modes have the same data
structures available to build the key from.

This solves the above issue and simplifies the code instead
of complicating it furher. With the nice benefit of being a patch
full of removals and creating one less #define to worry about.
The disadvantage is the key size is sizeof('address') larger in
the conntrack local case. However, this is not the default case
so I believe the trade-off is worth it.

Signed-off-by: John Fastabend <[email protected]>
The keys are the same for both local and glocal case now so
we can remove at least a few additional switch statements.

Signed-off-by: John Fastabend <[email protected]>
Signed-off-by: John Fastabend <[email protected]>
Copy link
Member

@borkmann borkmann left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants