[ovs-dev] [PATCH] ovs-ctl: Allow recording hostname separately

Frode Nordahl frode.nordahl at canonical.com
Tue Feb 16 14:30:57 UTC 2021


ovs-ctl determines the system FQDN or hostname and records it in
the `external-ids:hostname` field of the `Open-vSwitch` table on
system startup.

This value may be consumed by downstream software and having it
unset or set to a incorrect value could lead to erratic behavior
of a system.

When a system is configured to use a Open vSwitch controlled
datapath as its only network connection, the current ordering of
events would always produce a unreliable hostname

Reported-At: https://bugs.launchpad.net/bugs/1915829
Signed-off-by: Frode Nordahl <frode.nordahl at canonical.com>
---
 utilities/ovs-ctl.in | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index be3aa083b..9231ae4f4 100644
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -230,7 +230,9 @@ start_forwarding () {
     if test X"$OVS_VSWITCHD" = Xyes; then
         do_start_forwarding || return 1
     fi
-    set_hostname &
+    if test X"$RECORD_HOSTNAME" = Xyes; then
+        set_hostname &
+    fi
     return 0
 }
 
@@ -321,6 +323,7 @@ set_defaults () {
     SYSTEM_ID=
 
     FULL_HOSTNAME=yes
+    RECORD_HOSTNAME=yes
 
     DELETE_BRIDGES=no
     DELETE_TRANSIENT_PORTS=no
@@ -394,6 +397,8 @@ Commands:
   delete-transient-ports  delete transient (other_config:transient=true) ports
   start-ovs-ipsec         start Open vSwitch ipsec daemon
   stop-ovs-ipsec          stop Open vSwitch ipsec daemon
+  record-hostname         determine the system hostname and record it in the
+                          Open vSwitch database if not already set
   help                    display this help message
 
 One of the following options is required for "start", "restart" and "force-reload-kmod":
@@ -415,6 +420,8 @@ Less important options for "start", "restart" and "force-reload-kmod":
   --ovsdb-server-priority=NICE   set ovsdb-server's niceness (default: $OVSDB_SERVER_PRIORITY)
   --ovs-vswitchd-priority=NICE   set ovs-vswitchd's niceness (default: $OVS_VSWITCHD_PRIORITY)
   --no-full-hostname             set short hostname instead of full hostname
+  --no-record-hostname           do not attempt to determine/record system
+                                 hostname as part of start command
 
 Debugging options for "start", "restart" and "force-reload-kmod":
   --ovsdb-server-wrapper=WRAPPER
@@ -573,6 +580,9 @@ case $command in
     stop-ovs-ipsec)
         stop_ovs_ipsec
         ;;
+    record-hostname)
+        set_hostname
+        ;;
     help)
         usage
         ;;
-- 
2.30.0



More information about the dev mailing list