0b5169716dc66f73578a51094631bfbc3634f5d0
Author: Eelco Chaudron <[email protected]>
dpif-offload: Introduce provider debug information API.

This patch adds a new API that allows offload providers to expose
free-form debug information integrated into the existing
'ovs-appctl dpif/offload/show' command.

> diff --git a/include/openvswitch/json.h b/include/openvswitch/json.h
> index 134890553..ea2c4da04 100644
> --- a/include/openvswitch/json.h
> +++ b/include/openvswitch/json.h
> @@ -123,6 +123,7 @@ struct json *json_array_create_3(struct json *, struct 
> json *, struct json *);
>  bool json_array_contains_string(const struct json *, const char *);
>  
>  struct json *json_object_create(void);
> +bool json_object_is_empty(struct json *);

Does json_object_is_empty handle NULL input safely? The function accepts
'struct json *json' but doesn't specify NULL handling behavior.

> diff --git a/lib/dpif-offload-dpdk.c b/lib/dpif-offload-dpdk.c
> index be33346a4..1f097bfc9 100644
> --- a/lib/dpif-offload-dpdk.c
> +++ b/lib/dpif-offload-dpdk.c
> @@ -225,6 +237,57 @@ dpif_offload_dpdk_get_debug(const struct dpif_offload 
> *offload_, struct ds *ds,
>          if (!json_object_is_empty(json_ports)) {
>              json_object_put(json, "ports", json_ports);
>          } else {
>              json_destroy(json_ports);

[ ... ]

> diff --git a/lib/json.c b/lib/json.c
> index 23622ab36..23000f195 100644
> --- a/lib/json.c
> +++ b/lib/json.c
> @@ -397,6 +397,13 @@ json_object_create(void)
>      return json;
>  }
>  
> +bool
> +json_object_is_empty(struct json *json)
> +{
> +    return json && json->type == JSON_OBJECT
> +           && shash_is_empty(json->object);
> +}

What happens if json_object_is_empty is called with json->object being
NULL? Does shash_is_empty handle NULL pointers correctly?

> diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
> index f94101415..f751cdd4f 100644
> --- a/ofproto/ofproto-dpif.c
> +++ b/ofproto/ofproto-dpif.c
> @@ -6744,15 +6745,26 @@ dpif_offload_show_backer_json(struct json *backers,
>      /* Add offload provides as new JSON objects using its type as key. */
>      DPIF_OFFLOAD_FOR_EACH (offload, &dump, backer->dpif) {
> -        json_array_add(json_priority,
> +        struct json *debug_data = json_object_create();
> +
> +        json_array_add(json_priority,
>                         json_string_create(dpif_offload_class_type(offload)));
> +
> +        dpif_offload_get_debug(offload, NULL, debug_data);

Does this code leak debug_data if dpif_offload_class_type returns NULL?
The json_string_create call could fail, but debug_data would still need
cleanup.

> +        json_object_put(json_providers, dpif_offload_class_type(offload),
> +                        debug_data);

Can dpif_offload_class_type return NULL here? If so, json_object_put
would receive a NULL key parameter.
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to