-
Notifications
You must be signed in to change notification settings - Fork 433
Add support for Antrea Egress in hybrid mode #7239
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
Conversation
5bcb6c8 to
2f0eae9
Compare
61f8d42 to
c36407b
Compare
c36407b to
15b17e8
Compare
15b17e8 to
afbbf6d
Compare
|
@hongliangl please check if patch ut coverage can be improved. |
Will check. |
pkg/agent/openflow/pipeline.go
Outdated
| Cookie(f.cookieAllocator.Request(f.category).Raw()). | ||
| MatchProtocol(ipProtocol). | ||
| MatchRegMark(FromGatewayRegMark, FromExternalRegMark). | ||
| MatchPktMark(types.RemotePodSourceMark, &types.RemotePodSourceMark). |
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 we need to matach a remote Pod mark here? Could not we just match egress traffic, since destination is already matched by MatchDstIPNet(peerSubnet)?
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 is to exclude the request packets of external-to-Service (backend is a remote Pod) connections. I will add comment to this line to explain.
acf1edf to
ca06d56
Compare
b5210d6 to
507b3fe
Compare
antoninbas
left a comment
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.
some initial comments
1bb82b7 to
efb5191
Compare
antoninbas
left a comment
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.
Change looks good to me, I think @tnqn should review as well
24013fb to
9e0e31b
Compare
383dfe9 to
64cb0d9
Compare
d51733a to
eacb369
Compare
46ec86a to
01e4486
Compare
This commit adds support of Antrea Egress in hybrid mode. The key changes include:
- IPTables rules added in table `mangle`, chains `ANTREA-PREROUTING` and `ANTREA-POSTROUTING`
```shell
# Set connmark for the first packets of connections originated remote Pods.
-A ANTREA-PREROUTING ! -s 10.244.0.0/24 -i antrea-gw0 -m comment --comment "Antrea: set connmark for the first Egress request packet" -m conntrack --ctstate NEW -m mark ! --mark 0x0/0xff -j CONNMARK --set-xmark 0x40000000/0x40000000
# Restore fwmark from connmark for reply packets of connections originated from remote Pods.
-A ANTREA-PREROUTING -m comment --comment "Antrea: restore fwmark from connmark for reply packets sourced from remote Pods" -m conntrack --ctstate ESTABLISHED -m conntrack --ctdir REPLY -m connmark --mark 0x40000000/0x40000000 -j CONNMARK --restore-mark --nfmask 0x40000000 --ctmask 0x40000000
# Clear fwmark from reply packets of connections originated from remote Pods.
-A ANTREA-POSTROUTING -m comment --comment "Antrea: clear fwmark from reply Egress packets to remote Pods" -m conntrack --ctstate ESTABLISHED -m conntrack --ctdir REPLY -j MARK --set-xmark 0x0/0x40000000
```
- IP rule
```shell
root@kind-control-plane:/# ip rule | grep 141
32765: from all fwmark 0x40000000/0x40000000 lookup 141
```
- A default route in the policy-routing table 141 and its corresponding static ip neighbor
are used to forward reply Egress packets back to OVS pipeline.
```shell
root@kind-control-plane:/# ip route list table 141
default via 169.254.0.251 dev antrea-gw0 onlink
root@kind-control-plane:/# ip neigh | grep 169.254.0.251
169.254.0.251 dev antrea-gw0 lladdr aa:bb:cc:dd:ee:ff PERMANENT
```
- OVS flows
```shell
# Encapsulate packets sourced from antrea-gw0 and destined to remote Pod CIDRs via tunnel.
table=L3Forwarding, priority=201,ct_mark=0x1/0xf,ip,in_port=antrea-gw0, nw_dst=10.244.1.0/24 actions=set_field:ba:5e:d1:55:aa:c0->eth_src,set_field:aa:bb:cc:dd:ee:ff->eth_dst,set_field:172.18.0.3->tun_dst,set_field:0x10/0xf0->reg0,goto_table:L3DecTTL
table=L3Forwarding, priority=201,ct_mark=0x1/0xf,ip,in_port=antrea-gw0, nw_dst=10.244.2.0/24 actions=set_field:ba:5e:d1:55:aa:c0->eth_src,set_field:aa:bb:cc:dd:ee:ff->eth_dst,set_field:172.18.0.4->tun_dst,set_field:0x10/0xf0->reg0,goto_table:L3DecTTL
table=L3Forwarding, priority=201,ct_mark=0x1/0xf,ip,in_port=antrea-gw0, nw_dst=10.244.3.0/24 actions=set_field:ba:5e:d1:55:aa:c0->eth_src,set_field:aa:bb:cc:dd:ee:ff->eth_dst,set_field:172.18.0.5->tun_dst,set_field:0x10/0xf0->reg0,goto_table:L3DecTTL
```
Signed-off-by: Hongliang Liu <[email protected]>
Signed-off-by: Hongliang Liu <[email protected]>
01e4486 to
9f4ef0e
Compare
tnqn
left a comment
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 |
antoninbas
left a comment
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 - but I did ask for a clarification in https://github.com/antrea-io/antrea/pull/7239/files#r2505192467, PTAL
@antoninbas Replied in #7239 (comment). If the performance loss is acceptable using a unified pkt_mark regardless of traffic modes, we can refine the implementation in a subsequent PR. Created an issue #7554 to track that. |
This commit adds support of Antrea Egress in hybrid mode. The key changes include:
IPTables rules added in table
mangle, chainsANTREA-PREROUTINGandANTREA-POSTROUTINGIP rule
root@kind-control-plane:/# ip rule | grep 141 32765: from all fwmark 0x40000000/0x40000000 lookup 141A default route in the policy-routing table 141 and its corresponding static ip neighbor
are used to forward reply Egress packets back to OVS pipeline.
OVS flows
The benchmark of hybrid vs encap of Egress traffic:
Dependencies: