diff --git a/pkg/controller/pod.go b/pkg/controller/pod.go index 33ed41f3a8c..deb61b63fa3 100644 --- a/pkg/controller/pod.go +++ b/pkg/controller/pod.go @@ -869,6 +869,10 @@ func (c *Controller) handleUpdatePod(key string) error { klog.Errorf("failed to add static route, %v", err) return err } + } else { + if err := c.ovnLegacyClient.DeleteStaticRoute(podIP, c.config.ClusterRouter); err != nil { + return err + } } } diff --git a/pkg/ovs/ovn-nbctl-legacy.go b/pkg/ovs/ovn-nbctl-legacy.go index 7a3f0a19e75..93520928a4f 100644 --- a/pkg/ovs/ovn-nbctl-legacy.go +++ b/pkg/ovs/ovn-nbctl-legacy.go @@ -1082,6 +1082,12 @@ func parseLrRouteListOutput(output string) (routeList []*StaticRoute, err error) } func (c LegacyClient) UpdateNatRule(policy, logicalIP, externalIP, router, logicalMac, port string) error { + // when dual protocol pod has eip or snat, will add nat for all dual addresses. + // will fail when logicalIP externalIP is different protocol. + if externalIP != "" && util.CheckProtocol(logicalIP) != util.CheckProtocol(externalIP) { + return nil + } + if policy == "snat" { if externalIP == "" { _, err := c.ovnNbCommand(IfExists, "lr-nat-del", router, "snat", logicalIP)