On 11/26/24 3:37 PM, Felix Huettner via dev wrote:
> We already parse the networks of a port to the ovn_port struct, so there
> is no need to reference northbound.
> This is a prerequisite for later patches that use derived router ports.
>
> Acked-by: Lorenzo Bianconi <[email protected]>
> Signed-off-by: Felix Huettner <[email protected]>
> ---
Hi Felix,
> northd/northd.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/northd/northd.c b/northd/northd.c
> index 0fe15ac59..32a7c8509 100644
> --- a/northd/northd.c
> +++ b/northd/northd.c
> @@ -3139,10 +3139,25 @@ ovn_port_update_sbrec(struct ovsdb_idl_txn *ovnsb_txn,
> sbrec_port_binding_set_parent_port(op->sb, NULL);
> sbrec_port_binding_set_tag(op->sb, NULL, 0);
>
> + const struct lport_addresses *networks;
> + if (op->primary_port) {
> + networks = &op->primary_port->lrp_networks;
> + } else {
> + networks = &op->lrp_networks;
> + }
> struct ds s = DS_EMPTY_INITIALIZER;
> - ds_put_cstr(&s, op->nbrp->mac);
> - for (int i = 0; i < op->nbrp->n_networks; ++i) {
> - ds_put_format(&s, " %s", op->nbrp->networks[i]);
> + ds_put_cstr(&s, networks->ea_s);
> + for (int i = 0; i < networks->n_ipv4_addrs; ++i) {
Nit: size_t
Nit: ++i is not really needed
> + struct ipv4_netaddr addr = networks->ipv4_addrs[i];
> + ds_put_format(&s, " %s/%d", addr.addr_s, addr.plen);
> + }
> + /* We do not need the ipv6 LLA. Since it is last in the list we just
> + * skip it. */
Should we instead use
in6_is_lla(&op->lrp_networks.ipv6_addrs[j].addr)
?
If this has the potential of breaking things (e.g., when users
explicitly set a LLA into the LRP.networks - although, is that even
supported and OK?) we could add a helper to ovn-util.[hc]:
lrp_networks_to_string(const struct lport_addresses *, struct ds *)
Like that we don't make assumptions in northd.c about how addresses are
stored by the ovn-util module.
> + if (networks->n_ipv6_addrs > 1) {
> + for (int i = 0; i < networks->n_ipv6_addrs - 1; ++i) {
Same nits about size_t and ++i.
> + struct ipv6_netaddr addr = networks->ipv6_addrs[i];
> + ds_put_format(&s, " %s/%d", addr.addr_s, addr.plen);
> + }
> }
> const char *addresses = ds_cstr(&s);
> sbrec_port_binding_set_mac(op->sb, &addresses, 1);
Regards,
Dumitru
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev