mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 01:51:26 +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:
parent
05d6f419cd
commit
ea43621745
@ -1148,7 +1148,8 @@ ovsdb_jsonrpc_trigger_create(struct ovsdb_jsonrpc_session *s, struct ovsdb *db,
|
||||
/* Insert into trigger table. */
|
||||
t = xmalloc(sizeof *t);
|
||||
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));
|
||||
t->id = json_clone(request->id);
|
||||
hmap_insert(&s->triggers, &t->hmap_node, hash);
|
||||
|
@ -831,8 +831,11 @@ add_server_db(struct server_config *config)
|
||||
|
||||
db->filename = xstrdup("<internal>");
|
||||
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);
|
||||
ovs_assert(ok);
|
||||
|
||||
add_db(config, db);
|
||||
}
|
||||
|
||||
|
@ -464,6 +464,8 @@ ovsdb_create(struct ovsdb_schema *schema, struct ovsdb_storage *storage)
|
||||
|
||||
db->n_atoms = 0;
|
||||
|
||||
db->read_only = false;
|
||||
|
||||
db->is_relay = false;
|
||||
ovs_list_init(&db->txn_forward_new);
|
||||
hmap_init(&db->txn_forward_sent);
|
||||
|
@ -114,6 +114,9 @@ struct ovsdb {
|
||||
|
||||
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. */
|
||||
bool is_relay; /* True, if database is in relay mode. */
|
||||
/* List that holds transactions waiting to be forwarded to the server. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user