datapath: Don't call genlmsg_reply() under rcu_read_lock().
[openvswitch] / debian / openvswitch-switch.init
index 96eb00cf89b393e1e34b2c9fe0de9e98ae560e80..8ea58660657ce099d14a25ca9364f872e3c988b6 100755 (executable)
@@ -193,6 +193,23 @@ unload_modules() {
     unload_module openvswitch_mod
 }
 
+set_system_info() {
+    ovs_version=`ovs-vswitchd --version | sed 's/.*) //;1q'`
+    ovs-vsctl --no-wait --timeout=5 set Open_vSwitch . \
+        ovs-version="$ovs_version"
+
+    if (lsb_release --id) >/dev/null 2>&1; then
+        system_type=`lsb_release --id -s`
+        system_release=`lsb_release --release -s`
+        system_codename=`lsb_release --codename -s`
+        system_version="${system_release}-${system_codename}"
+
+        ovs-vsctl --no-wait --timeout=5 set Open_vSwitch . \
+            system-type="$system_type" \
+            system-version="$system_version"
+    fi
+}
+
 case "$1" in
     start)
         conf_file=/etc/openvswitch/conf.db
@@ -209,13 +226,24 @@ case "$1" in
         if test ! -e $conf_file; then
             # Create configuration database.
             ovsdb-tool -vANY:console:emer create $conf_file $schema_file
-        else
-            # If schema version changed, then back up the old version.
-            old_ver=`ovsdb-tool db-version "$conf_file"`
-            if test "X$old_ver" != "X$schema_ver"; then
-                cp "$conf_file" "$conf_file.backup$old_ver"
-            fi
+        elif test "X`ovsdb-tool needs-conversion $conf_file $schema_file`" != Xno; then
+            # Back up the old version.
+            version=`ovsdb-tool db-version "$conf_file"`
+            cksum=`ovsdb-tool db-cksum "$conf_file" | awk '{print $1}'`
+            cp "$conf_file" "$conf_file.backup$version-$cksum"
             
+            # Compact database.  This is important if the old schema did not
+            # enable garbage collection (i.e. if it did not have any tables
+            # with "isRoot": true) but the new schema does.  In that situation
+            # the old database may contain a transaction that creates a record
+            # followed by a transaction that creates the first use of the
+            # record.  Replaying that series of transactions against the new
+            # database schema (as "convert" does) would cause the record to be
+            # dropped by the first transaction, then the second transaction
+            # would cause a referential integrity failure (for a strong
+            # reference).
+            ovsdb-tool -vANY:console:emer compact $conf_file
+
             # Upgrade or downgrade schema and compact database.
             ovsdb-tool -vANY:console:emer convert $conf_file $schema_file
         fi
@@ -245,7 +273,6 @@ case "$1" in
         set -- "$@" --log-file=/var/log/openvswitch/ovsdb-server.log
         set -- "$@" --detach --no-chdir --pidfile $monitor_opt
         set -- "$@" --remote punix:/var/run/openvswitch/db.sock
-        set -- "$@" --remote db:Open_vSwitch,managers
         set -- "$@" --remote db:Open_vSwitch,manager_options
         set -- "$@" --private-key=db:SSL,private_key
         set -- "$@" --certificate=db:SSL,certificate
@@ -264,6 +291,8 @@ case "$1" in
 
         ovs-vsctl --no-wait --timeout=5 init -- set Open_vSwitch . db-version="$schema_ver"
 
+        set_system_info
+
         # Start ovs-vswitchd.
         set --
         set -- "$@" --verbose=ANY:console:emer --verbose=ANY:syslog:err