On Mon, Oct 14, 2024 at 12:10 PM Xavier Simonart <[email protected]>
wrote:

> Signed-off-by: Xavier Simonart <[email protected]>
>
> ---
> v2: - Rebased on main.
>     - Addressed Ales' comments:
>       - Set name to "unknown" when dumping peer ports if name not set.
>       - Formatting.
>
> Signed-off-by: Xavier Simonart <[email protected]>
> ---
>  controller/local_data.c     | 16 ++++++++++++++++
>  controller/local_data.h     |  2 ++
>  controller/ovn-controller.c | 15 +++++++++++++++
>  3 files changed, 33 insertions(+)
>
> diff --git a/controller/local_data.c b/controller/local_data.c
> index f889fb76b..f1a7ce00e 100644
> --- a/controller/local_data.c
> +++ b/controller/local_data.c
> @@ -231,6 +231,22 @@ add_local_datapath_peer_port(
>      local_datapath_peer_port_add(peer_ld, peer, pb);
>  }
>
> +void
> +local_data_dump_peer_ports(struct hmap *local_datapaths, struct ds
> *peer_ports)
> +{
> +    struct local_datapath *ld;
> +    size_t i = 0;
> +    HMAP_FOR_EACH (ld, hmap_node, local_datapaths) {
> +        const char *name = smap_get_def(&ld->datapath->external_ids,
> "name",
> +                                    "unknown");
> +        for (i = 0; i < ld->n_peer_ports; i++) {
> +            ds_put_format(peer_ports, "dp %s : local = %s, remote = %s\n",
> +                          name, ld->peer_ports[i].local->logical_port,
> +                          ld->peer_ports[i].remote->logical_port);
> +        }
> +    }
> +}
> +
>  void
>  remove_local_datapath_peer_port(const struct sbrec_port_binding *pb,
>                                  struct local_datapath *ld,
> diff --git a/controller/local_data.h b/controller/local_data.h
> index 632f34b51..ab8e789a5 100644
> --- a/controller/local_data.h
> +++ b/controller/local_data.h
> @@ -173,5 +173,7 @@ void remove_local_datapath_multichassis_port(struct
> local_datapath *ld,
>                                               char *logical_port);
>  bool lb_is_local(const struct sbrec_load_balancer *sbrec_lb,
>                   const struct hmap *local_datapaths);
> +void local_data_dump_peer_ports(struct hmap *local_datapaths,
> +                                struct ds *peer_ports);
>
>  #endif /* controller/local_data.h */
> diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
> index 7002dcdfe..e18d4c02b 100644
> --- a/controller/ovn-controller.c
> +++ b/controller/ovn-controller.c
> @@ -101,6 +101,7 @@ static unixctl_cb_func debug_status_execution;
>  static unixctl_cb_func debug_dump_local_bindings;
>  static unixctl_cb_func debug_dump_related_lports;
>  static unixctl_cb_func debug_dump_local_template_vars;
> +static unixctl_cb_func debug_dump_peer_ports;
>  static unixctl_cb_func debug_dump_lflow_conj_ids;
>  static unixctl_cb_func lflow_cache_flush_cmd;
>  static unixctl_cb_func lflow_cache_show_stats_cmd;
> @@ -5336,6 +5337,10 @@ main(int argc, char *argv[])
>                               debug_dump_lflow_conj_ids,
>                               &lflow_output_data->conj_ids);
>
> +    unixctl_command_register("debug/dump-peer-ports", "", 0, 0,
> +                             debug_dump_peer_ports,
> +                             &runtime_data->local_datapaths);
> +
>      unixctl_command_register("debug/dump-local-template-vars", "", 0, 0,
>                               debug_dump_local_template_vars,
>                               &template_vars_data->local_templates);
> @@ -6273,6 +6278,16 @@ debug_dump_related_lports(struct unixctl_conn
> *conn, int argc OVS_UNUSED,
>      ds_destroy(&data);
>  }
>
> +static void
> +debug_dump_peer_ports(struct unixctl_conn *conn, int argc OVS_UNUSED,
> +                          const char *argv[] OVS_UNUSED, void
> *local_datapaths)
> +{
> +    struct ds peer_ports = DS_EMPTY_INITIALIZER;
> +    local_data_dump_peer_ports(local_datapaths, &peer_ports);
> +    unixctl_command_reply(conn, ds_cstr(&peer_ports));
> +    ds_destroy(&peer_ports);
> +}
> +
>  static void
>  debug_dump_lflow_conj_ids(struct unixctl_conn *conn, int argc OVS_UNUSED,
>                            const char *argv[] OVS_UNUSED, void *conj_ids)
> --
> 2.31.1
>
>
Looks good to me, thanks.

Acked-by: Ales Musil <[email protected]>
-- 

Ales Musil

Senior Software Engineer - OVN Core

Red Hat EMEA <https://www.redhat.com>

[email protected]
<https://red.ht/sig>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to