From: Ben Pfaff Date: Fri, 16 Jan 2009 00:08:00 +0000 (-0800) Subject: brcompat: Don't re-read configuration file from inside bridge code. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b34f542b1015b69c589bc4fa324d236cd35dd5f;p=openvswitch brcompat: Don't re-read configuration file from inside bridge code. brc_modify_config() re-reads the configuration files by calling cfg_read(), but we don't want to do that when we're deep inside the bridge code, in the call to brc_modify_config() from phy_port_changed(). So only call cfg_read() from the callers of brc_modify_config() that are in brcompat.c. Also, each cfg_read() call was followed by a call to bridge_reconfigure(), which is what reconfigure() in vswitchd.c does, so just use that function instead of open-coding the pair of calls. This should not have caused a real problem, because no pointers into configuration data are retained by bridge code, but it still seems like the "correct" way to do things. --- diff --git a/vswitchd/brcompat.c b/vswitchd/brcompat.c index 39f0b4a7..c6f18e77 100644 --- a/vswitchd/brcompat.c +++ b/vswitchd/brcompat.c @@ -58,6 +58,7 @@ #include "timeval.h" #include "util.h" #include "vlog-socket.h" +#include "vswitchd.h" #include "vlog.h" #define THIS_MODULE VLM_brcompat @@ -251,8 +252,6 @@ brc_modify_config(const char *dp_name, const char *port_name, brc_write_config(&new_cfg); svec_destroy(&new_cfg); - - cfg_read(); } static int @@ -263,8 +262,7 @@ brc_add_dp(const char *dp_name) } brc_modify_config(dp_name, NULL, BMC_ADD_DP); - - bridge_reconfigure(); + reconfigure(); if (!bridge_exists(dp_name)) { return EINVAL; @@ -281,8 +279,7 @@ brc_del_dp(const char *dp_name) } brc_modify_config(dp_name, NULL, BMC_DEL_DP); - - bridge_reconfigure(); + reconfigure(); if (bridge_exists(dp_name)) { return EINVAL; @@ -355,9 +352,7 @@ brc_handle_port_cmd(struct ofpbuf *buffer, bool add) } else { brc_modify_config(dp_name, port_name, BMC_DEL_PORT); } - - /* Force vswitchd to reconfigure itself. */ - bridge_reconfigure(); + reconfigure(); return 0; } diff --git a/vswitchd/vswitchd.c b/vswitchd/vswitchd.c index dc1cfa1d..85bf19c3 100644 --- a/vswitchd/vswitchd.c +++ b/vswitchd/vswitchd.c @@ -26,6 +26,8 @@ #include +#include "vswitchd.h" + #include #include #include @@ -57,8 +59,6 @@ static void parse_options(int argc, char *argv[]); static void usage(void) NO_RETURN; -static void reconfigure(void); - static bool brc_enabled = false; int @@ -106,7 +106,7 @@ main(int argc, char *argv[]) return 0; } -static void +void reconfigure(void) { cfg_read(); diff --git a/vswitchd/vswitchd.h b/vswitchd/vswitchd.h new file mode 100644 index 00000000..53202863 --- /dev/null +++ b/vswitchd/vswitchd.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2009 Nicira Networks + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * In addition, as a special exception, Nicira Networks gives permission + * to link the code of its release of vswitchd with the OpenSSL project's + * "OpenSSL" library (or with modified versions of it that use the same + * license as the "OpenSSL" library), and distribute the linked + * executables. You must obey the GNU General Public License in all + * respects for all of the code used other than "OpenSSL". If you modify + * this file, you may extend this exception to your version of the file, + * but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. + */ + +#ifndef VSWITCHD_H +#define VSWITCHD_H 1 + +void reconfigure(void); + +#endif /* vswitchd.h */