Skip to content

Commit

Permalink
ovn: do not send direct traffic between lports to conntrack (#3663)
Browse files Browse the repository at this point in the history
Signed-off-by: zhangzujian <zhangzujian.7@gmail.com>
  • Loading branch information
zhangzujian committed Jan 30, 2024
1 parent 130f06c commit 822df37
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions charts/templates/controller-deploy.yaml
Expand Up @@ -99,6 +99,7 @@ spec:
- --default-vlan-name={{- .Values.networking.vlan.VLAN_NAME }}
- --default-vlan-id={{- .Values.networking.vlan.VLAN_ID }}
- --ls-dnat-mod-dl-dst={{- .Values.func.LS_DNAT_MOD_DL_DST }}
- --ls-ct-skip-dst-lport-ips={{- .Values.func.LS_CT_SKIP_DST_LPORT_IPS }}
- --pod-nic-type={{- .Values.networking.POD_NIC_TYPE }}
- --enable-lb={{- .Values.func.ENABLE_LB }}
- --enable-np={{- .Values.func.ENABLE_NP }}
Expand Down
1 change: 1 addition & 0 deletions charts/values.yaml
Expand Up @@ -62,6 +62,7 @@ func:
ENABLE_LB_SVC: false
ENABLE_KEEP_VM_IP: true
LS_DNAT_MOD_DL_DST: true
LS_CT_SKIP_DST_LPORT_IPS: true
ENABLE_BIND_LOCAL_IP: true
U2O_INTERCONNECTION: false
ENABLE_TPROXY: false
Expand Down
4 changes: 3 additions & 1 deletion dist/images/Dockerfile.base
Expand Up @@ -44,7 +44,9 @@ RUN cd /usr/src/ && git clone -b branch-22.12 --depth=1 https://github.com/ovn-o
# ovn-controller: do not send GARP on localnet for Kube-OVN ports
curl -s https://github.com/kubeovn/ovn/commit/8af8751cdb55f582c675db921f2526b06fd3d8c0.patch | git apply && \
# ovn-ic blacklist function not work on ipv6
curl -s https://github.com/kubeovn/ovn/commit/78ab91005854532e7eb5c4fe6b2923ce292e3681.patch | git apply
curl -s https://github.com/kubeovn/ovn/commit/78ab91005854532e7eb5c4fe6b2923ce292e3681.patch | git apply && \
# lflow: do not send direct traffic between lports to conntrack
curl -s https://github.com/kubeovn/ovn/commit/6f1af045845deeabf06fdc7c90073e0a6874ab2f.patch | git apply

RUN apt install -y build-essential fakeroot \
autoconf automake bzip2 debhelper-compat dh-exec dh-python dh-sequence-python3 dh-sequence-sphinxdoc \
Expand Down
2 changes: 2 additions & 0 deletions dist/images/install.sh
Expand Up @@ -15,6 +15,7 @@ ENABLE_LB=${ENABLE_LB:-true}
ENABLE_NP=${ENABLE_NP:-true}
ENABLE_EIP_SNAT=${ENABLE_EIP_SNAT:-true}
LS_DNAT_MOD_DL_DST=${LS_DNAT_MOD_DL_DST:-true}
LS_CT_SKIP_DST_LPORT_IPS=${LS_CT_SKIP_DST_LPORT_IPS:-true}
ENABLE_EXTERNAL_VPC=${ENABLE_EXTERNAL_VPC:-true}
CNI_CONFIG_PRIORITY=${CNI_CONFIG_PRIORITY:-01}
ENABLE_LB_SVC=${ENABLE_LB_SVC:-false}
Expand Down Expand Up @@ -3959,6 +3960,7 @@ spec:
- --default-exchange-link-name=$EXCHANGE_LINK_NAME
- --default-vlan-id=$VLAN_ID
- --ls-dnat-mod-dl-dst=$LS_DNAT_MOD_DL_DST
- --ls-ct-skip-dst-lport-ips=$LS_CT_SKIP_DST_LPORT_IPS
- --pod-nic-type=$POD_NIC_TYPE
- --enable-lb=$ENABLE_LB
- --enable-np=$ENABLE_NP
Expand Down
28 changes: 28 additions & 0 deletions mocks/pkg/ovs/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/controller/config.go
Expand Up @@ -78,6 +78,7 @@ type Configuration struct {
DefaultVlanName string
DefaultVlanID int
LsDnatModDlDst bool
LsCtSkipDstLportIPs bool

EnableLb bool
EnableNP bool
Expand Down Expand Up @@ -149,6 +150,7 @@ func ParseFlags() (*Configuration, error) {
argDefaultVlanName = pflag.String("default-vlan-name", "ovn-vlan", "The default vlan name")
argDefaultVlanID = pflag.Int("default-vlan-id", 1, "The default vlan id")
argLsDnatModDlDst = pflag.Bool("ls-dnat-mod-dl-dst", true, "Set ethernet destination address for DNAT on logical switch")
argLsCtSkipDstLportIPs = pflag.Bool("ls-ct-skip-dst-lport-ips", true, "Skip conntrack for direct traffic between lports")
argPodNicType = pflag.String("pod-nic-type", "veth-pair", "The default pod network nic implementation type")
argPodDefaultFipType = pflag.String("pod-default-fip-type", "", "The type of fip bind to pod automatically: iptables")
argEnableLb = pflag.Bool("enable-lb", true, "Enable load balancer")
Expand Down Expand Up @@ -223,6 +225,7 @@ func ParseFlags() (*Configuration, error) {
NetworkType: *argNetworkType,
DefaultVlanID: *argDefaultVlanID,
LsDnatModDlDst: *argLsDnatModDlDst,
LsCtSkipDstLportIPs: *argLsCtSkipDstLportIPs,
DefaultProviderName: *argDefaultProviderName,
DefaultHostInterface: *argDefaultInterfaceName,
DefaultExchangeLinkName: *argDefaultExchangeLinkName,
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/controller.go
Expand Up @@ -777,6 +777,10 @@ func (c *Controller) Run(ctx context.Context) {
util.LogFatalAndExit(err, "failed to set NB_Global option use_ct_inv_match to false")
}

if err := c.OVNNbClient.SetLsCtSkipDstLportIPs(c.config.LsCtSkipDstLportIPs); err != nil {
util.LogFatalAndExit(err, "failed to set NB_Global option ls_ct_skip_dst_lport_ips")
}

if err := c.InitOVN(); err != nil {
util.LogFatalAndExit(err, "failed to initialize ovn resources")
}
Expand Down
1 change: 1 addition & 0 deletions pkg/ovs/interface.go
Expand Up @@ -17,6 +17,7 @@ type NBGlobal interface {
SetUseCtInvMatch() error
SetICAutoRoute(enable bool, blackList []string) error
SetLsDnatModDlDst(enabled bool) error
SetLsCtSkipDstLportIPs(enabled bool) error
GetNbGlobal() (*ovnnb.NBGlobal, error)
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/ovs/ovn-nb_global.go
Expand Up @@ -153,3 +153,7 @@ func (c *OVNNbClient) SetLBCIDR(serviceCIDR string) error {
func (c *OVNNbClient) SetLsDnatModDlDst(enabled bool) error {
return c.SetNbGlobalOptions("ls_dnat_mod_dl_dst", enabled)
}

func (c *OVNNbClient) SetLsCtSkipDstLportIPs(enabled bool) error {
return c.SetNbGlobalOptions("ls_ct_skip_dst_lport_ips", enabled)
}
1 change: 1 addition & 0 deletions yamls/kube-ovn-dual-stack.yaml
Expand Up @@ -66,6 +66,7 @@ spec:
- --default-exchange-link-name=false
- --default-vlan-id=100
- --ls-dnat-mod-dl-dst=true
- --ls-ct-skip-dst-lport-ips=true
- --pod-nic-type=veth-pair
- --enable-lb=true
- --enable-np=true
Expand Down
1 change: 1 addition & 0 deletions yamls/kube-ovn-ipv6.yaml
Expand Up @@ -66,6 +66,7 @@ spec:
- --default-exchange-link-name=false
- --default-vlan-id=100
- --ls-dnat-mod-dl-dst=true
- --ls-ct-skip-dst-lport-ips=true
- --pod-nic-type=veth-pair
- --enable-lb=true
- --enable-np=true
Expand Down
1 change: 1 addition & 0 deletions yamls/kube-ovn.yaml
Expand Up @@ -66,6 +66,7 @@ spec:
- --default-exchange-link-name=false
- --default-vlan-id=100
- --ls-dnat-mod-dl-dst=true
- --ls-ct-skip-dst-lport-ips=true
- --pod-nic-type=veth-pair
- --enable-lb=true
- --enable-np=true
Expand Down

0 comments on commit 822df37

Please sign in to comment.