Currently, there is no way for an OVSDB server to ID itself. This patch adds a UUID field that is populated every time OVSDB server runs. Later patch will make use this UUID to detect and stop and OVSDB server from replicating itself.
Signed-off-by: Andy Zhou <az...@ovn.org> --- ovsdb/jsonrpc-server.c | 6 ++++++ ovsdb/jsonrpc-server.h | 4 ++++ ovsdb/server.c | 2 ++ ovsdb/server.h | 7 +++++++ 4 files changed, 19 insertions(+) diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c index fa589b5..dca6666 100644 --- a/ovsdb/jsonrpc-server.c +++ b/ovsdb/jsonrpc-server.c @@ -1575,6 +1575,12 @@ ovsdb_jsonrpc_create_notify(const struct ovsdb_jsonrpc_monitor *m, return jsonrpc_create_notify(method, params); } +const struct uuid * +ovsdb_jsonrpc_server_get_uuid(const struct ovsdb_jsonrpc_server *s) +{ + return ovsdb_server_get_uuid(&s->up); +} + static void ovsdb_jsonrpc_monitor_flush_all(struct ovsdb_jsonrpc_session *s) { diff --git a/ovsdb/jsonrpc-server.h b/ovsdb/jsonrpc-server.h index f72f884..3cacbb6 100644 --- a/ovsdb/jsonrpc-server.h +++ b/ovsdb/jsonrpc-server.h @@ -22,6 +22,7 @@ struct ovsdb; struct shash; struct simap; +struct uuid; struct ovsdb_jsonrpc_server *ovsdb_jsonrpc_server_create(bool read_only); bool ovsdb_jsonrpc_server_add_db(struct ovsdb_jsonrpc_server *, @@ -71,6 +72,9 @@ bool ovsdb_jsonrpc_server_is_read_only(struct ovsdb_jsonrpc_server *); void ovsdb_jsonrpc_server_get_memory_usage(const struct ovsdb_jsonrpc_server *, struct simap *usage); +const struct uuid *ovsdb_jsonrpc_server_get_uuid( + const struct ovsdb_jsonrpc_server *); + struct ovsdb_jsonrpc_monitor; void ovsdb_jsonrpc_monitor_destroy(struct ovsdb_jsonrpc_monitor *); void ovsdb_jsonrpc_disable_monitor_cond(void); diff --git a/ovsdb/server.c b/ovsdb/server.c index eca9151..2a77523 100644 --- a/ovsdb/server.c +++ b/ovsdb/server.c @@ -19,6 +19,7 @@ #include "hash.h" #include "ovsdb.h" +#include "uuid.h" /* Initializes 'session' as a session within 'server'. */ void @@ -121,6 +122,7 @@ ovsdb_server_init(struct ovsdb_server *server) { shash_init(&server->dbs); hmap_init(&server->locks); + uuid_generate(&server->uuid); } /* Adds 'db' to the set of databases served out by 'server'. Returns true if diff --git a/ovsdb/server.h b/ovsdb/server.h index c0bbb69..f8bb6c2 100644 --- a/ovsdb/server.h +++ b/ovsdb/server.h @@ -19,6 +19,7 @@ #include "openvswitch/hmap.h" #include "openvswitch/list.h" #include "openvswitch/shash.h" +#include "openvswitch/uuid.h" struct ovsdb; struct ovsdb_server; @@ -79,6 +80,8 @@ bool ovsdb_lock_waiter_is_owner(const struct ovsdb_lock_waiter *); struct ovsdb_server { struct shash dbs; /* Maps from a db name to a "struct ovsdb *". */ struct hmap locks; /* Contains "struct ovsdb_lock"s indexed by name. */ + struct uuid uuid; /* Server ID. Generated every time a server is + launched. */ }; void ovsdb_server_init(struct ovsdb_server *); @@ -92,4 +95,8 @@ struct ovsdb_lock_waiter *ovsdb_server_lock(struct ovsdb_server *, enum ovsdb_lock_mode, struct ovsdb_session **victimp); +static inline const struct uuid * +ovsdb_server_get_uuid(const struct ovsdb_server *s){ + return (&s->uuid); +} #endif /* ovsdb/server.h */ -- 1.9.1 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev