diff mbox series

[ovs-dev,1/5] northd: Use the same UUID for SB representation of Static_Mac_Binding.

Message ID 20241018100930.826293-2-amusil@redhat.com
State Superseded
Headers show
Series Reuse UUID for SB rows if there is 1:1 mapping | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Ales Musil Oct. 18, 2024, 10:09 a.m. UTC
The NB Static_Mac_Binding has exactly one corresponding row in SB database.
Use the NB UUID for the SB representation which makes the processing easier
and the link between the rows is obvious at first glance.

Signed-off-by: Ales Musil <amusil@redhat.com>
---
 lib/automake.mk                |  2 --
 lib/static-mac-binding-index.c | 43 ----------------------------------
 lib/static-mac-binding-index.h | 27 ---------------------
 northd/en-northd.c             |  4 ----
 northd/inc-proc-northd.c       |  6 -----
 northd/northd.c                | 34 ++++++---------------------
 northd/northd.h                |  1 -
 tests/ovn-northd.at            |  2 ++
 8 files changed, 9 insertions(+), 110 deletions(-)
 delete mode 100644 lib/static-mac-binding-index.c
 delete mode 100644 lib/static-mac-binding-index.h

Comments

Mark Michelson Oct. 18, 2024, 8:17 p.m. UTC | #1
Acked-by: Mark Michelson <mmichels@redhat.com>

