2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00

ovsdb: Allow database itself to be read-only.

Currently, the read-only option can be set on connections or JSON-RPC
server as a whole.  However, there is no way to allow modifications in
one database, but not in the other.

Adding an internal read-only flag for a database itself.  Will be used
later for running active and backup databases in a single process.

Marking the _Server database as read only is not necessary, because
modifications of internal databases are not allowed anyway, but it
doesn't hurt.

Acked-by: Mike Pattrick <mkp@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Ilya Maximets 2024-01-09 23:49:01 +01:00
parent 05d6f419cd
commit ea43621745
4 changed files with 10 additions and 1 deletions

View File

@ -1148,7 +1148,8 @@ ovsdb_jsonrpc_trigger_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db,
/* Insert into trigger table. */ /* Insert into trigger table. */
t = xmalloc(sizeof *t); t = xmalloc(sizeof *t);
bool disconnect_all = ovsdb_trigger_init( bool disconnect_all = ovsdb_trigger_init(
&s->up, db, &t->trigger, request, time_msec(), s->read_only, &s->up, db, &t->trigger, request, time_msec(),
s->read_only || db->read_only,
s->remote->role, jsonrpc_session_get_id(s->js)); s->remote->role, jsonrpc_session_get_id(s->js));
t->id = json_clone(request->id); t->id = json_clone(request->id);
hmap_insert(&s->triggers, &t->hmap_node, hash); hmap_insert(&s->triggers, &t->hmap_node, hash);

View File

@ -831,8 +831,11 @@ add_server_db(struct server_config *config)
db->filename = xstrdup("<internal>"); db->filename = xstrdup("<internal>");
db->db = ovsdb_create(schema, ovsdb_storage_create_unbacked(NULL)); db->db = ovsdb_create(schema, ovsdb_storage_create_unbacked(NULL));
db->db->read_only = true;
bool ok OVS_UNUSED = ovsdb_jsonrpc_server_add_db(config->jsonrpc, db->db); bool ok OVS_UNUSED = ovsdb_jsonrpc_server_add_db(config->jsonrpc, db->db);
ovs_assert(ok); ovs_assert(ok);
add_db(config, db); add_db(config, db);
} }

View File

@ -464,6 +464,8 @@ ovsdb_create(struct ovsdb_schema *schema, struct ovsdb_storage *storage)
db->n_atoms = 0; db->n_atoms = 0;
db->read_only = false;
db->is_relay = false; db->is_relay = false;
ovs_list_init(&db->txn_forward_new); ovs_list_init(&db->txn_forward_new);
hmap_init(&db->txn_forward_sent); hmap_init(&db->txn_forward_sent);

View File

@ -114,6 +114,9 @@ struct ovsdb {
size_t n_atoms; /* Total number of ovsdb atoms in the database. */ size_t n_atoms; /* Total number of ovsdb atoms in the database. */
bool read_only; /* If 'true', JSON-RPC clients are not allowed to change
* the data. */
/* Relay mode. */ /* Relay mode. */
bool is_relay; /* True, if database is in relay mode. */ bool is_relay; /* True, if database is in relay mode. */
/* List that holds transactions waiting to be forwarded to the server. */ /* List that holds transactions waiting to be forwarded to the server. */