[ovs-dev] [PATCH 1/2] ovs-ctl.in: Call 'hostname -f' after vswitchd starts.

Gurucharan Shetty guru at ovn.org
Fri Oct 6 11:08:22 UTC 2017


Currently we call 'hostname -f' when ovs-vswitchd is not
running. If you are using ovs-vswitchd to provide your
primary networking, then 'hostname -f' will "hang" till it
times out. On the system this issue was discovered, this was
as long as 40 seconds. This is a problem during OVS restarts
or upgrades.

This commit calls 'hostname -f' after ovs-vswitchd has started.

Signed-off-by: Gurucharan Shetty <guru at ovn.org>
---
 utilities/ovs-ctl.in | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index dc1d02c..97c3c09 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -75,6 +75,12 @@ ovs_vsctl () {
     ovs-vsctl --no-wait "$@"
 }
 
+set_hostname () {
+    # 'hostname -f' needs network connectivity to work.  So we should
+    # call this only after ovs-vswitchd is running.
+    ovs_vsctl set Open_vSwitch . external-ids:hostname=$(hostname -f)
+}
+
 set_system_ids () {
     set ovs_vsctl set Open_vSwitch .
 
@@ -108,8 +114,6 @@ set_system_ids () {
     esac
     set "$@" external-ids:system-id="\"$SYSTEM_ID\""
 
-    set "$@" external-ids:hostname="\"$(hostname -f)\""
-
     set "$@" external-ids:rundir="\"$rundir\""
 
     if test X"$SYSTEM_TYPE" != X; then
@@ -382,6 +386,7 @@ force_reload_kmod () {
     else
         log_warning_msg "Failed to save configuration, not replacing kernel module"
         start_forwarding
+        set_hostname
         add_managers
         exit 1
     fi
@@ -405,6 +410,7 @@ force_reload_kmod () {
     # Start vswitchd by asking it to wait till flow restore is finished.
     flow_restore_wait
     start_forwarding || return 1
+    set_hostname
 
     # Restore saved flows and inform vswitchd that we are done.
     restore_flows
@@ -438,6 +444,7 @@ restart () {
     # Start vswitchd by asking it to wait till flow restore is finished.
     flow_restore_wait
     start_forwarding || return 1
+    set_hostname
 
     # Restore saved flows and inform vswitchd that we are done.
     restore_flows
@@ -695,6 +702,7 @@ case $command in
     start)
         start_ovsdb || exit 1
         start_forwarding || exit 1
+        set_hostname
         add_managers
         ;;
     stop)
-- 
1.9.1



More information about the dev mailing list