1 /* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017 Nicira, Inc.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
26 #include "command-line.h"
29 #include "openvswitch/dynamic-string.h"
30 #include "fatal-signal.h"
33 #include "openvswitch/json.h"
35 #include "jsonrpc-server.h"
36 #include "openvswitch/list.h"
40 #include "ovsdb-data.h"
41 #include "ovsdb-types.h"
42 #include "ovsdb-error.h"
43 #include "poll-loop.h"
45 #include "replication.h"
48 #include "openvswitch/shash.h"
49 #include "stream-ssl.h"
54 #include "transaction.h"
58 #include "perf-counter.h"
59 #include "ovsdb-util.h"
60 #include "openvswitch/vlog.h"
62 VLOG_DEFINE_THIS_MODULE(ovsdb_server
);
65 /* Initialized in main(). */
67 struct ovsdb_file
*file
;
70 /* Only used by update_remote_status(). */
71 struct ovsdb_txn
*txn
;
74 /* SSL configuration. */
75 static char *private_key_file
;
76 static char *certificate_file
;
77 static char *ca_cert_file
;
78 static char *ssl_protocols
;
79 static char *ssl_ciphers
;
80 static bool bootstrap_ca_cert
;
82 static unixctl_cb_func ovsdb_server_exit
;
83 static unixctl_cb_func ovsdb_server_compact
;
84 static unixctl_cb_func ovsdb_server_reconnect
;
85 static unixctl_cb_func ovsdb_server_perf_counters_clear
;
86 static unixctl_cb_func ovsdb_server_perf_counters_show
;
87 static unixctl_cb_func ovsdb_server_disable_monitor_cond
;
88 static unixctl_cb_func ovsdb_server_set_active_ovsdb_server
;
89 static unixctl_cb_func ovsdb_server_get_active_ovsdb_server
;
90 static unixctl_cb_func ovsdb_server_connect_active_ovsdb_server
;
91 static unixctl_cb_func ovsdb_server_disconnect_active_ovsdb_server
;
92 static unixctl_cb_func ovsdb_server_set_sync_exclude_tables
;
93 static unixctl_cb_func ovsdb_server_get_sync_exclude_tables
;
94 static unixctl_cb_func ovsdb_server_get_sync_status
;
96 struct server_config
{
98 struct shash
*all_dbs
;
103 struct ovsdb_jsonrpc_server
*jsonrpc
;
105 static unixctl_cb_func ovsdb_server_add_remote
;
106 static unixctl_cb_func ovsdb_server_remove_remote
;
107 static unixctl_cb_func ovsdb_server_list_remotes
;
109 static unixctl_cb_func ovsdb_server_add_database
;
110 static unixctl_cb_func ovsdb_server_remove_database
;
111 static unixctl_cb_func ovsdb_server_list_databases
;
113 static char *open_db(struct server_config
*config
, const char *filename
);
114 static void close_db(struct db
*db
);
116 static void parse_options(int *argc
, char **argvp
[],
117 struct sset
*remotes
, char **unixctl_pathp
,
118 char **run_command
, char **sync_from
,
119 char **sync_exclude
, bool *is_backup
);
120 OVS_NO_RETURN
static void usage(void);
122 static char *reconfigure_remotes(struct ovsdb_jsonrpc_server
*,
123 const struct shash
*all_dbs
,
124 struct sset
*remotes
);
125 static char *reconfigure_ssl(const struct shash
*all_dbs
);
126 static void report_error_if_changed(char *error
, char **last_errorp
);
128 static void update_remote_status(const struct ovsdb_jsonrpc_server
*jsonrpc
,
129 const struct sset
*remotes
,
130 struct shash
*all_dbs
);
132 static void save_config__(FILE *config_file
, const struct sset
*remotes
,
133 const struct sset
*db_filenames
,
134 const char *sync_from
, const char *sync_exclude
,
136 static void save_config(struct server_config
*);
137 static void load_config(FILE *config_file
, struct sset
*remotes
,
138 struct sset
*db_filenames
, char **sync_from
,
139 char **sync_exclude
, bool *is_backup
);
142 ovsdb_replication_init(const char *sync_from
, const char *exclude
,
143 struct shash
*all_dbs
, const struct uuid
*server_uuid
)
145 replication_init(sync_from
, exclude
, server_uuid
);
146 struct shash_node
*node
;
147 SHASH_FOR_EACH (node
, all_dbs
) {
148 struct db
*db
= node
->data
;
149 replication_add_local_db(node
->name
, db
->db
);
154 main_loop(struct ovsdb_jsonrpc_server
*jsonrpc
, struct shash
*all_dbs
,
155 struct unixctl_server
*unixctl
, struct sset
*remotes
,
156 struct process
*run_process
, bool *exiting
, bool *is_backup
)
158 char *remotes_error
, *ssl_error
;
159 struct shash_node
*node
;
160 long long int status_timer
= LLONG_MIN
;
161 bool last_role
= *is_backup
;
165 remotes_error
= NULL
;
168 if (memory_should_report()) {
172 ovsdb_jsonrpc_server_get_memory_usage(jsonrpc
, &usage
);
173 ovsdb_monitor_get_memory_usage(&usage
);
174 SHASH_FOR_EACH(node
, all_dbs
) {
175 struct db
*db
= node
->data
;
176 ovsdb_get_memory_usage(db
->db
, &usage
);
178 memory_report(&usage
);
179 simap_destroy(&usage
);
182 /* Run unixctl_server_run() before reconfigure_remotes() because
183 * ovsdb-server/add-remote and ovsdb-server/remove-remote can change
184 * the set of remotes that reconfigure_remotes() uses. */
185 unixctl_server_run(unixctl
);
187 /* In ovsdb-server's role (active or backup) has changed, restart
188 * the ovsdb jsonrpc server. */
189 if (last_role
!= *is_backup
) {
190 bool read_only
= last_role
= *is_backup
;
191 ovsdb_jsonrpc_server_reconnect(jsonrpc
, read_only
);
194 report_error_if_changed(
195 reconfigure_remotes(jsonrpc
, all_dbs
, remotes
),
197 report_error_if_changed(reconfigure_ssl(all_dbs
), &ssl_error
);
198 ovsdb_jsonrpc_server_run(jsonrpc
);
202 if (!replication_is_alive()) {
203 disconnect_active_server();
208 SHASH_FOR_EACH(node
, all_dbs
) {
209 struct db
*db
= node
->data
;
210 ovsdb_trigger_run(db
->db
, time_msec());
214 if (process_exited(run_process
)) {
219 /* update Manager status(es) every 2.5 seconds */
220 if (time_msec() >= status_timer
) {
221 status_timer
= time_msec() + 2500;
222 update_remote_status(jsonrpc
, remotes
, all_dbs
);
230 ovsdb_jsonrpc_server_wait(jsonrpc
);
231 unixctl_server_wait(unixctl
);
232 SHASH_FOR_EACH(node
, all_dbs
) {
233 struct db
*db
= node
->data
;
234 ovsdb_trigger_wait(db
->db
, time_msec());
237 process_wait(run_process
);
240 poll_immediate_wake();
242 poll_timer_wait_until(status_timer
);
244 if (should_service_stop()) {
253 main(int argc
, char *argv
[])
255 char *unixctl_path
= NULL
;
256 char *run_command
= NULL
;
257 struct unixctl_server
*unixctl
;
258 struct ovsdb_jsonrpc_server
*jsonrpc
;
259 struct sset remotes
, db_filenames
;
260 char *sync_from
, *sync_exclude
;
262 const char *db_filename
;
263 struct process
*run_process
;
266 FILE *config_tmpfile
;
267 struct server_config server_config
;
268 struct shash all_dbs
;
269 struct shash_node
*node
, *next
;
273 ovs_cmdl_proctitle_init(argc
, argv
);
274 set_program_name(argv
[0]);
275 service_start(&argc
, &argv
);
276 fatal_ignore_sigpipe();
280 parse_options(&argc
, &argv
, &remotes
, &unixctl_path
, &run_command
,
281 &sync_from
, &sync_exclude
, &active
);
282 is_backup
= sync_from
&& !active
;
284 daemon_become_new_user(false);
286 /* Create and initialize 'config_tmpfile' as a temporary file to hold
287 * ovsdb-server's most basic configuration, and then save our initial
288 * configuration to it. When --monitor is used, this preserves the effects
289 * of ovs-appctl commands such as ovsdb-server/add-remote (which saves the
290 * new configuration) across crashes. */
291 config_tmpfile
= tmpfile();
292 if (!config_tmpfile
) {
293 ovs_fatal(errno
, "failed to create temporary file");
296 sset_init(&db_filenames
);
298 for (i
= 0; i
< argc
; i
++) {
299 sset_add(&db_filenames
, argv
[i
]);
302 char *default_db
= xasprintf("%s/conf.db", ovs_dbdir());
303 sset_add(&db_filenames
, default_db
);
307 server_config
.remotes
= &remotes
;
308 server_config
.config_tmpfile
= config_tmpfile
;
310 save_config__(config_tmpfile
, &remotes
, &db_filenames
, sync_from
,
311 sync_exclude
, is_backup
);
313 daemonize_start(false);
315 /* Load the saved config. */
316 load_config(config_tmpfile
, &remotes
, &db_filenames
, &sync_from
,
317 &sync_exclude
, &is_backup
);
319 /* Start ovsdb jsonrpc server. When running as a backup server,
320 * jsonrpc connections are read only. Otherwise, both read
321 * and write transactions are allowed. */
322 jsonrpc
= ovsdb_jsonrpc_server_create(is_backup
);
324 shash_init(&all_dbs
);
325 server_config
.all_dbs
= &all_dbs
;
326 server_config
.jsonrpc
= jsonrpc
;
327 server_config
.sync_from
= &sync_from
;
328 server_config
.sync_exclude
= &sync_exclude
;
329 server_config
.is_backup
= &is_backup
;
331 perf_counters_init();
333 SSET_FOR_EACH (db_filename
, &db_filenames
) {
334 error
= open_db(&server_config
, db_filename
);
336 ovs_fatal(0, "%s", error
);
340 error
= reconfigure_remotes(jsonrpc
, &all_dbs
, &remotes
);
342 error
= reconfigure_ssl(&all_dbs
);
345 ovs_fatal(0, "%s", error
);
348 retval
= unixctl_server_create(unixctl_path
, &unixctl
);
356 run_argv
[0] = "/bin/sh";
358 run_argv
[2] = run_command
;
361 retval
= process_start(run_argv
, &run_process
);
363 ovs_fatal(retval
, "%s: process failed to start", run_command
);
369 daemonize_complete();
372 /* ovsdb-server is usually a long-running process, in which case it
373 * makes plenty of sense to log the version, but --run makes
374 * ovsdb-server more like a command-line tool, so skip it. */
375 VLOG_INFO("%s (Open vSwitch) %s", program_name
, VERSION
);
378 unixctl_command_register("exit", "", 0, 0, ovsdb_server_exit
, &exiting
);
379 unixctl_command_register("ovsdb-server/compact", "", 0, 1,
380 ovsdb_server_compact
, &all_dbs
);
381 unixctl_command_register("ovsdb-server/reconnect", "", 0, 0,
382 ovsdb_server_reconnect
, jsonrpc
);
384 unixctl_command_register("ovsdb-server/add-remote", "REMOTE", 1, 1,
385 ovsdb_server_add_remote
, &server_config
);
386 unixctl_command_register("ovsdb-server/remove-remote", "REMOTE", 1, 1,
387 ovsdb_server_remove_remote
, &server_config
);
388 unixctl_command_register("ovsdb-server/list-remotes", "", 0, 0,
389 ovsdb_server_list_remotes
, &remotes
);
391 unixctl_command_register("ovsdb-server/add-db", "DB", 1, 1,
392 ovsdb_server_add_database
, &server_config
);
393 unixctl_command_register("ovsdb-server/remove-db", "DB", 1, 1,
394 ovsdb_server_remove_database
, &server_config
);
395 unixctl_command_register("ovsdb-server/list-dbs", "", 0, 0,
396 ovsdb_server_list_databases
, &all_dbs
);
397 unixctl_command_register("ovsdb-server/perf-counters-show", "", 0, 0,
398 ovsdb_server_perf_counters_show
, NULL
);
399 unixctl_command_register("ovsdb-server/perf-counters-clear", "", 0, 0,
400 ovsdb_server_perf_counters_clear
, NULL
);
401 unixctl_command_register("ovsdb-server/set-active-ovsdb-server", "", 1, 1,
402 ovsdb_server_set_active_ovsdb_server
,
404 unixctl_command_register("ovsdb-server/get-active-ovsdb-server", "", 0, 0,
405 ovsdb_server_get_active_ovsdb_server
,
407 unixctl_command_register("ovsdb-server/connect-active-ovsdb-server", "",
408 0, 0, ovsdb_server_connect_active_ovsdb_server
,
410 unixctl_command_register("ovsdb-server/disconnect-active-ovsdb-server", "",
411 0, 0, ovsdb_server_disconnect_active_ovsdb_server
,
413 unixctl_command_register("ovsdb-server/set-sync-exclude-tables", "",
414 0, 1, ovsdb_server_set_sync_exclude_tables
,
416 unixctl_command_register("ovsdb-server/get-sync-exclude-tables", "",
417 0, 0, ovsdb_server_get_sync_exclude_tables
,
419 unixctl_command_register("ovsdb-server/sync-status", "",
420 0, 0, ovsdb_server_get_sync_status
,
423 /* Simulate the behavior of OVS release prior to version 2.5 that
424 * does not support the monitor_cond method. */
425 unixctl_command_register("ovsdb-server/disable-monitor-cond", "", 0, 0,
426 ovsdb_server_disable_monitor_cond
, jsonrpc
);
429 const struct uuid
*server_uuid
;
430 server_uuid
= ovsdb_jsonrpc_server_get_uuid(jsonrpc
);
431 ovsdb_replication_init(sync_from
, sync_exclude
, &all_dbs
, server_uuid
);
434 main_loop(jsonrpc
, &all_dbs
, unixctl
, &remotes
, run_process
, &exiting
,
437 ovsdb_jsonrpc_server_destroy(jsonrpc
);
438 SHASH_FOR_EACH_SAFE(node
, next
, &all_dbs
) {
439 struct db
*db
= node
->data
;
441 shash_delete(&all_dbs
, node
);
443 shash_destroy(&all_dbs
);
444 sset_destroy(&remotes
);
445 sset_destroy(&db_filenames
);
448 unixctl_server_destroy(unixctl
);
449 replication_destroy();
451 if (run_process
&& process_exited(run_process
)) {
452 int status
= process_status(run_process
);
454 ovs_fatal(0, "%s: child exited, %s",
455 run_command
, process_status_msg(status
));
458 perf_counters_destroy();
463 /* Returns true if 'filename' is known to be already open as a database,
466 * "False negatives" are possible. */
468 is_already_open(struct server_config
*config OVS_UNUSED
,
469 const char *filename OVS_UNUSED
)
474 if (!stat(filename
, &s
)) {
475 struct shash_node
*node
;
477 SHASH_FOR_EACH (node
, config
->all_dbs
) {
478 struct db
*db
= node
->data
;
481 if (!stat(db
->filename
, &s2
)
482 && s
.st_dev
== s2
.st_dev
483 && s
.st_ino
== s2
.st_ino
) {
494 close_db(struct db
*db
)
496 ovsdb_destroy(db
->db
);
502 open_db(struct server_config
*config
, const char *filename
)
504 struct ovsdb_error
*db_error
;
508 /* If we know that the file is already open, return a good error message.
509 * Otherwise, if the file is open, we'll fail later on with a harder to
510 * interpret file locking error. */
511 if (is_already_open(config
, filename
)) {
512 return xasprintf("%s: already open", filename
);
515 db
= xzalloc(sizeof *db
);
516 db
->filename
= xstrdup(filename
);
518 db_error
= ovsdb_file_open(db
->filename
, false, &db
->db
, &db
->file
);
520 error
= ovsdb_error_to_string(db_error
);
521 } else if (!ovsdb_jsonrpc_server_add_db(config
->jsonrpc
, db
->db
)) {
522 error
= xasprintf("%s: duplicate database name", db
->db
->schema
->name
);
524 shash_add_assert(config
->all_dbs
, db
->db
->schema
->name
, db
);
528 ovsdb_error_destroy(db_error
);
533 static char * OVS_WARN_UNUSED_RESULT
534 parse_db_column__(const struct shash
*all_dbs
,
535 const char *name_
, char *name
,
536 const struct db
**dbp
,
537 const struct ovsdb_table
**tablep
,
538 const struct ovsdb_column
**columnp
)
540 const char *db_name
, *table_name
, *column_name
;
541 const struct ovsdb_column
*column
;
542 const struct ovsdb_table
*table
;
543 const char *tokens
[3];
544 char *save_ptr
= NULL
;
551 strtok_r(name
, ":", &save_ptr
); /* "db:" */
552 tokens
[0] = strtok_r(NULL
, ",", &save_ptr
);
553 tokens
[1] = strtok_r(NULL
, ",", &save_ptr
);
554 tokens
[2] = strtok_r(NULL
, ",", &save_ptr
);
555 if (!tokens
[0] || !tokens
[1] || !tokens
[2]) {
556 return xasprintf("\"%s\": invalid syntax", name_
);
560 table_name
= tokens
[1];
561 column_name
= tokens
[2];
563 db
= shash_find_data(all_dbs
, tokens
[0]);
565 return xasprintf("\"%s\": no database named %s", name_
, db_name
);
568 table
= ovsdb_get_table(db
->db
, table_name
);
570 return xasprintf("\"%s\": no table named %s", name_
, table_name
);
573 column
= ovsdb_table_schema_get_column(table
->schema
, column_name
);
575 return xasprintf("\"%s\": table \"%s\" has no column \"%s\"",
576 name_
, table_name
, column_name
);
585 /* Returns NULL if successful, otherwise a malloc()'d string describing the
587 static char * OVS_WARN_UNUSED_RESULT
588 parse_db_column(const struct shash
*all_dbs
,
590 const struct db
**dbp
,
591 const struct ovsdb_table
**tablep
,
592 const struct ovsdb_column
**columnp
)
594 char *name
= xstrdup(name_
);
595 char *retval
= parse_db_column__(all_dbs
, name_
, name
,
596 dbp
, tablep
, columnp
);
601 /* Returns NULL if successful, otherwise a malloc()'d string describing the
603 static char * OVS_WARN_UNUSED_RESULT
604 parse_db_string_column(const struct shash
*all_dbs
,
606 const struct db
**dbp
,
607 const struct ovsdb_table
**tablep
,
608 const struct ovsdb_column
**columnp
)
612 retval
= parse_db_column(all_dbs
, name
, dbp
, tablep
, columnp
);
617 if ((*columnp
)->type
.key
.type
!= OVSDB_TYPE_STRING
618 || (*columnp
)->type
.value
.type
!= OVSDB_TYPE_VOID
) {
619 return xasprintf("\"%s\": table \"%s\" column \"%s\" is "
620 "not string or set of strings",
621 name
, (*tablep
)->schema
->name
, (*columnp
)->name
);
628 query_db_string(const struct shash
*all_dbs
, const char *name
,
631 if (!name
|| strncmp(name
, "db:", 3)) {
634 const struct ovsdb_column
*column
;
635 const struct ovsdb_table
*table
;
636 const struct ovsdb_row
*row
;
640 retval
= parse_db_string_column(all_dbs
, name
,
641 &db
, &table
, &column
);
643 ds_put_format(errors
, "%s\n", retval
);
648 HMAP_FOR_EACH (row
, hmap_node
, &table
->rows
) {
649 const struct ovsdb_datum
*datum
;
652 datum
= &row
->fields
[column
->index
];
653 for (i
= 0; i
< datum
->n
; i
++) {
654 if (datum
->keys
[i
].string
[0]) {
655 return datum
->keys
[i
].string
;
663 static struct ovsdb_jsonrpc_options
*
664 add_remote(struct shash
*remotes
, const char *target
)
666 struct ovsdb_jsonrpc_options
*options
;
668 options
= shash_find_data(remotes
, target
);
670 options
= ovsdb_jsonrpc_default_options(target
);
671 shash_add(remotes
, target
, options
);
677 /* Adds a remote and options to 'remotes', based on the Manager table row in
680 add_manager_options(struct shash
*remotes
, const struct ovsdb_row
*row
)
682 static struct vlog_rate_limit rl
= VLOG_RATE_LIMIT_INIT(1, 1);
683 struct ovsdb_jsonrpc_options
*options
;
684 long long int max_backoff
, probe_interval
;
686 const char *target
, *dscp_string
, *role
;
688 if (!ovsdb_util_read_string_column(row
, "target", &target
) || !target
) {
689 VLOG_INFO_RL(&rl
, "Table `%s' has missing or invalid `target' column",
690 row
->table
->schema
->name
);
694 options
= add_remote(remotes
, target
);
695 if (ovsdb_util_read_integer_column(row
, "max_backoff", &max_backoff
)) {
696 options
->max_backoff
= max_backoff
;
698 if (ovsdb_util_read_integer_column(row
, "inactivity_probe",
700 options
->probe_interval
= probe_interval
;
702 if (ovsdb_util_read_bool_column(row
, "read_only", &read_only
)) {
703 options
->read_only
= read_only
;
707 options
->role
= NULL
;
708 if (ovsdb_util_read_string_column(row
, "role", &role
) && role
) {
709 options
->role
= xstrdup(role
);
712 options
->dscp
= DSCP_DEFAULT
;
713 dscp_string
= ovsdb_util_read_map_string_column(row
, "other_config",
716 int dscp
= atoi(dscp_string
);
717 if (dscp
>= 0 && dscp
<= 63) {
718 options
->dscp
= dscp
;
724 query_db_remotes(const char *name
, const struct shash
*all_dbs
,
725 struct shash
*remotes
, struct ds
*errors
)
727 const struct ovsdb_column
*column
;
728 const struct ovsdb_table
*table
;
729 const struct ovsdb_row
*row
;
733 retval
= parse_db_column(all_dbs
, name
, &db
, &table
, &column
);
735 ds_put_format(errors
, "%s\n", retval
);
740 if (column
->type
.key
.type
== OVSDB_TYPE_STRING
741 && column
->type
.value
.type
== OVSDB_TYPE_VOID
) {
742 HMAP_FOR_EACH (row
, hmap_node
, &table
->rows
) {
743 const struct ovsdb_datum
*datum
;
746 datum
= &row
->fields
[column
->index
];
747 for (i
= 0; i
< datum
->n
; i
++) {
748 add_remote(remotes
, datum
->keys
[i
].string
);
751 } else if (column
->type
.key
.type
== OVSDB_TYPE_UUID
752 && column
->type
.key
.u
.uuid
.refTable
753 && column
->type
.value
.type
== OVSDB_TYPE_VOID
) {
754 const struct ovsdb_table
*ref_table
= column
->type
.key
.u
.uuid
.refTable
;
755 HMAP_FOR_EACH (row
, hmap_node
, &table
->rows
) {
756 const struct ovsdb_datum
*datum
;
759 datum
= &row
->fields
[column
->index
];
760 for (i
= 0; i
< datum
->n
; i
++) {
761 const struct ovsdb_row
*ref_row
;
763 ref_row
= ovsdb_table_get_row(ref_table
, &datum
->keys
[i
].uuid
);
765 add_manager_options(remotes
, ref_row
);
773 update_remote_row(const struct ovsdb_row
*row
, struct ovsdb_txn
*txn
,
774 const struct ovsdb_jsonrpc_server
*jsonrpc
)
776 struct ovsdb_jsonrpc_remote_status status
;
777 struct ovsdb_row
*rw_row
;
779 char *keys
[9], *values
[9];
782 /* Get the "target" (protocol/host/port) spec. */
783 if (!ovsdb_util_read_string_column(row
, "target", &target
)) {
784 /* Bad remote spec or incorrect schema. */
787 rw_row
= ovsdb_txn_row_modify(txn
, row
);
788 ovsdb_jsonrpc_server_get_remote_status(jsonrpc
, target
, &status
);
790 /* Update status information columns. */
791 ovsdb_util_write_bool_column(rw_row
, "is_connected", status
.is_connected
);
794 keys
[n
] = xstrdup("state");
795 values
[n
++] = xstrdup(status
.state
);
797 if (status
.sec_since_connect
!= UINT_MAX
) {
798 keys
[n
] = xstrdup("sec_since_connect");
799 values
[n
++] = xasprintf("%u", status
.sec_since_connect
);
801 if (status
.sec_since_disconnect
!= UINT_MAX
) {
802 keys
[n
] = xstrdup("sec_since_disconnect");
803 values
[n
++] = xasprintf("%u", status
.sec_since_disconnect
);
805 if (status
.last_error
) {
806 keys
[n
] = xstrdup("last_error");
808 xstrdup(ovs_retval_to_string(status
.last_error
));
810 if (status
.locks_held
&& status
.locks_held
[0]) {
811 keys
[n
] = xstrdup("locks_held");
812 values
[n
++] = xstrdup(status
.locks_held
);
814 if (status
.locks_waiting
&& status
.locks_waiting
[0]) {
815 keys
[n
] = xstrdup("locks_waiting");
816 values
[n
++] = xstrdup(status
.locks_waiting
);
818 if (status
.locks_lost
&& status
.locks_lost
[0]) {
819 keys
[n
] = xstrdup("locks_lost");
820 values
[n
++] = xstrdup(status
.locks_lost
);
822 if (status
.n_connections
> 1) {
823 keys
[n
] = xstrdup("n_connections");
824 values
[n
++] = xasprintf("%d", status
.n_connections
);
826 if (status
.bound_port
!= htons(0)) {
827 keys
[n
] = xstrdup("bound_port");
828 values
[n
++] = xasprintf("%"PRIu16
, ntohs(status
.bound_port
));
830 ovsdb_util_write_string_string_column(rw_row
, "status", keys
, values
, n
);
832 ovsdb_jsonrpc_server_free_remote_status(&status
);
836 update_remote_rows(const struct shash
*all_dbs
,
837 const char *remote_name
,
838 const struct ovsdb_jsonrpc_server
*jsonrpc
)
840 const struct ovsdb_table
*table
, *ref_table
;
841 const struct ovsdb_column
*column
;
842 const struct ovsdb_row
*row
;
846 if (strncmp("db:", remote_name
, 3)) {
850 retval
= parse_db_column(all_dbs
, remote_name
, &db
, &table
, &column
);
856 if (column
->type
.key
.type
!= OVSDB_TYPE_UUID
857 || !column
->type
.key
.u
.uuid
.refTable
858 || column
->type
.value
.type
!= OVSDB_TYPE_VOID
) {
862 ref_table
= column
->type
.key
.u
.uuid
.refTable
;
864 HMAP_FOR_EACH (row
, hmap_node
, &table
->rows
) {
865 const struct ovsdb_datum
*datum
;
868 datum
= &row
->fields
[column
->index
];
869 for (i
= 0; i
< datum
->n
; i
++) {
870 const struct ovsdb_row
*ref_row
;
872 ref_row
= ovsdb_table_get_row(ref_table
, &datum
->keys
[i
].uuid
);
874 update_remote_row(ref_row
, db
->txn
, jsonrpc
);
881 update_remote_status(const struct ovsdb_jsonrpc_server
*jsonrpc
,
882 const struct sset
*remotes
,
883 struct shash
*all_dbs
)
885 static struct vlog_rate_limit rl
= VLOG_RATE_LIMIT_INIT(1, 1);
888 struct shash_node
*node
;
890 SHASH_FOR_EACH(node
, all_dbs
) {
892 db
->txn
= ovsdb_txn_create(db
->db
);
895 /* Iterate over --remote arguments given on command line. */
896 SSET_FOR_EACH (remote
, remotes
) {
897 update_remote_rows(all_dbs
, remote
, jsonrpc
);
900 SHASH_FOR_EACH(node
, all_dbs
) {
901 struct ovsdb_error
*error
;
903 error
= ovsdb_txn_commit(db
->txn
, false);
905 char *msg
= ovsdb_error_to_string(error
);
906 VLOG_ERR_RL(&rl
, "Failed to update remote status: %s", msg
);
908 ovsdb_error_destroy(error
);
913 /* Reconfigures ovsdb-server's remotes based on information in the database. */
915 reconfigure_remotes(struct ovsdb_jsonrpc_server
*jsonrpc
,
916 const struct shash
*all_dbs
, struct sset
*remotes
)
918 struct ds errors
= DS_EMPTY_INITIALIZER
;
919 struct shash resolved_remotes
;
922 /* Configure remotes. */
923 shash_init(&resolved_remotes
);
924 SSET_FOR_EACH (name
, remotes
) {
925 if (!strncmp(name
, "db:", 3)) {
926 query_db_remotes(name
, all_dbs
, &resolved_remotes
, &errors
);
928 add_remote(&resolved_remotes
, name
);
931 ovsdb_jsonrpc_server_set_remotes(jsonrpc
, &resolved_remotes
);
932 shash_destroy_free_data(&resolved_remotes
);
934 return errors
.string
;
938 reconfigure_ssl(const struct shash
*all_dbs
)
940 struct ds errors
= DS_EMPTY_INITIALIZER
;
941 const char *resolved_private_key
;
942 const char *resolved_certificate
;
943 const char *resolved_ca_cert
;
944 const char *resolved_ssl_protocols
;
945 const char *resolved_ssl_ciphers
;
947 resolved_private_key
= query_db_string(all_dbs
, private_key_file
, &errors
);
948 resolved_certificate
= query_db_string(all_dbs
, certificate_file
, &errors
);
949 resolved_ca_cert
= query_db_string(all_dbs
, ca_cert_file
, &errors
);
950 resolved_ssl_protocols
= query_db_string(all_dbs
, ssl_protocols
, &errors
);
951 resolved_ssl_ciphers
= query_db_string(all_dbs
, ssl_ciphers
, &errors
);
953 stream_ssl_set_key_and_cert(resolved_private_key
, resolved_certificate
);
954 stream_ssl_set_ca_cert_file(resolved_ca_cert
, bootstrap_ca_cert
);
955 stream_ssl_set_protocols(resolved_ssl_protocols
);
956 stream_ssl_set_ciphers(resolved_ssl_ciphers
);
958 return errors
.string
;
962 report_error_if_changed(char *error
, char **last_errorp
)
965 if (!*last_errorp
|| strcmp(error
, *last_errorp
)) {
966 VLOG_WARN("%s", error
);
968 *last_errorp
= error
;
979 ovsdb_server_set_active_ovsdb_server(struct unixctl_conn
*conn
,
980 int argc OVS_UNUSED
, const char *argv
[],
983 struct server_config
*config
= config_
;
985 if (*config
->sync_from
) {
986 free(*config
->sync_from
);
988 *config
->sync_from
= xstrdup(argv
[1]);
991 unixctl_command_reply(conn
, NULL
);
995 ovsdb_server_get_active_ovsdb_server(struct unixctl_conn
*conn
,
997 const char *argv
[] OVS_UNUSED
,
1000 struct server_config
*config
= config_
;
1002 unixctl_command_reply(conn
, *config
->sync_from
);
1006 ovsdb_server_connect_active_ovsdb_server(struct unixctl_conn
*conn
,
1007 int argc OVS_UNUSED
,
1008 const char *argv
[] OVS_UNUSED
,
1011 struct server_config
*config
= config_
;
1014 if ( !*config
->sync_from
) {
1015 msg
= "Unable to connect: active server is not specified.\n";
1017 const struct uuid
*server_uuid
;
1018 server_uuid
= ovsdb_jsonrpc_server_get_uuid(config
->jsonrpc
);
1019 ovsdb_replication_init(*config
->sync_from
, *config
->sync_exclude
,
1020 config
->all_dbs
, server_uuid
);
1021 if (!*config
->is_backup
) {
1022 *config
->is_backup
= true;
1023 save_config(config
);
1026 unixctl_command_reply(conn
, msg
);
1030 ovsdb_server_disconnect_active_ovsdb_server(struct unixctl_conn
*conn
,
1031 int argc OVS_UNUSED
,
1032 const char *argv
[] OVS_UNUSED
,
1035 struct server_config
*config
= config_
;
1037 disconnect_active_server();
1038 *config
->is_backup
= false;
1039 save_config(config
);
1040 unixctl_command_reply(conn
, NULL
);
1044 ovsdb_server_set_sync_exclude_tables(struct unixctl_conn
*conn
,
1045 int argc OVS_UNUSED
,
1049 struct server_config
*config
= config_
;
1051 char *err
= set_blacklist_tables(argv
[1], true);
1053 free(*config
->sync_exclude
);
1054 *config
->sync_exclude
= xstrdup(argv
[1]);
1055 save_config(config
);
1056 if (*config
->is_backup
) {
1057 const struct uuid
*server_uuid
;
1058 server_uuid
= ovsdb_jsonrpc_server_get_uuid(config
->jsonrpc
);
1059 ovsdb_replication_init(*config
->sync_from
, *config
->sync_exclude
,
1060 config
->all_dbs
, server_uuid
);
1062 err
= set_blacklist_tables(argv
[1], false);
1064 unixctl_command_reply(conn
, err
);
1069 ovsdb_server_get_sync_exclude_tables(struct unixctl_conn
*conn
,
1070 int argc OVS_UNUSED
,
1071 const char *argv
[] OVS_UNUSED
,
1072 void *arg_ OVS_UNUSED
)
1074 char *reply
= get_blacklist_tables();
1075 unixctl_command_reply(conn
, reply
);
1080 ovsdb_server_exit(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1081 const char *argv
[] OVS_UNUSED
,
1084 bool *exiting
= exiting_
;
1086 unixctl_command_reply(conn
, NULL
);
1090 ovsdb_server_perf_counters_show(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1091 const char *argv
[] OVS_UNUSED
,
1092 void *arg_ OVS_UNUSED
)
1094 char *s
= perf_counters_to_string();
1096 unixctl_command_reply(conn
, s
);
1101 ovsdb_server_perf_counters_clear(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1102 const char *argv
[] OVS_UNUSED
,
1103 void *arg_ OVS_UNUSED
)
1105 perf_counters_clear();
1106 unixctl_command_reply(conn
, NULL
);
1109 /* "ovsdb-server/disable-monitor-cond": makes ovsdb-server drop all of its
1110 * JSON-RPC connections and reconnect. New sessions will not recognize
1111 * the 'monitor_cond' method. */
1113 ovsdb_server_disable_monitor_cond(struct unixctl_conn
*conn
,
1114 int argc OVS_UNUSED
,
1115 const char *argv
[] OVS_UNUSED
,
1118 struct ovsdb_jsonrpc_server
*jsonrpc
= jsonrpc_
;
1119 bool read_only
= ovsdb_jsonrpc_server_is_read_only(jsonrpc
);
1121 ovsdb_jsonrpc_disable_monitor_cond();
1122 ovsdb_jsonrpc_server_reconnect(jsonrpc
, read_only
);
1123 unixctl_command_reply(conn
, NULL
);
1127 ovsdb_server_compact(struct unixctl_conn
*conn
, int argc
,
1128 const char *argv
[], void *dbs_
)
1130 struct shash
*all_dbs
= dbs_
;
1133 struct shash_node
*node
;
1137 SHASH_FOR_EACH(node
, all_dbs
) {
1139 if (argc
< 2 || !strcmp(argv
[1], node
->name
)) {
1140 struct ovsdb_error
*error
;
1142 VLOG_INFO("compacting %s database by user request", node
->name
);
1144 error
= ovsdb_file_compact(db
->file
);
1146 char *s
= ovsdb_error_to_string(error
);
1147 ds_put_format(&reply
, "%s\n", s
);
1149 ovsdb_error_destroy(error
);
1157 unixctl_command_reply_error(conn
, "no database by that name");
1158 } else if (reply
.length
) {
1159 unixctl_command_reply_error(conn
, ds_cstr(&reply
));
1161 unixctl_command_reply(conn
, NULL
);
1166 /* "ovsdb-server/reconnect": makes ovsdb-server drop all of its JSON-RPC
1167 * connections and reconnect. */
1169 ovsdb_server_reconnect(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1170 const char *argv
[] OVS_UNUSED
, void *jsonrpc_
)
1172 struct ovsdb_jsonrpc_server
*jsonrpc
= jsonrpc_
;
1173 bool read_only
= ovsdb_jsonrpc_server_is_read_only(jsonrpc
);
1175 ovsdb_jsonrpc_server_reconnect(jsonrpc
, read_only
);
1176 unixctl_command_reply(conn
, NULL
);
1179 /* "ovsdb-server/add-remote REMOTE": adds REMOTE to the set of remotes that
1180 * ovsdb-server services. */
1182 ovsdb_server_add_remote(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1183 const char *argv
[], void *config_
)
1185 struct server_config
*config
= config_
;
1186 const char *remote
= argv
[1];
1188 const struct ovsdb_column
*column
;
1189 const struct ovsdb_table
*table
;
1190 const struct db
*db
;
1193 retval
= (strncmp("db:", remote
, 3)
1195 : parse_db_column(config
->all_dbs
, remote
,
1196 &db
, &table
, &column
));
1198 if (sset_add(config
->remotes
, remote
)) {
1199 save_config(config
);
1201 unixctl_command_reply(conn
, NULL
);
1203 unixctl_command_reply_error(conn
, retval
);
1208 /* "ovsdb-server/remove-remote REMOTE": removes REMOTE frmo the set of remotes
1209 * that ovsdb-server services. */
1211 ovsdb_server_remove_remote(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1212 const char *argv
[], void *config_
)
1214 struct server_config
*config
= config_
;
1215 struct sset_node
*node
;
1217 node
= sset_find(config
->remotes
, argv
[1]);
1219 sset_delete(config
->remotes
, node
);
1220 save_config(config
);
1221 unixctl_command_reply(conn
, NULL
);
1223 unixctl_command_reply_error(conn
, "no such remote");
1227 /* "ovsdb-server/list-remotes": outputs a list of configured rmeotes. */
1229 ovsdb_server_list_remotes(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1230 const char *argv
[] OVS_UNUSED
, void *remotes_
)
1232 struct sset
*remotes
= remotes_
;
1233 const char **list
, **p
;
1238 list
= sset_sort(remotes
);
1239 for (p
= list
; *p
; p
++) {
1240 ds_put_format(&s
, "%s\n", *p
);
1244 unixctl_command_reply(conn
, ds_cstr(&s
));
1249 /* "ovsdb-server/add-db DB": adds the DB to ovsdb-server. */
1251 ovsdb_server_add_database(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1252 const char *argv
[], void *config_
)
1254 struct server_config
*config
= config_
;
1255 const char *filename
= argv
[1];
1258 error
= open_db(config
, filename
);
1260 save_config(config
);
1261 if (*config
->is_backup
) {
1262 const struct uuid
*server_uuid
;
1263 server_uuid
= ovsdb_jsonrpc_server_get_uuid(config
->jsonrpc
);
1264 ovsdb_replication_init(*config
->sync_from
, *config
->sync_exclude
,
1265 config
->all_dbs
, server_uuid
);
1267 unixctl_command_reply(conn
, NULL
);
1269 unixctl_command_reply_error(conn
, error
);
1275 ovsdb_server_remove_database(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1276 const char *argv
[], void *config_
)
1278 struct server_config
*config
= config_
;
1279 struct shash_node
*node
;
1283 node
= shash_find(config
->all_dbs
, argv
[1]);
1285 unixctl_command_reply_error(conn
, "Failed to find the database.");
1290 ok
= ovsdb_jsonrpc_server_remove_db(config
->jsonrpc
, db
->db
);
1294 shash_delete(config
->all_dbs
, node
);
1296 save_config(config
);
1297 if (*config
->is_backup
) {
1298 const struct uuid
*server_uuid
;
1299 server_uuid
= ovsdb_jsonrpc_server_get_uuid(config
->jsonrpc
);
1300 ovsdb_replication_init(*config
->sync_from
, *config
->sync_exclude
,
1301 config
->all_dbs
, server_uuid
);
1303 unixctl_command_reply(conn
, NULL
);
1307 ovsdb_server_list_databases(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1308 const char *argv
[] OVS_UNUSED
, void *all_dbs_
)
1310 struct shash
*all_dbs
= all_dbs_
;
1311 const struct shash_node
**nodes
;
1317 nodes
= shash_sort(all_dbs
);
1318 for (i
= 0; i
< shash_count(all_dbs
); i
++) {
1319 ds_put_format(&s
, "%s\n", nodes
[i
]->name
);
1323 unixctl_command_reply(conn
, ds_cstr(&s
));
1328 ovsdb_server_get_sync_status(struct unixctl_conn
*conn
, int argc OVS_UNUSED
,
1329 const char *argv
[] OVS_UNUSED
, void *config_
)
1331 struct server_config
*config
= config_
;
1332 bool is_backup
= *config
->is_backup
;
1333 struct ds ds
= DS_EMPTY_INITIALIZER
;
1335 ds_put_format(&ds
, "state: %s\n", is_backup
? "backup" : "active");
1338 ds_put_and_free_cstr(&ds
, replication_status());
1341 unixctl_command_reply(conn
, ds_cstr(&ds
));
1346 parse_options(int *argcp
, char **argvp
[],
1347 struct sset
*remotes
, char **unixctl_pathp
, char **run_command
,
1348 char **sync_from
, char **sync_exclude
, bool *active
)
1351 OPT_REMOTE
= UCHAR_MAX
+ 1,
1354 OPT_BOOTSTRAP_CA_CERT
,
1360 DAEMON_OPTION_ENUMS
,
1363 static const struct option long_options
[] = {
1364 {"remote", required_argument
, NULL
, OPT_REMOTE
},
1365 {"unixctl", required_argument
, NULL
, OPT_UNIXCTL
},
1367 {"run", required_argument
, NULL
, OPT_RUN
},
1369 {"help", no_argument
, NULL
, 'h'},
1370 {"version", no_argument
, NULL
, 'V'},
1371 DAEMON_LONG_OPTIONS
,
1373 {"bootstrap-ca-cert", required_argument
, NULL
, OPT_BOOTSTRAP_CA_CERT
},
1374 {"peer-ca-cert", required_argument
, NULL
, OPT_PEER_CA_CERT
},
1375 STREAM_SSL_LONG_OPTIONS
,
1376 {"sync-from", required_argument
, NULL
, OPT_SYNC_FROM
},
1377 {"sync-exclude-tables", required_argument
, NULL
, OPT_SYNC_EXCLUDE
},
1378 {"active", no_argument
, NULL
, OPT_ACTIVE
},
1381 char *short_options
= ovs_cmdl_long_options_to_short_options(long_options
);
1383 char **argv
= *argvp
;
1386 *sync_exclude
= NULL
;
1391 c
= getopt_long(argc
, argv
, short_options
, long_options
, NULL
);
1398 sset_add(remotes
, optarg
);
1402 *unixctl_pathp
= optarg
;
1406 *run_command
= optarg
;
1413 ovs_print_version(0, 0);
1416 VLOG_OPTION_HANDLERS
1417 DAEMON_OPTION_HANDLERS
1420 private_key_file
= optarg
;
1424 certificate_file
= optarg
;
1428 ca_cert_file
= optarg
;
1429 bootstrap_ca_cert
= false;
1432 case OPT_SSL_PROTOCOLS
:
1433 ssl_protocols
= optarg
;
1436 case OPT_SSL_CIPHERS
:
1437 ssl_ciphers
= optarg
;
1440 case OPT_BOOTSTRAP_CA_CERT
:
1441 ca_cert_file
= optarg
;
1442 bootstrap_ca_cert
= true;
1445 case OPT_PEER_CA_CERT
:
1446 stream_ssl_set_peer_ca_cert_file(optarg
);
1450 *sync_from
= xstrdup(optarg
);
1453 case OPT_SYNC_EXCLUDE
: {
1454 char *err
= set_blacklist_tables(optarg
, false);
1456 ovs_fatal(0, "%s", err
);
1458 *sync_exclude
= xstrdup(optarg
);
1472 free(short_options
);
1481 printf("%s: Open vSwitch database server\n"
1482 "usage: %s [OPTIONS] [DATABASE...]\n"
1483 "where each DATABASE is a database file in ovsdb format.\n"
1484 "The default DATABASE, if none is given, is\n%s/conf.db.\n",
1485 program_name
, program_name
, ovs_dbdir());
1486 printf("\nJSON-RPC options (may be specified any number of times):\n"
1487 " --remote=REMOTE connect or listen to REMOTE\n");
1488 stream_usage("JSON-RPC", true, true, true);
1491 replication_usage();
1492 printf("\nOther options:\n"
1493 " --run COMMAND run COMMAND as subprocess then exit\n"
1494 " --unixctl=SOCKET override default control socket name\n"
1495 " -h, --help display this help message\n"
1496 " -V, --version display version information\n");
1500 static struct json
*
1501 sset_to_json(const struct sset
*sset
)
1506 array
= json_array_create_empty();
1507 SSET_FOR_EACH (s
, sset
) {
1508 json_array_add(array
, json_string_create(s
));
1513 /* Truncates and replaces the contents of 'config_file' by a representation of
1514 * 'remotes' and 'db_filenames'. */
1516 save_config__(FILE *config_file
, const struct sset
*remotes
,
1517 const struct sset
*db_filenames
, const char *sync_from
,
1518 const char *sync_exclude
, bool is_backup
)
1523 if (ftruncate(fileno(config_file
), 0) == -1) {
1524 VLOG_FATAL("failed to truncate temporary file (%s)",
1525 ovs_strerror(errno
));
1528 obj
= json_object_create();
1529 json_object_put(obj
, "remotes", sset_to_json(remotes
));
1530 json_object_put(obj
, "db_filenames", sset_to_json(db_filenames
));
1532 json_object_put(obj
, "sync_from", json_string_create(sync_from
));
1535 json_object_put(obj
, "sync_exclude",
1536 json_string_create(sync_exclude
));
1538 json_object_put(obj
, "is_backup", json_boolean_create(is_backup
));
1540 s
= json_to_string(obj
, 0);
1543 if (fseek(config_file
, 0, SEEK_SET
) != 0
1544 || fputs(s
, config_file
) == EOF
1545 || fflush(config_file
) == EOF
) {
1546 VLOG_FATAL("failed to write temporary file (%s)", ovs_strerror(errno
));
1551 /* Truncates and replaces the contents of 'config_file' by a representation of
1554 save_config(struct server_config
*config
)
1556 struct sset db_filenames
;
1557 struct shash_node
*node
;
1559 sset_init(&db_filenames
);
1560 SHASH_FOR_EACH (node
, config
->all_dbs
) {
1561 struct db
*db
= node
->data
;
1562 sset_add(&db_filenames
, db
->filename
);
1565 save_config__(config
->config_tmpfile
, config
->remotes
, &db_filenames
,
1566 *config
->sync_from
, *config
->sync_exclude
,
1567 *config
->is_backup
);
1569 sset_destroy(&db_filenames
);
1573 sset_from_json(struct sset
*sset
, const struct json
*array
)
1579 ovs_assert(array
->type
== JSON_ARRAY
);
1580 for (i
= 0; i
< array
->u
.array
.n
; i
++) {
1581 const struct json
*elem
= array
->u
.array
.elems
[i
];
1582 sset_add(sset
, json_string(elem
));
1586 /* Clears and replaces 'remotes' and 'dbnames' by a configuration read from
1587 * 'config_file', which must have been previously written by save_config(). */
1589 load_config(FILE *config_file
, struct sset
*remotes
, struct sset
*db_filenames
,
1590 char **sync_from
, char **sync_exclude
, bool *is_backup
)
1594 if (fseek(config_file
, 0, SEEK_SET
) != 0) {
1595 VLOG_FATAL("seek failed in temporary file (%s)", ovs_strerror(errno
));
1597 json
= json_from_stream(config_file
);
1598 if (json
->type
== JSON_STRING
) {
1599 VLOG_FATAL("reading json failed (%s)", json_string(json
));
1601 ovs_assert(json
->type
== JSON_OBJECT
);
1603 sset_from_json(remotes
, shash_find_data(json_object(json
), "remotes"));
1604 sset_from_json(db_filenames
,
1605 shash_find_data(json_object(json
), "db_filenames"));
1607 struct json
*string
;
1608 string
= shash_find_data(json_object(json
), "sync_from");
1610 *sync_from
= string
? xstrdup(json_string(string
)) : NULL
;
1612 string
= shash_find_data(json_object(json
), "sync_exclude");
1613 free(*sync_exclude
);
1614 *sync_exclude
= string
? xstrdup(json_string(string
)) : NULL
;
1616 *is_backup
= json_boolean(shash_find_data(json_object(json
), "is_backup"));