From e51879e99b3ed11c6b7017a63bff1c5da9f21fda Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Fri, 29 Jul 2016 14:39:29 -0700 Subject: ovsdb: Make OVSDB backup sever read only When ovsdb-sever is running in the backup state, it would be nice to make sure there is no un-intended changes to the backup database. This patch makes the ovsdb server only accepts 'read' transactions as a backup server. When the server role is changed into an active server, all existing client connections will be reset. After reconnect, all clinet transactions will then be accepted. Signed-off-by: Andy Zhou Acked-by: Ben Pfaff --- ovsdb/trigger.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'ovsdb/trigger.c') diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c index 0fbe94908..a859983f4 100644 --- a/ovsdb/trigger.c +++ b/ovsdb/trigger.c @@ -31,7 +31,8 @@ static void ovsdb_trigger_complete(struct ovsdb_trigger *); void ovsdb_trigger_init(struct ovsdb_session *session, struct ovsdb *db, struct ovsdb_trigger *trigger, - struct json *request, long long int now) + struct json *request, long long int now, + bool read_only) { trigger->session = session; trigger->db = db; @@ -40,6 +41,7 @@ ovsdb_trigger_init(struct ovsdb_session *session, struct ovsdb *db, trigger->result = NULL; trigger->created = now; trigger->timeout_msec = LLONG_MAX; + trigger->read_only = read_only; ovsdb_trigger_try(trigger, now); } @@ -111,7 +113,8 @@ static bool ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now) { t->result = ovsdb_execute(t->db, t->session, - t->request, now - t->created, &t->timeout_msec); + t->request, t->read_only, + now - t->created, &t->timeout_msec); if (t->result) { ovsdb_trigger_complete(t); return true; -- cgit v1.2.1