]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovs-save: Use a file to restore flows instead of heredoc
authorTimothy Redaelli <tredaelli@redhat.com>
Mon, 25 Sep 2017 14:44:05 +0000 (16:44 +0200)
committerBen Pfaff <blp@ovn.org>
Fri, 27 Oct 2017 16:55:00 +0000 (09:55 -0700)
This patch makes ovs-save to use a file to restore flows instead of using
shell script here-document.
This is needed since eval + here-documents are much slower than reading a file
with the rules directly.

Signed-off-by: Timothy Redaelli <tredaelli@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Flavio Leitner <fbl@sysclose.org>
utilities/ovs-save

index fc9418c3dd768f63e0f05d0f18b6a5abc2a43072..da65c41ec19949cd2899898d05d5b00ad34062de 100755 (executable)
@@ -110,6 +110,7 @@ save_flows () {
         exit 1
     fi
 
+    workdir=$(mktemp -d "${TMPDIR:-/tmp}/ovs-save.XXXXXXXXXX")
     for bridge in "$@"; do
         # Get the highest enabled OpenFlow version
         ofp_version=$(get_highest_ofp_version "$bridge")
@@ -120,19 +121,19 @@ save_flows () {
              cnt++;printf "{class="$1",type="$2",len="$3"}->"$4}'
         echo "'"
 
-        echo -n "ovs-ofctl -O $ofp_version add-flows ${bridge} "
+        echo -n "ovs-ofctl -O $ofp_version add-flows ${bridge} " \
+            "\"$workdir/$bridge.flows.dump\""
 
         # If possible, use OpenFlow 1.4 atomic bundle transaction to add flows
-        [ ${ofp_version#OpenFlow} -ge 14 ] && echo -n "--bundle "
-
-        echo  "- << EOF"
+        [ ${ofp_version#OpenFlow} -ge 14 ] && echo " --bundle" || echo
 
         ovs-ofctl -O $ofp_version dump-flows --no-names --no-stats "$bridge" | \
             sed -e '/NXST_FLOW/d' \
                 -e '/OFPST_FLOW/d' \
-                -e 's/\(idle\|hard\)_age=[^,]*,//g'
-        echo "EOF"
+                -e 's/\(idle\|hard\)_age=[^,]*,//g' > \
+                "$workdir/$bridge.flows.dump"
     done
+    echo "rm -rf \"$workdir\""
 }
 
 while [ $# -ne 0 ]