[filters] original src so_mark and ip_transparent#5525
[filters] original src so_mark and ip_transparent#5525mattklein123 merged 13 commits intoenvoyproxy:masterfrom
Conversation
We need to set SO_MARK and IP_TRANSPARENT. Do so. This needs some further work to UT it. Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Rather than relying on the original_src option encapsulating many options, just have the filter add multiple options. Simpler. Signed-off-by: Kyle Larose <kyle@agilicus.com>
If the platform (i.e. mac) doesn't support a given option, short circuit testing of it by just returning. Also fix a typo in a comment. Signed-off-by: Kyle Larose <kyle@agilicus.com>
|
/retest |
|
🔨 rebuilding |
Signed-off-by: Kyle Larose <kyle@agilicus.com>
This field didn't make sense. We take a different approach for testing options which don't have details that make sense. Signed-off-by: Kyle Larose <kyle@agilicus.com>
Pluralize some stuff. Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
|
@lizan Thanks for the first pass. How is this looking now? |
|
@lizan Any chance of looking at this in the next few days, please? Thanks. :) |
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
|
@lizan Looking good now? |
| // Sets the SO_MARK option on the upstream connection's socket to the provided value. Used to | ||
| // ensure that non-local addresses may be routed back through envoy when binding to the original | ||
| // source address. | ||
| // [#proto-status: experimental] |
There was a problem hiding this comment.
I realize this is not this PR, but does a mark of 0 make sense? Shouldn't this be an optional uint32 WKT wrapper? If a mark of 0 means, no mark, and this is OK, can you document that?
There was a problem hiding this comment.
A mark of 0 is equivalent to not marking it at all. I could document that for sure, though if I were to do that, I would probably want to make the mark option not set at all if it's zero. I can definitely do that as part of this PR. I'll update the docs while I'm at it too. Now that they're merged, it's not a big deal. :)
There was a problem hiding this comment.
OK thank you. Either option is fine with me.
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
|
/retest |
|
🔨 rebuilding |
Signed-off-by: Kyle Larose <kyle@agilicus.com> Signed-off-by: Dan Zhang <danzh@google.com>
|
@klarose Could you briefly elaborate how you use the SO_MARK set on the upstream connection to ensure the return traffic is routed back to Envoy? AFAIK only the outgoing packets will have the skb->mark set, return packets will not (unless marked by the destination in the same network namespace). |
|
@jrajahalme TL;DR: conntrack Basically, we save the mark in the conntrack record on egress from envoy. When return packets come back, we use conntrack to restore the mark, then force it through the a different routing table. You can see some example config here: https://www.envoyproxy.io/docs/envoy/latest/configuration/listener_filters/original_src_filter#extra-setup |
Signed-off-by: Kyle Larose <kyle@agilicus.com> Signed-off-by: Kyle Larose <eomereadig@gmail.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com> Signed-off-by: Fred Douglas <fredlas@google.com>
Description:
This completes the primary functionality of the original src listener filter by adding SO_MARK and IP_TRANSPARENT options to the upstream connection. With these, any IP address can now connect upstream. This is one of the tasks mentioned in #5337
My original plan for the options was to have the OriginalSrcSocketOption recurse into them. However, I realized that this was somewhat sketchy when doing the UT -- there was not clean mapping between a socket option and multiple "sub-options". Rather than introduce such a comment, I simply leveraged the fact that we are already adding an option to the socket -- now we just add three instead of one!
Risk Level: Low. Existing filter; minor changes to code used in testing.
Testing: UT + some testing of ipv4 and ipv6 traffic using a container.
Docs Changes: See #5539.