If the logical router ports without 'peer' or the port named peer is not created, it is unnecessary to insert the ports into the southbound Port_Binding table.
Similarly, if logical switch ports of type 'router' don't contain 'router-port' value, these ports will not be inserted. This patch may optimize the process of 'build_ports'. Signed-off-by: nickcooper-zhangtonghao <nickcooper-zhangtong...@opencloud.tech> --- ovn/northd/ovn-northd.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c index efc915c..f85eb2e 100644 --- a/ovn/northd/ovn-northd.c +++ b/ovn/northd/ovn-northd.c @@ -770,6 +770,22 @@ join_logical_ports(struct northd_context *ctx, } } +static bool +ovn_port_is_insert(const struct ovn_port *op) +{ + if (op->nbsp) { + /* The logical switch port is connected to router*/ + if (!strcmp(op->nbsp->type, "router")) { + const char *router_port = smap_get(&op->nbsp->options, + "router-port"); + return router_port ? true : false; + } + return true; + } + /* Check the peer of the logical router port*/ + return op->peer ? true : false; +} + static void ovn_port_update_sbrec(const struct ovn_port *op) { @@ -869,11 +885,19 @@ build_ports(struct northd_context *ctx, struct hmap *datapaths, continue; } - op->sb = sbrec_port_binding_insert(ctx->ovnsb_txn); - ovn_port_update_sbrec(op); + /* If the logical router ports without 'peer' or the port named peer + * is not created, it is unnecessary to insert the ports into the + * southbound Port_Binding table. + * + * Similarly, if logical switch ports of type 'router' lack 'router-port' + * value, these ports will not be inserted. */ + if (ovn_port_is_insert(op)) { + op->sb = sbrec_port_binding_insert(ctx->ovnsb_txn); + ovn_port_update_sbrec(op); - sbrec_port_binding_set_logical_port(op->sb, op->key); - sbrec_port_binding_set_tunnel_key(op->sb, tunnel_key); + sbrec_port_binding_set_logical_port(op->sb, op->key); + sbrec_port_binding_set_tunnel_key(op->sb, tunnel_key); + } } /* Delete southbound records without northbound matches. */ -- 1.8.3.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev