diff --git a/internal/server/network/ovn/ovn_nb_actions.go b/internal/server/network/ovn/ovn_nb_actions.go index d34070d9deb..20c492d4983 100644 --- a/internal/server/network/ovn/ovn_nb_actions.go +++ b/internal/server/network/ovn/ovn_nb_actions.go @@ -1115,14 +1115,28 @@ func (o *NB) LogicalSwitchPortAdd(switchName OVNSwitch, portName OVNSwitchPort, // LogicalSwitchPortIPs returns a list of IPs for a switch port. func (o *NB) LogicalSwitchPortIPs(portName OVNSwitchPort) ([]net.IP, error) { - addressesRaw, err := o.nbctl("--format=csv", "--no-headings", "--data=bare", "--column=addresses,dynamic_addresses", "find", "logical_switch_port", fmt.Sprintf("name=%s", string(portName))) + ctx := context.TODO() + + lsp := ovnNB.LogicalSwitchPort{ + Name: string(portName), + } + + err := o.client.Get(ctx, &lsp) if err != nil { + if err == ovsClient.ErrNotFound { + // Don't fail on missing port. + return []net.IP{}, nil + } + return nil, err } - addresses := strings.Split(strings.Replace(strings.TrimSpace(addressesRaw), ",", " ", 1), " ") - ips := make([]net.IP, 0) + addresses := lsp.Addresses + if lsp.DynamicAddresses != nil { + addresses = append(addresses, strings.Split(*lsp.DynamicAddresses, " ")...) + } + ips := make([]net.IP, 0) for _, address := range addresses { ip := net.ParseIP(address) if ip != nil {