diff mbox series

[ovs-dev,v2,01/32] northd: Set southbound mac from lrp_networks.

Message ID 4f9f431b1ab525f733d8ea4a4c8055c098a5b0a1.1730713432.git.felix.huettner@stackit.cloud
State Superseded
Headers show
Series OVN Fabric integration | 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 fail github build: failed

Commit Message

Felix Huettner Nov. 4, 2024, 11:03 a.m. UTC
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.

Signed-off-by: Felix Huettner <felix.huettner@stackit.cloud>
---
 northd/northd.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

Comments

Lorenzo Bianconi Nov. 13, 2024, 5:47 p.m. UTC | #1
> 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.
> 
> Signed-off-by: Felix Huettner <felix.huettner@stackit.cloud>

Acked-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>

> ---
>  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) {
> +            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. */
> +        if (networks->n_ipv6_addrs > 1) {
> +            for (int i = 0; i < networks->n_ipv6_addrs - 1; ++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);
> -- 
> 2.47.0
> 
> 
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
diff mbox series

Patch

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) {
+            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. */
+        if (networks->n_ipv6_addrs > 1) {
+            for (int i = 0; i < networks->n_ipv6_addrs - 1; ++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);