X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=utilities%2Fovs-ctl.in;h=5ad5f26009b9917fb455f05bf9df350c218357f2;hb=e40686f3016dbd25a85143a4dcc2777f75f95b87;hp=78f67a3e7bc8388780e0530fa7656dbdece3ac56;hpb=167744623897a67ef3fd13bcaf44a84d3641fe68;p=sliver-openvswitch.git diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index 78f67a3e7..5ad5f2600 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2009, 2010, 2011, 2012 Nicira, Inc. +# Copyright (C) 2009, 2010, 2011, 2012, 2013 Nicira, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -57,7 +57,7 @@ insert_mod_if_required () { } ovs_vsctl () { - ovs-vsctl --no-wait --timeout=5 "$@" + ovs-vsctl --no-wait "$@" } ovsdb_tool () { @@ -157,7 +157,7 @@ set_system_ids () { check_force_cores () { if test X"$FORCE_COREFILES" = Xyes; then - ulimit -Sc 67108864 + ulimit -c 67108864 fi } @@ -216,8 +216,9 @@ start_forwarding () { log_success_msg "ovs-vswitchd is already running" else # Increase the limit on the number of open file descriptors. - # ovs-vswitchd needs 16 per datapath, plus a few extra, so this - # should allow for 256 (or more) bridges. + # On Linux, ovs-vswitchd needs about one file descriptor per + # switch port, so this allows a very large number of switch + # ports. ulimit -n 5000 # Start ovs-vswitchd. @@ -274,7 +275,6 @@ ovs_save () { chmod +x "$2" return 0 fi - eval $3="" [ -z "${bridges}" ] && return 0 } @@ -283,9 +283,7 @@ save_ofports_if_required () { case `ovs-appctl version | sed 1q` in "ovs-vswitchd (Open vSwitch) 1."[0-9].*) action "Saving ofport values" ovs_save save-ofports \ - "${script_ofports}" script_ofports - ;; - *) + "${script_ofports}" ;; esac } @@ -296,25 +294,43 @@ save_interfaces () { } restore_ofports () { - [ -n "${script_ofports}" ] && \ + [ -x "${script_ofports}" ] && \ action "Restoring ofport values" "${script_ofports}" } restore_flows () { - [ -n "${script_flows}" ] && \ + [ -x "${script_flows}" ] && \ action "Restoring saved flows" "${script_flows}" } -force_reload_kmod () { - ifaces=`internal_interfaces` - action "Detected internal interfaces: $ifaces" true +restore_interfaces () { + [ ! -x "${script_interfaces}" ] && return 0 + action "Restoring interface configuration" "${script_interfaces}" + rc=$? + if test $rc = 0; then + level=debug + else + level=err + fi + log="logger -p daemon.$level -t ovs-save" + $log "interface restore script exited with status $rc:" + $log -f "$script_interfaces" +} +init_restore_scripts () { script_interfaces=`mktemp` script_flows=`mktemp` script_ofports=`mktemp` trap 'rm -f "${script_interfaces}" "${script_flows}" "${script_ofports}"' 0 +} + +force_reload_kmod () { + ifaces=`internal_interfaces` + action "Detected internal interfaces: $ifaces" true + + init_restore_scripts - action "Saving flows" ovs_save save-flows "${script_flows}" script_flows + action "Saving flows" ovs_save save-flows "${script_flows}" save_ofports_if_required @@ -352,16 +368,7 @@ force_reload_kmod () { restore_flows - action "Restoring interface configuration" "$script_interfaces" - rc=$? - if test $rc = 0; then - level=debug - else - level=err - fi - log="logger -p daemon.$level -t ovs-save" - $log "force-reload-kmod interface restore script exited with status $rc:" - $log -f "$script_interfaces" + restore_interfaces "$datadir/scripts/ovs-check-dead-ifs" } @@ -370,13 +377,25 @@ force_reload_kmod () { ## restart ## ## ------- ## +save_interfaces_if_required () { + # Save interfaces if we are upgrading from a pre-1.10 branch. + case `ovs-appctl version | sed 1q` in + "ovs-vswitchd (Open vSwitch) 1."[0-9].*) + ifaces=`internal_interfaces` + action "Detected internal interfaces: $ifaces" true + if action "Saving interface configuration" save_interfaces; then + chmod +x "$script_interfaces" + fi + ;; + esac +} + restart () { if daemon_is_running ovsdb-server && daemon_is_running ovs-vswitchd; then - script_flows=`mktemp` - trap 'rm -f "${script_flows}"' 0 - - action "Saving flows" ovs_save save-flows "${script_flows}" \ - script_flows + init_restore_scripts + save_interfaces_if_required + action "Saving flows" ovs_save save-flows "${script_flows}" + save_ofports_if_required fi # Restart the database first, since a large database may take a @@ -384,11 +403,18 @@ restart () { stop_ovsdb start_ovsdb + # Restore of ofports, if required, should happen before vswitchd is + # restarted. + restore_ofports + stop_forwarding start_forwarding - # Restore the saved flows. Do not return error if restore fails. - restore_flows || true + # Restore the saved flows. + restore_flows + + # Restore the interfaces if required. Return true even if restore fails. + restore_interfaces || true } ## --------------- ##