On 10/18/24 06:09, Ales Musil wrote:
> The NB Static_Mac_Binding has exactly one corresponding row in SB database.
> Use the NB UUID for the SB representation which makes the processing easier
> and the link between the rows is obvious at first glance.
> 
> Signed-off-by: Ales Musil <amusil@redhat.com>
> ---
>   lib/automake.mk                |  2 --
>   lib/static-mac-binding-index.c | 43 ----------------------------------
>   lib/static-mac-binding-index.h | 27 ---------------------
>   northd/en-northd.c             |  4 ----
>   northd/inc-proc-northd.c       |  6 -----
>   northd/northd.c                | 34 ++++++---------------------
>   northd/northd.h                |  1 -
>   tests/ovn-northd.at            |  2 ++
>   8 files changed, 9 insertions(+), 110 deletions(-)
>   delete mode 100644 lib/static-mac-binding-index.c
>   delete mode 100644 lib/static-mac-binding-index.h
> 
> diff --git a/lib/automake.mk b/lib/automake.mk
> index b69e854b0..25e516406 100644
> --- a/lib/automake.mk
> +++ b/lib/automake.mk
> @@ -44,8 +44,6 @@ lib_libovn_la_SOURCES = \
>   	lib/inc-proc-eng.h \
>   	lib/lb.c \
>   	lib/lb.h \
> -	lib/static-mac-binding-index.c \
> -	lib/static-mac-binding-index.h \
>   	lib/stopwatch-names.h \
>   	lib/vif-plug-provider.h \
>   	lib/vif-plug-provider.c \
> diff --git a/lib/static-mac-binding-index.c b/lib/static-mac-binding-index.c
> deleted file mode 100644
> index fecc9b74f..000000000
> --- a/lib/static-mac-binding-index.c
> +++ /dev/null
> @@ -1,43 +0,0 @@
> -/* Copyright (c) 2021
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at:
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - */
> -
> -#include <config.h>
> -
> -#include "lib/static-mac-binding-index.h"
> -#include "lib/ovn-sb-idl.h"
> -
> -struct ovsdb_idl_index *
> -static_mac_binding_index_create(struct ovsdb_idl *idl)
> -{
> -    return ovsdb_idl_index_create2(idl,
> -                                   &sbrec_static_mac_binding_col_logical_port,
> -                                   &sbrec_static_mac_binding_col_ip);
> -}
> -
> -const struct sbrec_static_mac_binding *
> -static_mac_binding_lookup(struct ovsdb_idl_index *smb_index,
> -                          const char *logical_port, const char *ip)
> -{
> -    struct sbrec_static_mac_binding *target =
> -        sbrec_static_mac_binding_index_init_row(smb_index);
> -    sbrec_static_mac_binding_index_set_logical_port(target, logical_port);
> -    sbrec_static_mac_binding_index_set_ip(target, ip);
> -
> -    struct sbrec_static_mac_binding *smb =
> -        sbrec_static_mac_binding_index_find(smb_index, target);
> -    sbrec_static_mac_binding_index_destroy_row(target);
> -
> -    return smb;
> -}
> diff --git a/lib/static-mac-binding-index.h b/lib/static-mac-binding-index.h
> deleted file mode 100644
> index 3d4ff06a2..000000000
> --- a/lib/static-mac-binding-index.h
> +++ /dev/null
> @@ -1,27 +0,0 @@
> -/* Copyright (c) 2021
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at:
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - */
> -
> -#ifndef OVN_STATIC_MAC_BINDING_INDEX_H
> -#define OVN_STATIC_MAC_BINDING_INDEX_H 1
> -
> -struct ovsdb_idl;
> -
> -struct ovsdb_idl_index *static_mac_binding_index_create(struct ovsdb_idl *);
> -const struct sbrec_static_mac_binding *static_mac_binding_lookup(
> -    struct ovsdb_idl_index *smb_index,
> -    const char *logical_port,
> -    const char *ip);
> -
> -#endif /* lib/static-mac-binding-index.h */
> diff --git a/northd/en-northd.c b/northd/en-northd.c
> index 24ed31517..97e90b832 100644
> --- a/northd/en-northd.c
> +++ b/northd/en-northd.c
> @@ -57,10 +57,6 @@ northd_get_input_data(struct engine_node *node,
>           engine_ovsdb_node_get_index(
>               engine_get_input("SB_ip_multicast", node),
>               "sbrec_ip_mcast_by_dp");
> -    input_data->sbrec_static_mac_binding_by_lport_ip =
> -        engine_ovsdb_node_get_index(
> -            engine_get_input("SB_static_mac_binding", node),
> -            "sbrec_static_mac_binding_by_lport_ip");
>       input_data->sbrec_fdb_by_dp_and_port =
>           engine_ovsdb_node_get_index(
>               engine_get_input("SB_fdb", node),
> diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
> index 8c834facb..480100d3c 100644
> --- a/northd/inc-proc-northd.c
> +++ b/northd/inc-proc-northd.c
> @@ -20,7 +20,6 @@
>   
>   #include "chassis-index.h"
>   #include "ip-mcast-index.h"
> -#include "static-mac-binding-index.h"
>   #include "lib/inc-proc-eng.h"
>   #include "lib/mac-binding-index.h"
>   #include "lib/ovn-nb-idl.h"
> @@ -359,8 +358,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
>                            ip_mcast_index_create(sb->idl);
>       struct ovsdb_idl_index *sbrec_chassis_by_hostname =
>           chassis_hostname_index_create(sb->idl);
> -    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip
> -        = static_mac_binding_index_create(sb->idl);
>       struct ovsdb_idl_index *sbrec_mac_binding_by_datapath
>           = mac_binding_by_datapath_index_create(sb->idl);
>       struct ovsdb_idl_index *fdb_by_dp_key =
> @@ -383,9 +380,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
>       engine_ovsdb_node_add_index(&en_sb_ip_multicast,
>                                   "sbrec_ip_mcast_by_dp",
>                                   sbrec_ip_mcast_by_dp);
> -    engine_ovsdb_node_add_index(&en_sb_static_mac_binding,
> -                                "sbrec_static_mac_binding_by_lport_ip",
> -                                sbrec_static_mac_binding_by_lport_ip);
>       engine_ovsdb_node_add_index(&en_sb_mac_binding,
>                                   "sbrec_mac_binding_by_datapath",
>                                   sbrec_mac_binding_by_datapath);
> diff --git a/northd/northd.c b/northd/northd.c
> index 0fe15ac59..fb34d0231 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -34,7 +34,6 @@
>   #include "lb.h"
>   #include "lib/chassis-index.h"
>   #include "lib/ip-mcast-index.h"
> -#include "lib/static-mac-binding-index.h"
>   #include "lib/copp.h"
>   #include "lib/mcast-group-index.h"
>   #include "lib/ovn-l7.h"
> @@ -18560,29 +18559,11 @@ build_mcast_groups(const struct sbrec_igmp_group_table *sbrec_igmp_group_table,
>       }
>   }
>   
> -static const struct nbrec_static_mac_binding *
> -static_mac_binding_by_port_ip(
> -    const struct nbrec_static_mac_binding_table *nbrec_static_mb_table,
> -    const char *logical_port, const char *ip)
> -{
> -    const struct nbrec_static_mac_binding *nb_smb = NULL;
> -
> -    NBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH (nb_smb, nbrec_static_mb_table) {
> -        if (!strcmp(nb_smb->logical_port, logical_port) &&
> -            !strcmp(nb_smb->ip, ip)) {
> -            break;
> -        }
> -    }
> -
> -    return nb_smb;
> -}
> -
>   static void
>   build_static_mac_binding_table(
>       struct ovsdb_idl_txn *ovnsb_txn,
>       const struct nbrec_static_mac_binding_table *nbrec_static_mb_table,
>       const struct sbrec_static_mac_binding_table *sbrec_static_mb_table,
> -    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip,
>       struct hmap *lr_ports)
>   {
>       /* Cleanup SB Static_MAC_Binding entries which do not have corresponding
> @@ -18592,9 +18573,8 @@ build_static_mac_binding_table(
>       const struct sbrec_static_mac_binding *sb_smb;
>       SBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH_SAFE (sb_smb,
>           sbrec_static_mb_table) {
> -        nb_smb = static_mac_binding_by_port_ip(nbrec_static_mb_table,
> -                                               sb_smb->logical_port,
> -                                               sb_smb->ip);
> +        nb_smb = nbrec_static_mac_binding_table_get_for_uuid(
> +            nbrec_static_mb_table, &sb_smb->header_.uuid);
>           if (!nb_smb) {
>               sbrec_static_mac_binding_delete(sb_smb);
>               continue;
> @@ -18614,13 +18594,14 @@ build_static_mac_binding_table(
>           if (op && op->nbrp) {
>               struct ovn_datapath *od = op->od;
>               if (od && od->sb) {
> +                const struct uuid *nb_uuid = &nb_smb->header_.uuid;
>                   const struct sbrec_static_mac_binding *mb =
> -                    static_mac_binding_lookup(
> -                        sbrec_static_mac_binding_by_lport_ip,
> -                        nb_smb->logical_port, nb_smb->ip);
> +                    sbrec_static_mac_binding_table_get_for_uuid(
> +                        sbrec_static_mb_table, nb_uuid);
>                   if (!mb) {
>                       /* Create new entry */
> -                    mb = sbrec_static_mac_binding_insert(ovnsb_txn);
> +                    mb = sbrec_static_mac_binding_insert_persist_uuid(
> +                        ovnsb_txn, nb_uuid);
>                       sbrec_static_mac_binding_set_logical_port(
>                           mb, nb_smb->logical_port);
>                       sbrec_static_mac_binding_set_ip(mb, nb_smb->ip);
> @@ -18900,7 +18881,6 @@ ovnnb_db_run(struct northd_input *input_data,
>       build_static_mac_binding_table(ovnsb_txn,
>           input_data->nbrec_static_mac_binding_table,
>           input_data->sbrec_static_mac_binding_table,
> -        input_data->sbrec_static_mac_binding_by_lport_ip,
>           &data->lr_ports);
>       stopwatch_stop(BUILD_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
>       stopwatch_start(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
> diff --git a/northd/northd.h b/northd/northd.h
> index 8f76d642d..995af65bc 100644
> --- a/northd/northd.h
> +++ b/northd/northd.h
> @@ -68,7 +68,6 @@ struct northd_input {
>       struct ovsdb_idl_index *sbrec_chassis_by_hostname;
>       struct ovsdb_idl_index *sbrec_ha_chassis_grp_by_name;
>       struct ovsdb_idl_index *sbrec_ip_mcast_by_dp;
> -    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip;
>       struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port;
>   };
>   
> diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> index d6a8c4640..bcee2d231 100644
> --- a/tests/ovn-northd.at
> +++ b/tests/ovn-northd.at
> @@ -8076,7 +8076,9 @@ ovn-nbctl static-mac-binding-add lr0-p0 192.168.10.100 00:00:22:33:44:55
>   
>   wait_row_count nb:Static_MAC_Binding 2 logical_port=lr0-p0
>   wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.10 mac="00\:00\:11\:22\:33\:44"
> +check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10
>   wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.100 mac="00\:00\:22\:33\:44\:55"
> +check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100
>   
>   ovn-nbctl static-mac-binding-add lr0-p1 10.0.0.10 00:00:33:44:55:66
>   wait_row_count nb:Static_MAC_Binding 1 logical_port=lr0-p1
Numan Siddique Nov. 13, 2024, 4:29 p.m. UTC | #2
On Fri, Oct 18, 2024 at 4:18 PM Mark Michelson <mmichels@redhat.com> wrote:
>
> Acked-by: Mark Michelson <mmichels@redhat.com>
>
> On 10/18/24 06:09, Ales Musil wrote:
> > The NB Static_Mac_Binding has exactly one corresponding row in SB database.
> > Use the NB UUID for the SB representation which makes the processing easier
> > and the link between the rows is obvious at first glance.
> >
> > Signed-off-by: Ales Musil <amusil@redhat.com>

Acked-by: Numan Siddique <numans@ovn.org>

Numan

> > ---
> >   lib/automake.mk                |  2 --
> >   lib/static-mac-binding-index.c | 43 ----------------------------------
> >   lib/static-mac-binding-index.h | 27 ---------------------
> >   northd/en-northd.c             |  4 ----
> >   northd/inc-proc-northd.c       |  6 -----
> >   northd/northd.c                | 34 ++++++---------------------
> >   northd/northd.h                |  1 -
> >   tests/ovn-northd.at            |  2 ++
> >   8 files changed, 9 insertions(+), 110 deletions(-)
> >   delete mode 100644 lib/static-mac-binding-index.c
> >   delete mode 100644 lib/static-mac-binding-index.h
> >
> > diff --git a/lib/automake.mk b/lib/automake.mk
> > index b69e854b0..25e516406 100644
> > --- a/lib/automake.mk
> > +++ b/lib/automake.mk
> > @@ -44,8 +44,6 @@ lib_libovn_la_SOURCES = \
> >       lib/inc-proc-eng.h \
> >       lib/lb.c \
> >       lib/lb.h \
> > -     lib/static-mac-binding-index.c \
> > -     lib/static-mac-binding-index.h \
> >       lib/stopwatch-names.h \
> >       lib/vif-plug-provider.h \
> >       lib/vif-plug-provider.c \
> > diff --git a/lib/static-mac-binding-index.c b/lib/static-mac-binding-index.c
> > deleted file mode 100644
> > index fecc9b74f..000000000
> > --- a/lib/static-mac-binding-index.c
> > +++ /dev/null
> > @@ -1,43 +0,0 @@
> > -/* Copyright (c) 2021
> > - *
> > - * Licensed under the Apache License, Version 2.0 (the "License");
> > - * you may not use this file except in compliance with the License.
> > - * You may obtain a copy of the License at:
> > - *
> > - *     http://www.apache.org/licenses/LICENSE-2.0
> > - *
> > - * Unless required by applicable law or agreed to in writing, software
> > - * distributed under the License is distributed on an "AS IS" BASIS,
> > - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > - * See the License for the specific language governing permissions and
> > - * limitations under the License.
> > - */
> > -
> > -#include <config.h>
> > -
> > -#include "lib/static-mac-binding-index.h"
> > -#include "lib/ovn-sb-idl.h"
> > -
> > -struct ovsdb_idl_index *
> > -static_mac_binding_index_create(struct ovsdb_idl *idl)
> > -{
> > -    return ovsdb_idl_index_create2(idl,
> > -                                   &sbrec_static_mac_binding_col_logical_port,
> > -                                   &sbrec_static_mac_binding_col_ip);
> > -}
> > -
> > -const struct sbrec_static_mac_binding *
> > -static_mac_binding_lookup(struct ovsdb_idl_index *smb_index,
> > -                          const char *logical_port, const char *ip)
> > -{
> > -    struct sbrec_static_mac_binding *target =
> > -        sbrec_static_mac_binding_index_init_row(smb_index);
> > -    sbrec_static_mac_binding_index_set_logical_port(target, logical_port);
> > -    sbrec_static_mac_binding_index_set_ip(target, ip);
> > -
> > -    struct sbrec_static_mac_binding *smb =
> > -        sbrec_static_mac_binding_index_find(smb_index, target);
> > -    sbrec_static_mac_binding_index_destroy_row(target);
> > -
> > -    return smb;
> > -}
> > diff --git a/lib/static-mac-binding-index.h b/lib/static-mac-binding-index.h
> > deleted file mode 100644
> > index 3d4ff06a2..000000000
> > --- a/lib/static-mac-binding-index.h
> > +++ /dev/null
> > @@ -1,27 +0,0 @@
> > -/* Copyright (c) 2021
> > - *
> > - * Licensed under the Apache License, Version 2.0 (the "License");
> > - * you may not use this file except in compliance with the License.
> > - * You may obtain a copy of the License at:
> > - *
> > - *     http://www.apache.org/licenses/LICENSE-2.0
> > - *
> > - * Unless required by applicable law or agreed to in writing, software
> > - * distributed under the License is distributed on an "AS IS" BASIS,
> > - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> > - * See the License for the specific language governing permissions and
> > - * limitations under the License.
> > - */
> > -
> > -#ifndef OVN_STATIC_MAC_BINDING_INDEX_H
> > -#define OVN_STATIC_MAC_BINDING_INDEX_H 1
> > -
> > -struct ovsdb_idl;
> > -
> > -struct ovsdb_idl_index *static_mac_binding_index_create(struct ovsdb_idl *);
> > -const struct sbrec_static_mac_binding *static_mac_binding_lookup(
> > -    struct ovsdb_idl_index *smb_index,
> > -    const char *logical_port,
> > -    const char *ip);
> > -
> > -#endif /* lib/static-mac-binding-index.h */
> > diff --git a/northd/en-northd.c b/northd/en-northd.c
> > index 24ed31517..97e90b832 100644
> > --- a/northd/en-northd.c
> > +++ b/northd/en-northd.c
> > @@ -57,10 +57,6 @@ northd_get_input_data(struct engine_node *node,
> >           engine_ovsdb_node_get_index(
> >               engine_get_input("SB_ip_multicast", node),
> >               "sbrec_ip_mcast_by_dp");
> > -    input_data->sbrec_static_mac_binding_by_lport_ip =
> > -        engine_ovsdb_node_get_index(
> > -            engine_get_input("SB_static_mac_binding", node),
> > -            "sbrec_static_mac_binding_by_lport_ip");
> >       input_data->sbrec_fdb_by_dp_and_port =
> >           engine_ovsdb_node_get_index(
> >               engine_get_input("SB_fdb", node),
> > diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
> > index 8c834facb..480100d3c 100644
> > --- a/northd/inc-proc-northd.c
> > +++ b/northd/inc-proc-northd.c
> > @@ -20,7 +20,6 @@
> >
> >   #include "chassis-index.h"
> >   #include "ip-mcast-index.h"
> > -#include "static-mac-binding-index.h"
> >   #include "lib/inc-proc-eng.h"
> >   #include "lib/mac-binding-index.h"
> >   #include "lib/ovn-nb-idl.h"
> > @@ -359,8 +358,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
> >                            ip_mcast_index_create(sb->idl);
> >       struct ovsdb_idl_index *sbrec_chassis_by_hostname =
> >           chassis_hostname_index_create(sb->idl);
> > -    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip
> > -        = static_mac_binding_index_create(sb->idl);
> >       struct ovsdb_idl_index *sbrec_mac_binding_by_datapath
> >           = mac_binding_by_datapath_index_create(sb->idl);
> >       struct ovsdb_idl_index *fdb_by_dp_key =
> > @@ -383,9 +380,6 @@ void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
> >       engine_ovsdb_node_add_index(&en_sb_ip_multicast,
> >                                   "sbrec_ip_mcast_by_dp",
> >                                   sbrec_ip_mcast_by_dp);
> > -    engine_ovsdb_node_add_index(&en_sb_static_mac_binding,
> > -                                "sbrec_static_mac_binding_by_lport_ip",
> > -                                sbrec_static_mac_binding_by_lport_ip);
> >       engine_ovsdb_node_add_index(&en_sb_mac_binding,
> >                                   "sbrec_mac_binding_by_datapath",
> >                                   sbrec_mac_binding_by_datapath);
> > diff --git a/northd/northd.c b/northd/northd.c
> > index 0fe15ac59..fb34d0231 100644
> > --- a/northd/northd.c
> > +++ b/northd/northd.c
> > @@ -34,7 +34,6 @@
> >   #include "lb.h"
> >   #include "lib/chassis-index.h"
> >   #include "lib/ip-mcast-index.h"
> > -#include "lib/static-mac-binding-index.h"
> >   #include "lib/copp.h"
> >   #include "lib/mcast-group-index.h"
> >   #include "lib/ovn-l7.h"
> > @@ -18560,29 +18559,11 @@ build_mcast_groups(const struct sbrec_igmp_group_table *sbrec_igmp_group_table,
> >       }
> >   }
> >
> > -static const struct nbrec_static_mac_binding *
> > -static_mac_binding_by_port_ip(
> > -    const struct nbrec_static_mac_binding_table *nbrec_static_mb_table,
> > -    const char *logical_port, const char *ip)
> > -{
> > -    const struct nbrec_static_mac_binding *nb_smb = NULL;
> > -
> > -    NBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH (nb_smb, nbrec_static_mb_table) {
> > -        if (!strcmp(nb_smb->logical_port, logical_port) &&
> > -            !strcmp(nb_smb->ip, ip)) {
> > -            break;
> > -        }
> > -    }
> > -
> > -    return nb_smb;
> > -}
> > -
> >   static void
> >   build_static_mac_binding_table(
> >       struct ovsdb_idl_txn *ovnsb_txn,
> >       const struct nbrec_static_mac_binding_table *nbrec_static_mb_table,
> >       const struct sbrec_static_mac_binding_table *sbrec_static_mb_table,
> > -    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip,
> >       struct hmap *lr_ports)
> >   {
> >       /* Cleanup SB Static_MAC_Binding entries which do not have corresponding
> > @@ -18592,9 +18573,8 @@ build_static_mac_binding_table(
> >       const struct sbrec_static_mac_binding *sb_smb;
> >       SBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH_SAFE (sb_smb,
> >           sbrec_static_mb_table) {
> > -        nb_smb = static_mac_binding_by_port_ip(nbrec_static_mb_table,
> > -                                               sb_smb->logical_port,
> > -                                               sb_smb->ip);
> > +        nb_smb = nbrec_static_mac_binding_table_get_for_uuid(
> > +            nbrec_static_mb_table, &sb_smb->header_.uuid);
> >           if (!nb_smb) {
> >               sbrec_static_mac_binding_delete(sb_smb);
> >               continue;
> > @@ -18614,13 +18594,14 @@ build_static_mac_binding_table(
> >           if (op && op->nbrp) {
> >               struct ovn_datapath *od = op->od;
> >               if (od && od->sb) {
> > +                const struct uuid *nb_uuid = &nb_smb->header_.uuid;
> >                   const struct sbrec_static_mac_binding *mb =
> > -                    static_mac_binding_lookup(
> > -                        sbrec_static_mac_binding_by_lport_ip,
> > -                        nb_smb->logical_port, nb_smb->ip);
> > +                    sbrec_static_mac_binding_table_get_for_uuid(
> > +                        sbrec_static_mb_table, nb_uuid);
> >                   if (!mb) {
> >                       /* Create new entry */
> > -                    mb = sbrec_static_mac_binding_insert(ovnsb_txn);
> > +                    mb = sbrec_static_mac_binding_insert_persist_uuid(
> > +                        ovnsb_txn, nb_uuid);
> >                       sbrec_static_mac_binding_set_logical_port(
> >                           mb, nb_smb->logical_port);
> >                       sbrec_static_mac_binding_set_ip(mb, nb_smb->ip);
> > @@ -18900,7 +18881,6 @@ ovnnb_db_run(struct northd_input *input_data,
> >       build_static_mac_binding_table(ovnsb_txn,
> >           input_data->nbrec_static_mac_binding_table,
> >           input_data->sbrec_static_mac_binding_table,
> > -        input_data->sbrec_static_mac_binding_by_lport_ip,
> >           &data->lr_ports);
> >       stopwatch_stop(BUILD_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
> >       stopwatch_start(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
> > diff --git a/northd/northd.h b/northd/northd.h
> > index 8f76d642d..995af65bc 100644
> > --- a/northd/northd.h
> > +++ b/northd/northd.h
> > @@ -68,7 +68,6 @@ struct northd_input {
> >       struct ovsdb_idl_index *sbrec_chassis_by_hostname;
> >       struct ovsdb_idl_index *sbrec_ha_chassis_grp_by_name;
> >       struct ovsdb_idl_index *sbrec_ip_mcast_by_dp;
> > -    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip;
> >       struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port;
> >   };
> >
> > diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
> > index d6a8c4640..bcee2d231 100644
> > --- a/tests/ovn-northd.at
> > +++ b/tests/ovn-northd.at
> > @@ -8076,7 +8076,9 @@ ovn-nbctl static-mac-binding-add lr0-p0 192.168.10.100 00:00:22:33:44:55
> >
> >   wait_row_count nb:Static_MAC_Binding 2 logical_port=lr0-p0
> >   wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.10 mac="00\:00\:11\:22\:33\:44"
> > +check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10
> >   wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.100 mac="00\:00\:22\:33\:44\:55"
> > +check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100
> >
> >   ovn-nbctl static-mac-binding-add lr0-p1 10.0.0.10 00:00:33:44:55:66
> >   wait_row_count nb:Static_MAC_Binding 1 logical_port=lr0-p1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

diff --git a/lib/automake.mk b/lib/automake.mk
index b69e854b0..25e516406 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -44,8 +44,6 @@  lib_libovn_la_SOURCES = \
 	lib/inc-proc-eng.h \
 	lib/lb.c \
 	lib/lb.h \
-	lib/static-mac-binding-index.c \
-	lib/static-mac-binding-index.h \
 	lib/stopwatch-names.h \
 	lib/vif-plug-provider.h \
 	lib/vif-plug-provider.c \
diff --git a/lib/static-mac-binding-index.c b/lib/static-mac-binding-index.c
deleted file mode 100644
index fecc9b74f..000000000
--- a/lib/static-mac-binding-index.c
+++ /dev/null
@@ -1,43 +0,0 @@ 
-/* Copyright (c) 2021
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <config.h>
-
-#include "lib/static-mac-binding-index.h"
-#include "lib/ovn-sb-idl.h"
-
-struct ovsdb_idl_index *
-static_mac_binding_index_create(struct ovsdb_idl *idl)
-{
-    return ovsdb_idl_index_create2(idl,
-                                   &sbrec_static_mac_binding_col_logical_port,
-                                   &sbrec_static_mac_binding_col_ip);
-}
-
-const struct sbrec_static_mac_binding *
-static_mac_binding_lookup(struct ovsdb_idl_index *smb_index,
-                          const char *logical_port, const char *ip)
-{
-    struct sbrec_static_mac_binding *target =
-        sbrec_static_mac_binding_index_init_row(smb_index);
-    sbrec_static_mac_binding_index_set_logical_port(target, logical_port);
-    sbrec_static_mac_binding_index_set_ip(target, ip);
-
-    struct sbrec_static_mac_binding *smb =
-        sbrec_static_mac_binding_index_find(smb_index, target);
-    sbrec_static_mac_binding_index_destroy_row(target);
-
-    return smb;
-}
diff --git a/lib/static-mac-binding-index.h b/lib/static-mac-binding-index.h
deleted file mode 100644
index 3d4ff06a2..000000000
--- a/lib/static-mac-binding-index.h
+++ /dev/null
@@ -1,27 +0,0 @@ 
-/* Copyright (c) 2021
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef OVN_STATIC_MAC_BINDING_INDEX_H
-#define OVN_STATIC_MAC_BINDING_INDEX_H 1
-
-struct ovsdb_idl;
-
-struct ovsdb_idl_index *static_mac_binding_index_create(struct ovsdb_idl *);
-const struct sbrec_static_mac_binding *static_mac_binding_lookup(
-    struct ovsdb_idl_index *smb_index,
-    const char *logical_port,
-    const char *ip);
-
-#endif /* lib/static-mac-binding-index.h */
diff --git a/northd/en-northd.c b/northd/en-northd.c
index 24ed31517..97e90b832 100644
--- a/northd/en-northd.c
+++ b/northd/en-northd.c
@@ -57,10 +57,6 @@  northd_get_input_data(struct engine_node *node,
         engine_ovsdb_node_get_index(
             engine_get_input("SB_ip_multicast", node),
             "sbrec_ip_mcast_by_dp");
-    input_data->sbrec_static_mac_binding_by_lport_ip =
-        engine_ovsdb_node_get_index(
-            engine_get_input("SB_static_mac_binding", node),
-            "sbrec_static_mac_binding_by_lport_ip");
     input_data->sbrec_fdb_by_dp_and_port =
         engine_ovsdb_node_get_index(
             engine_get_input("SB_fdb", node),
diff --git a/northd/inc-proc-northd.c b/northd/inc-proc-northd.c
index 8c834facb..480100d3c 100644
--- a/northd/inc-proc-northd.c
+++ b/northd/inc-proc-northd.c
@@ -20,7 +20,6 @@ 
 
 #include "chassis-index.h"
 #include "ip-mcast-index.h"
-#include "static-mac-binding-index.h"
 #include "lib/inc-proc-eng.h"
 #include "lib/mac-binding-index.h"
 #include "lib/ovn-nb-idl.h"
@@ -359,8 +358,6 @@  void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
                          ip_mcast_index_create(sb->idl);
     struct ovsdb_idl_index *sbrec_chassis_by_hostname =
         chassis_hostname_index_create(sb->idl);
-    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip
-        = static_mac_binding_index_create(sb->idl);
     struct ovsdb_idl_index *sbrec_mac_binding_by_datapath
         = mac_binding_by_datapath_index_create(sb->idl);
     struct ovsdb_idl_index *fdb_by_dp_key =
@@ -383,9 +380,6 @@  void inc_proc_northd_init(struct ovsdb_idl_loop *nb,
     engine_ovsdb_node_add_index(&en_sb_ip_multicast,
                                 "sbrec_ip_mcast_by_dp",
                                 sbrec_ip_mcast_by_dp);
-    engine_ovsdb_node_add_index(&en_sb_static_mac_binding,
-                                "sbrec_static_mac_binding_by_lport_ip",
-                                sbrec_static_mac_binding_by_lport_ip);
     engine_ovsdb_node_add_index(&en_sb_mac_binding,
                                 "sbrec_mac_binding_by_datapath",
                                 sbrec_mac_binding_by_datapath);
diff --git a/northd/northd.c b/northd/northd.c
index 0fe15ac59..fb34d0231 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -34,7 +34,6 @@ 
 #include "lb.h"
 #include "lib/chassis-index.h"
 #include "lib/ip-mcast-index.h"
-#include "lib/static-mac-binding-index.h"
 #include "lib/copp.h"
 #include "lib/mcast-group-index.h"
 #include "lib/ovn-l7.h"
@@ -18560,29 +18559,11 @@  build_mcast_groups(const struct sbrec_igmp_group_table *sbrec_igmp_group_table,
     }
 }
 
-static const struct nbrec_static_mac_binding *
-static_mac_binding_by_port_ip(
-    const struct nbrec_static_mac_binding_table *nbrec_static_mb_table,
-    const char *logical_port, const char *ip)
-{
-    const struct nbrec_static_mac_binding *nb_smb = NULL;
-
-    NBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH (nb_smb, nbrec_static_mb_table) {
-        if (!strcmp(nb_smb->logical_port, logical_port) &&
-            !strcmp(nb_smb->ip, ip)) {
-            break;
-        }
-    }
-
-    return nb_smb;
-}
-
 static void
 build_static_mac_binding_table(
     struct ovsdb_idl_txn *ovnsb_txn,
     const struct nbrec_static_mac_binding_table *nbrec_static_mb_table,
     const struct sbrec_static_mac_binding_table *sbrec_static_mb_table,
-    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip,
     struct hmap *lr_ports)
 {
     /* Cleanup SB Static_MAC_Binding entries which do not have corresponding
@@ -18592,9 +18573,8 @@  build_static_mac_binding_table(
     const struct sbrec_static_mac_binding *sb_smb;
     SBREC_STATIC_MAC_BINDING_TABLE_FOR_EACH_SAFE (sb_smb,
         sbrec_static_mb_table) {
-        nb_smb = static_mac_binding_by_port_ip(nbrec_static_mb_table,
-                                               sb_smb->logical_port,
-                                               sb_smb->ip);
+        nb_smb = nbrec_static_mac_binding_table_get_for_uuid(
+            nbrec_static_mb_table, &sb_smb->header_.uuid);
         if (!nb_smb) {
             sbrec_static_mac_binding_delete(sb_smb);
             continue;
@@ -18614,13 +18594,14 @@  build_static_mac_binding_table(
         if (op && op->nbrp) {
             struct ovn_datapath *od = op->od;
             if (od && od->sb) {
+                const struct uuid *nb_uuid = &nb_smb->header_.uuid;
                 const struct sbrec_static_mac_binding *mb =
-                    static_mac_binding_lookup(
-                        sbrec_static_mac_binding_by_lport_ip,
-                        nb_smb->logical_port, nb_smb->ip);
+                    sbrec_static_mac_binding_table_get_for_uuid(
+                        sbrec_static_mb_table, nb_uuid);
                 if (!mb) {
                     /* Create new entry */
-                    mb = sbrec_static_mac_binding_insert(ovnsb_txn);
+                    mb = sbrec_static_mac_binding_insert_persist_uuid(
+                        ovnsb_txn, nb_uuid);
                     sbrec_static_mac_binding_set_logical_port(
                         mb, nb_smb->logical_port);
                     sbrec_static_mac_binding_set_ip(mb, nb_smb->ip);
@@ -18900,7 +18881,6 @@  ovnnb_db_run(struct northd_input *input_data,
     build_static_mac_binding_table(ovnsb_txn,
         input_data->nbrec_static_mac_binding_table,
         input_data->sbrec_static_mac_binding_table,
-        input_data->sbrec_static_mac_binding_by_lport_ip,
         &data->lr_ports);
     stopwatch_stop(BUILD_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
     stopwatch_start(CLEAR_LFLOWS_CTX_STOPWATCH_NAME, time_msec());
diff --git a/northd/northd.h b/northd/northd.h
index 8f76d642d..995af65bc 100644
--- a/northd/northd.h
+++ b/northd/northd.h
@@ -68,7 +68,6 @@  struct northd_input {
     struct ovsdb_idl_index *sbrec_chassis_by_hostname;
     struct ovsdb_idl_index *sbrec_ha_chassis_grp_by_name;
     struct ovsdb_idl_index *sbrec_ip_mcast_by_dp;
-    struct ovsdb_idl_index *sbrec_static_mac_binding_by_lport_ip;
     struct ovsdb_idl_index *sbrec_fdb_by_dp_and_port;
 };
 
diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at
index d6a8c4640..bcee2d231 100644
--- a/tests/ovn-northd.at
+++ b/tests/ovn-northd.at
@@ -8076,7 +8076,9 @@  ovn-nbctl static-mac-binding-add lr0-p0 192.168.10.100 00:00:22:33:44:55
 
 wait_row_count nb:Static_MAC_Binding 2 logical_port=lr0-p0
 wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.10 mac="00\:00\:11\:22\:33\:44"
+check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.10
 wait_row_count Static_MAC_Binding 1 logical_port=lr0-p0 ip=192.168.10.100 mac="00\:00\:22\:33\:44\:55"
+check_column "$(fetch_column nb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100)" sb:Static_MAC_Binding _uuid logical_port=lr0-p0 ip=192.168.10.100
 
 ovn-nbctl static-mac-binding-add lr0-p1 10.0.0.10 00:00:33:44:55:66
 wait_row_count nb:Static_MAC_Binding 1 logical_port=lr0-p1