On Wed, Aug 18, 2021 at 8:43 PM <[email protected]> wrote:
>
> From: Numan Siddique <[email protected]>
>
> This patch adds 2 new APIs in the ovsdb-idl client library
> - ovsdb_idl_has_table() and ovsdb_idl_has_column_in_table() to
> query if a table and a column is present in the IDL or not. This
> is required for scenarios where the server schema is old and
> missing a table or column and the client (built with a new schema
> version) does a transaction with the missing table or column. This
> results in a continuous loop of transaction failures.
>
> OVN would require the API - ovsdb_idl_has_table() to address this issue
> when an old ovsdb-server is used (OVS 2.11) which has the 'datapath'
> table missing. A recent commit in OVN creates a 'datapath' row
> in the local ovsdb-server. ovsdb_idl_has_column_in_table() would be
> useful to have.
>
> Related issue: https://bugzilla.redhat.com/show_bug.cgi?id=1992705
> Signed-off-by: Numan Siddique <[email protected]>
> ---
> lib/ovsdb-idl.c | 25 +++++++++++++++++++++++++
> lib/ovsdb-idl.h | 4 ++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
> index 2198c69c6..c5795fb7f 100644
> --- a/lib/ovsdb-idl.c
> +++ b/lib/ovsdb-idl.c
> @@ -4256,3 +4256,28 @@ ovsdb_idl_loop_commit_and_wait(struct ovsdb_idl_loop
> *loop)
>
> return retval;
> }
> +
> +bool
> +ovsdb_idl_has_table(struct ovsdb_idl *idl, const char *table_name)
> +{
> + struct ovsdb_idl_table *table = shash_find_data(&idl->table_by_name,
> + table_name);
> + return table ? true: false;
> +}
> +
> +bool
> +ovsdb_idl_has_column_in_table(struct ovsdb_idl *idl, const char *table_name,
> + const char *column_name)
> +{
> + struct ovsdb_idl_table *table = shash_find_data(&idl->table_by_name,
> + table_name);
> + if (!table) {
> + return false;
> + }
> +
> + if (shash_find_data(&table->columns, column_name)) {
> + return true;
> + }
> +
> + return false;
Why not use ovsdb_idl_has_table you created and make this function
more concise? I would have done:
if (ovsdb_idl_has_table(idl, table_name) &&
shash_find_data(&table->columns, column_name))
return true;
return false;
I dont know if this breaks any coding conventions though :)
Otherwise LGTM
> +}
> diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h
> index d93483245..216db4c6d 100644
> --- a/lib/ovsdb-idl.h
> +++ b/lib/ovsdb-idl.h
> @@ -474,6 +474,10 @@ void ovsdb_idl_cursor_next_eq(struct ovsdb_idl_cursor *);
>
> struct ovsdb_idl_row *ovsdb_idl_cursor_data(struct ovsdb_idl_cursor *);
>
> +bool ovsdb_idl_has_table(struct ovsdb_idl *idl, const char *table_name);
> +bool ovsdb_idl_has_column_in_table(struct ovsdb_idl *idl,
> + const char *table_name,
> + const char *column_name);
> #ifdef __cplusplus
> }
> #endif
> --
> 2.31.1
>
> _______________________________________________
> dev mailing list
> [email protected]
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev