summaryrefslogtreecommitdiff
path: root/ovsdb/transaction.h
diff options
context:
space:
mode:
authorHan Zhou <hzhou8@ebay.com>2019-08-19 16:30:35 -0700
committerBen Pfaff <blp@ovn.org>2019-08-21 14:47:06 -0700
commitc194367cbf86cce4faad9e4126ee0529f37c3690 (patch)
tree4d632bb086982a6ade4949e6116386bb405b5667 /ovsdb/transaction.h
parent8e35461419a63fc5ca1e492994d08c02295137e1 (diff)
downloadopenvswitch-c194367cbf86cce4faad9e4126ee0529f37c3690.tar.gz
ovsdb monitor: Fix crash when using non-zero last-id with standalone DB.
When a client uses monitor-cond-since with a non-zero last-id but the server is not in cluster mode for the DB being monitored, it leads to segmentation fault because the txn_history list is not initialized in this case. Program terminated with signal SIGSEGV, Segmentation fault. 1536 struct ovsdb_txn *txn = h_node->txn; (gdb) bt 0 ovsdb_monitor_get_changes_after (txn_uuid=txn_uuid@entry=0x7ffe8605b7e0, dbmon=0x17c1b40, p_mcs=p_mcs@entry=0x17c4900) at ovsdb/monitor.c:1536 1 0x000000000040da2d in ovsdb_jsonrpc_monitor_create (request_id=0x1804630, version=<optimized out>, params=0x17ad330, db=0x18015b0, s=<optimized out>) at ovsdb/jsonrpc-server.c:1469 2 ovsdb_jsonrpc_session_got_request (request=0x17ad520, s=<optimized out>) at ovsdb/jsonrpc-server.c:1002 3 ovsdb_jsonrpc_session_run (s=<optimized out>) at ovsdb/jsonrpc-server.c:556 ... Although it doesn't happen in normal use cases, no one can prevent a client to send this on purpose or in a corner case when a client firstly connected to a clustered DB but later the server restarted with a non-clustered DB. This patch fixes it by always initialize the txn_history list to avoid the undefined behavior in this case. It adds a test case to cover it, too. Fixes: 695e815 ("ovsdb-server: Transaction history tracking.") Reported-by: Aliasgar Ginwala <aginwala@ebay.com> Signed-off-by: Han Zhou <hzhou8@ebay.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb/transaction.h')
-rw-r--r--ovsdb/transaction.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/ovsdb/transaction.h b/ovsdb/transaction.h
index c21871a45..ea6b53d3c 100644
--- a/ovsdb/transaction.h
+++ b/ovsdb/transaction.h
@@ -63,7 +63,7 @@ void ovsdb_txn_for_each_change(const struct ovsdb_txn *,
void ovsdb_txn_add_comment(struct ovsdb_txn *, const char *);
const char *ovsdb_txn_get_comment(const struct ovsdb_txn *);
void ovsdb_txn_history_run(struct ovsdb *);
-void ovsdb_txn_history_init(struct ovsdb *);
+void ovsdb_txn_history_init(struct ovsdb *, bool need_txn_history);
void ovsdb_txn_history_destroy(struct ovsdb *);
#endif /* ovsdb/transaction.h */