From 1b1d2e6daa563cc91f974ffdc082fb3a8b424801 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sun, 31 Dec 2017 21:15:58 -0800 Subject: ovsdb: Introduce experimental support for clustered databases. This commit adds support for OVSDB clustering via Raft. Please read ovsdb(7) for information on how to set up a clustered database. It is simple and boils down to running "ovsdb-tool create-cluster" on one server and "ovsdb-tool join-cluster" on each of the others and then starting ovsdb-server in the usual way on all of them. One you have a clustered database, you configure ovn-controller and ovn-northd to use it by pointing them to all of the servers, e.g. where previously you might have said "tcp:1.2.3.4" was the database server, now you say that it is "tcp:1.2.3.4,tcp:5.6.7.8,tcp:9.10.11.12". This also adds support for database clustering to ovs-sandbox. Acked-by: Justin Pettit Tested-by: aginwala Signed-off-by: Ben Pfaff --- lib/smap.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/smap.c') diff --git a/lib/smap.c b/lib/smap.c index 6c6717c15..149b8b243 100644 --- a/lib/smap.c +++ b/lib/smap.c @@ -108,9 +108,18 @@ smap_add_ipv6(struct smap *smap, const char *key, struct in6_addr *addr) } /* Searches for 'key' in 'smap'. If it does not already exists, adds it. - * Otherwise, changes its value to 'value'. */ + * Otherwise, changes its value to 'value'. The caller retains ownership of + * 'value'. */ void smap_replace(struct smap *smap, const char *key, const char *value) +{ + smap_replace_nocopy(smap, key, xstrdup(value)); +} + +/* Searches for 'key' in 'smap'. If it does not already exists, adds it. + * Otherwise, changes its value to 'value'. Takes ownership of 'value'. */ +void +smap_replace_nocopy(struct smap *smap, const char *key, char *value) { size_t key_len = strlen(key); size_t hash = hash_bytes(key, key_len, 0); @@ -120,9 +129,9 @@ smap_replace(struct smap *smap, const char *key, const char *value) node = smap_find__(smap, key, key_len, hash); if (node) { free(node->value); - node->value = xstrdup(value); + node->value = value; } else { - smap_add__(smap, xmemdup0(key, key_len), xstrdup(value), hash); + smap_add__(smap, xmemdup0(key, key_len), value, hash); } } -- cgit v1.2.1