From 0311d4f48ddfeb5f7d25b45d53168c02603bcf62 Mon Sep 17 00:00:00 2001 From: Gurucharan Shetty Date: Tue, 6 Nov 2012 11:11:30 -0800 Subject: [PATCH] ovs-ctl.in: Don't save kernel datapath config. Commit a41754333f6 (ovs-ctl.in: Ability to save flows and kernel datapath config.) made ovs-ctl able to usefully save and restore the flow table across loading and unloading the OVS kernel module and stopping and starting the OVS daemons. To ensure that the flow table was still meaningful, it ensured that the datapath port numbers were the same with the old and new versions of the kernel module. However, later commit e1b1d06afde (Separate OpenFlow port numbers from datapath ones.) changed the OpenFlow implementation so that keeping the same datapath port numbers no longer ensured that the OpenFlow port numbers would be the same. This caused a regression in saving and restoring the flow table. Although the flow table was still saved and restored, it was no longer useful, since the datapath port numbers might change. This commit does not fix the regression, but it does drop the code that saves and restores the port datapath numbers, since it is no longer useful. The following commit fixes the regression. Signed-off-by: Gurucharan Shetty --- utilities/ovs-ctl.8 | 9 +++-- utilities/ovs-ctl.in | 31 ++--------------- utilities/ovs-save | 82 -------------------------------------------- 3 files changed, 7 insertions(+), 115 deletions(-) diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8 index 3092d463..04c29305 100644 --- a/utilities/ovs-ctl.8 +++ b/utilities/ovs-ctl.8 @@ -287,8 +287,7 @@ implemented by Open vSwitch. The most common examples of these are bridge ``local ports''. . .IP 2. -Saves the Openflow flows of each bridge and the kernel datapath -configuration for each of the kernel datapaths. +Saves the Openflow flows of each bridge. . .IP 3. Stops the Open vSwitch daemons, as if by a call to \fBovs\-ctl @@ -305,9 +304,9 @@ compatibility module if it is loaded). . .IP 6. Starts OVS back up, as if by a call to \fBovs\-ctl start\fR. This -reloads the kernel module, restores the saved kernel datapath configuration, -restarts the OVS daemons (including \fBovs\-brcompatd\fR, if \fB\-\-brcompat\fR -is specified) and finally restores the saved Openflow flows. +reloads the kernel module, restarts the OVS daemons (including +\fBovs\-brcompatd\fR, if \fB\-\-brcompat\fR is specified) and finally +restores the saved Openflow flows. . .IP 7. Restores the kernel configuration state that was saved in step 4. diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in index 7febd1c2..be481dec 100755 --- a/utilities/ovs-ctl.in +++ b/utilities/ovs-ctl.in @@ -30,21 +30,13 @@ done ## start ## ## ----- ## -restore_datapaths () { - [ -n "${script_datapaths}" ] && \ - action "Restoring datapath configuration" "${script_datapaths}" -} - insert_openvswitch_mod_if_required () { # If openvswitch is already loaded then we're done. test -e /sys/module/openvswitch -o -e /sys/module/openvswitch_mod && \ return 0 # Load openvswitch. If that's successful then we're done. - if action "Inserting openvswitch module" modprobe openvswitch; then - restore_datapaths - return 0 - fi + action "Inserting openvswitch module" modprobe openvswitch && return 0 # If the bridge module is loaded, then that might be blocking # openvswitch. Try to unload it, if there are no bridges. @@ -58,7 +50,6 @@ insert_openvswitch_mod_if_required () { # Try loading openvswitch again. action "Inserting openvswitch module" modprobe openvswitch - restore_datapaths } insert_brcompat_mod_if_required () { @@ -319,11 +310,6 @@ save_interfaces () { > "${script_interfaces}" } -save_datapaths () { - "$datadir/scripts/ovs-save" save-datapaths ${datapaths} \ - > "${script_datapaths}" -} - restore_flows () { [ -n "${script_flows}" ] && \ action "Restoring saved flows" "${script_flows}" @@ -334,10 +320,8 @@ force_reload_kmod () { action "Detected internal interfaces: $ifaces" true script_interfaces=`mktemp` - script_datapaths=`mktemp` script_flows=`mktemp` - trap 'rm -f "${script_interfaces}" "${script_flows}" \ - "${script_datapaths}"' 0 1 2 13 15 + trap 'rm -f "${script_interfaces}" "${script_flows}" ' 0 1 2 13 15 action "Saving flows" save_flows @@ -357,16 +341,7 @@ force_reload_kmod () { fi chmod +x "$script_interfaces" - datapaths=`ovs-dpctl dump-dps` - if action "Saving datapath configuration" save_datapaths; then - chmod +x "${script_datapaths}" - else - log_warning_msg "Failed to save datapath configuration. The port\ - numbers may change after the restart" - script_datapaths="" - fi - - for dp in ${datapaths}; do + for dp in `ovs-dpctl dump-dps`; do action "Removing datapath: $dp" ovs-dpctl del-dp "$dp" done diff --git a/utilities/ovs-save b/utilities/ovs-save index 2f702213..2ab9d086 100755 --- a/utilities/ovs-save +++ b/utilities/ovs-save @@ -27,9 +27,6 @@ Commands: configuration. save-flows Outputs a shell script on stdout that will restore Openflow flows of each Open vSwitch bridge. - save-datapaths Outputs a shell script on stdout that will restore - the datapaths with the same port numbers as before. - This script is meant as a helper for the Open vSwitch init script commands. EOF } @@ -177,89 +174,10 @@ save_flows () { done } -ovs_vsctl () { - ovs-vsctl --no-wait --timeout=5 "$@" -} - -save_datapaths () { - if missing_program ovs-dpctl; then - echo "$0: ovs-dpctl not found in $PATH" >&2 - exit 1 - fi - if missing_program ovs-vsctl; then - echo "$0: ovs-vsctl not found in $PATH" >&2 - exit 1 - fi - - for dp in "$@"; do - echo "ovs-dpctl add-dp ${dp}" - ovs-dpctl show $dp | while read line; do - # An example 'ovs-dpctl show' output looks like this: - # system@br1: - # lookups: hit:0 missed:0 lost:0 - # flows: 0 - # port 0: br1 (internal) - # port 2: gre2886795521 (ipsec_gre: key=flow, remote_ip=172.17.1.1, tos=inherit) - # port 3: gre1 (ipsec_gre: remote_ip=192.168.113.1) - # port 14: gre2 (gre: remote_ip=192.168.115.1) - # port 15: gre3 (gre64: remote_ip=192.168.116.1) - # port 16: eth0 - # port 17: br1- (patch: peer=br1+) - - # Skip lines which do not have 'port' - if port_no=`expr "${line}" : '.*port \([0-9]\+\):'`; then :; else - continue - fi - - netdev=`echo ${line} | awk '{print $3}'` - - # Do not add port that has the same name as the datapath. It gets - # added by default. - [ "${dp#system@}" = "${netdev}" ] && continue - - type=`echo ${line} | awk '{print $4}' | sed 's/[:)(]//g'` - [ ! -n "${type}" ] && type="system" - - command="ovs-dpctl add-if ${dp}\ - ${netdev},type=${type},port_no=${port_no}" - - options=`echo ${line} | awk -F: '{print $3}' | sed 's/[) ]//g'` - [ -n "${options}" ] && command="${command},${options}" - - # For ipsec, ovs-dpctl does not show the key value pairs related - # to certificates. Get that information from ovs-vsctl. - if [ "${type}" = "ipsec_gre" ] ; then - if peer_cert=`ovs_vsctl get interface \ - "${netdev}" options:peer_cert 2>/dev/null`; then - # The option peer_cert comes with an accompanying - # "certificate" or "use_ssl_cert" - if certificate=`ovs_vsctl get interface "${netdev}" \ - options:certificate 2>/dev/null` ; then - command="${command},peer_cert=${peer_cert},certificate=${certificate}" - else - use_ssl_cert=`ovs_vsctl get interface "${netdev}" \ - options:use_ssl_cert 2>/dev/null` - command="${command},peer_cert=${peer_cert},use_ssl_cert=${use_ssl_cert}" - fi - else - psk=`ovs_vsctl get interface "${netdev}" \ - options:psk 2>/dev/null` - command="${command},psk=${psk}" - fi - fi - echo ${command} - done - done -} while [ $# -ne 0 ] do case $1 in - "save-datapaths") - shift - save_datapaths "$@" - exit 0 - ;; "save-flows") shift save_flows "$@" -- 2.30.2