From: Justin Pettit Date: Fri, 3 Apr 2009 21:56:32 +0000 (-0700) Subject: Use new vswitchd management settings when they change. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4bfa30106bfa18ce963b671a0c4ef5cf91d3f4ec;p=openvswitch Use new vswitchd management settings when they change. When changes were made to the "mgmt" section of vswitchd.conf, we weren't noticing changes if the major sections were not modified. Thanks to Dan for reporting this. --- diff --git a/lib/cfg.c b/lib/cfg.c index 4fbaa9ca..916cb932 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -540,6 +540,30 @@ cfg_del_section(const char *section_, ...) dirty = true; } + +/* Fills 'svec' with all of the key-value pairs that have sections that + * begin with 'section'. The caller must first initialize 'svec'. */ +void +cfg_get_section(struct svec *svec, const char *section_, ...) +{ + struct ds section; + va_list args; + char **p; + + ds_init(§ion); + va_start(args, section_); + ds_put_format_valist(§ion, section_, args); + ds_put_char(§ion, '.'); + va_end(args); + + for (p = cfg.names; *p; p++) { /* XXX this is inefficient */ + if (!strncmp(section.string, *p, section.length)) { + svec_add(svec, *p); + } + } + ds_destroy(§ion); +} + /* Returns the value numbered 'idx' of 'key'. Returns a null pointer if 'idx' * is greater than or equal to cfg_count(key). The caller must not modify or * free the returned string or retain its value beyond the next call to diff --git a/lib/cfg.h b/lib/cfg.h index c2f7d17f..8ecace94 100644 --- a/lib/cfg.h +++ b/lib/cfg.h @@ -70,6 +70,8 @@ void cfg_register(const char *key_spec, enum cfg_flags); void cfg_add_entry(const char *key, ...) PRINTF_FORMAT(1, 2); void cfg_del_entry(const char *key, ...) PRINTF_FORMAT(1, 2); void cfg_del_section(const char *key, ...) PRINTF_FORMAT(1, 2); +void cfg_get_section(struct svec *svec, const char *key, ...) + PRINTF_FORMAT(2, 3); bool cfg_has(const char *key, ...) PRINTF_FORMAT(1, 2); bool cfg_is_valid(enum cfg_flags, const char *key, ...) PRINTF_FORMAT(2, 3); diff --git a/vswitchd/mgmt.c b/vswitchd/mgmt.c index 02313bda..ab1b36a9 100644 --- a/vswitchd/mgmt.c +++ b/vswitchd/mgmt.c @@ -156,7 +156,7 @@ mgmt_reconfigure(void) } svec_init(&new_cfg); - cfg_get_subsections(&new_cfg, "mgmt"); + cfg_get_section(&new_cfg, "mgmt"); if (svec_equal(&mgmt_cfg, &new_cfg)) { /* Reconnecting to the controller causes the config file to be * resent automatically. If we're not reconnecting and the @@ -165,12 +165,14 @@ mgmt_reconfigure(void) if (cfg_updated && mgmt_rconn) { send_config_update(0, false); } + svec_destroy(&new_cfg); return; } controller_name = cfg_get_string(0, "mgmt.controller"); if (!controller_name) { VLOG_ERR("no controller specified for managment"); + svec_destroy(&new_cfg); return; } @@ -210,11 +212,9 @@ mgmt_reconfigure(void) mgmt_rconn = NULL; } mgmt_rconn = rconn_create(inactivity_probe, max_backoff); - if (controller_name) { - retval = rconn_connect(mgmt_rconn, controller_name); - if (retval == EAFNOSUPPORT) { - VLOG_ERR("no support for %s vconn", controller_name); - } + retval = rconn_connect(mgmt_rconn, controller_name); + if (retval == EAFNOSUPPORT) { + VLOG_ERR("no support for %s vconn", controller_name); } }