From fe2797cd064e26be91adf9d643499b175521daad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Wed, 27 Mar 2024 19:32:21 +0800 Subject: [PATCH] ovn: update patch for skipping ct (#3879) Signed-off-by: zhangzujian --- dist/images/Dockerfile.base | 2 +- pkg/controller/subnet.go | 2 +- pkg/ovs/ovn-nbctl-legacy.go | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/dist/images/Dockerfile.base b/dist/images/Dockerfile.base index 7f141fb722d..fc7e03b1f8a 100644 --- a/dist/images/Dockerfile.base +++ b/dist/images/Dockerfile.base @@ -63,7 +63,7 @@ RUN cd /usr/src/ && git clone -b branch-22.03 --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/1792621bf33a661d66ca47620871668267e3e521.patch | git apply && \ # lflow: do not send direct traffic between lports to conntrack - curl -s https://github.com/kubeovn/ovn/commit/55b22c91f9e4a128ab2ae0068e426cc2f0220e0c.patch | git apply && \ + curl -s https://github.com/kubeovn/ovn/commit/f9ad910c8036dc138e52738c400ddcca7236337e.patch | git apply && \ sed -i 's/OVN/ovn/g' debian/changelog && \ rm -rf .git && \ ./boot.sh && \ diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index a24e268ce6b..e00a4d5b77b 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -1599,7 +1599,7 @@ func (c *Controller) reconcileVlan(subnet *kubeovnv1.Subnet) error { } localnetPort := ovs.GetLocalnetName(subnet.Name) - if err := c.ovnLegacyClient.CreateLocalnetPort(subnet.Name, localnetPort, vlan.Spec.Provider, vlan.Spec.ID); err != nil { + if err := c.ovnLegacyClient.CreateLocalnetPort(subnet.Name, localnetPort, vlan.Spec.Provider, subnet.Spec.CIDRBlock, vlan.Spec.ID); err != nil { klog.Errorf("failed to create localnet port for subnet %s: %v", subnet.Name, err) return err } diff --git a/pkg/ovs/ovn-nbctl-legacy.go b/pkg/ovs/ovn-nbctl-legacy.go index 67f24b3c97f..4c14c97df1a 100644 --- a/pkg/ovs/ovn-nbctl-legacy.go +++ b/pkg/ovs/ovn-nbctl-legacy.go @@ -2243,7 +2243,7 @@ func (c LegacyClient) GetLogicalSwitchPortByLogicalSwitch(logicalSwitch string) return rv, nil } -func (c LegacyClient) CreateLocalnetPort(ls, port, provider string, vlanID int) error { +func (c LegacyClient) CreateLocalnetPort(ls, port, provider, cidrBlock string, vlanID int) error { cmdArg := []string{ MayExist, "lsp-add", ls, port, "--", "lsp-set-addresses", port, "unknown", "--", @@ -2255,6 +2255,13 @@ func (c LegacyClient) CreateLocalnetPort(ls, port, provider string, vlanID int) cmdArg = append(cmdArg, "--", "set", "logical_switch_port", port, fmt.Sprintf("tag=%d", vlanID)) } + ipv4CIDR, ipv6CIDR := util.SplitStringIP(cidrBlock) + if ipv4CIDR != "" { + cmdArg = append(cmdArg, "--", "set", "logical_switch_port", port, fmt.Sprintf("external_ids:ipv4_network=%s", ipv4CIDR)) + } + if ipv6CIDR != "" { + cmdArg = append(cmdArg, "--", "set", "logical_switch_port", port, fmt.Sprintf("external_ids:ipv6_network=%s", ipv6CIDR)) + } if _, err := c.ovnNbCommand(cmdArg...); err != nil { klog.Errorf("create localnet port %s failed, %v", port, err)