Thanks Dumitru,
Acked-by: Mark Michelson <mmich...@redhat.com>
I actually already pushed the patch to main as well, because for some
reason I thought I had already acked the patch. Hopefully that doesn't
cause an issue.
On 4/19/22 11:50, Dumitru Ceara wrote:
There's no need to always lookup a port's peer in ovn_port_get_peer().
Just use what was already stored in op->peer instead.
Also, factor out addition of router ports to a logical switch's
ovn_datapath and use x2nrealloc().
Signed-off-by: Dumitru Ceara <dce...@redhat.com>
---
v2: Changed patch according to Mark's review:
- modify ovn_port_get_peer() to check if op->peer is already set.
- rephrased the commit log accordingly.
---
northd/northd.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/northd/northd.c b/northd/northd.c
index bcd36bbaa..530bbc61b 100644
--- a/northd/northd.c
+++ b/northd/northd.c
@@ -601,6 +601,7 @@ struct ovn_datapath {
/* Logical switch data. */
struct ovn_port **router_ports;
size_t n_router_ports;
+ size_t n_allocated_router_ports;
struct hmap port_tnlids;
uint32_t port_key_hint;
@@ -1081,6 +1082,17 @@ ovn_datapath_from_sbrec(const struct hmap *datapaths,
return NULL;
}
+static void
+ovn_datapath_add_router_port(struct ovn_datapath *od, struct ovn_port *op)
+{
+ if (od->n_router_ports == od->n_allocated_router_ports) {
+ od->router_ports = x2nrealloc(od->router_ports,
+ &od->n_allocated_router_ports,
+ sizeof *od->router_ports);
+ }
+ od->router_ports[od->n_router_ports++] = op;
+}
+
static bool
lrouter_is_enabled(const struct nbrec_logical_router *lrouter)
{
@@ -1815,6 +1827,10 @@ ovn_port_get_peer(const struct hmap *ports, struct
ovn_port *op)
return NULL;
}
+ if (op->peer) {
+ return op->peer;
+ }
+
const char *peer_name = smap_get(&op->nbsp->options, "router-port");
if (!peer_name) {
return NULL;
@@ -2657,12 +2673,9 @@ join_logical_ports(struct northd_input *input_data,
continue;
}
+ ovn_datapath_add_router_port(op->od, op);
peer->peer = op;
op->peer = peer;
- op->od->router_ports = xrealloc(
- op->od->router_ports,
- sizeof *op->od->router_ports * (op->od->n_router_ports + 1));
- op->od->router_ports[op->od->n_router_ports++] = op;
/* Fill op->lsp_addrs for op->nbsp->addresses[] with
* contents "router", which was skipped in the loop above. */
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev