{"id":818266,"url":"http://patchwork.ozlabs.org/api/patches/818266/?format=json","web_url":"http://patchwork.ozlabs.org/project/openvswitch/patch/b29194c2dff42280b9a36e3cece7ab5f545d54ba.1506350315.git.tredaelli@redhat.com/","project":{"id":47,"url":"http://patchwork.ozlabs.org/api/projects/47/?format=json","name":"Open vSwitch","link_name":"openvswitch","list_id":"ovs-dev.openvswitch.org","list_email":"ovs-dev@openvswitch.org","web_url":"http://openvswitch.org/","scm_url":"git@github.com:openvswitch/ovs.git","webscm_url":"https://github.com/openvswitch/ovs","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<b29194c2dff42280b9a36e3cece7ab5f545d54ba.1506350315.git.tredaelli@redhat.com>","list_archive_url":null,"date":"2017-09-25T14:44:05","name":"[ovs-dev,v2,2/3] ovs-save: Use a file to restore flows instead of heredoc","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"19cb943b580b3a97575f56f45ac3a935198ca837","submitter":{"id":70949,"url":"http://patchwork.ozlabs.org/api/people/70949/?format=json","name":"Timothy Redaelli","email":"tredaelli@redhat.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/openvswitch/patch/b29194c2dff42280b9a36e3cece7ab5f545d54ba.1506350315.git.tredaelli@redhat.com/mbox/","series":[{"id":4973,"url":"http://patchwork.ozlabs.org/api/series/4973/?format=json","web_url":"http://patchwork.ozlabs.org/project/openvswitch/list/?series=4973","date":"2017-09-25T14:44:03","name":"ovs-save: Some refactors to speed-up save-flows","version":2,"mbox":"http://patchwork.ozlabs.org/series/4973/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/818266/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/818266/checks/","tags":{},"related":[],"headers":{"Return-Path":"<ovs-dev-bounces@openvswitch.org>","X-Original-To":["incoming@patchwork.ozlabs.org","dev@openvswitch.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","ovs-dev@mail.linuxfoundation.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=tredaelli@redhat.com"],"Received":["from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3y16MS6MvJz9t4Z\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 26 Sep 2017 00:45:40 +1000 (AEST)","from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id A0E3AB5D;\n\tMon, 25 Sep 2017 14:44:26 +0000 (UTC)","from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id 1BD87B43\n\tfor <dev@openvswitch.org>; Mon, 25 Sep 2017 14:44:24 +0000 (UTC)","from mx1.redhat.com (mx1.redhat.com [209.132.183.28])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTPS id E02E44BD\n\tfor <dev@openvswitch.org>; Mon, 25 Sep 2017 14:44:23 +0000 (UTC)","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby mx1.redhat.com (Postfix) with ESMTPS id 6D3644E4C3\n\tfor <dev@openvswitch.org>; Mon, 25 Sep 2017 14:44:23 +0000 (UTC)","from graphite.mxp.redhat.com (unknown [10.32.181.225])\n\tby smtp.corp.redhat.com (Postfix) with ESMTP id E44CF77C0E\n\tfor <dev@openvswitch.org>; Mon, 25 Sep 2017 14:44:22 +0000 (UTC)"],"X-Greylist":["domain auto-whitelisted by SQLgrey-1.7.6","Sender IP whitelisted, not delayed by milter-greylist-4.5.16\n\t(mx1.redhat.com [10.5.110.38]);\n\tMon, 25 Sep 2017 14:44:23 +0000 (UTC)"],"DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 6D3644E4C3","From":"Timothy Redaelli <tredaelli@redhat.com>","To":"dev@openvswitch.org","Date":"Mon, 25 Sep 2017 16:44:05 +0200","Message-Id":"<b29194c2dff42280b9a36e3cece7ab5f545d54ba.1506350315.git.tredaelli@redhat.com>","In-Reply-To":"<cover.1506350315.git.tredaelli@redhat.com>","References":"<cover.1506350315.git.tredaelli@redhat.com>","X-Scanned-By":"MIMEDefang 2.79 on 10.5.11.13","X-Spam-Status":"No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,\n\tRP_MATCHES_RCVD autolearn=disabled version=3.3.1","X-Spam-Checker-Version":"SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp1.linux-foundation.org","Subject":"[ovs-dev] [PATCH v2 2/3] ovs-save: Use a file to restore flows\n\tinstead of heredoc","X-BeenThere":"ovs-dev@openvswitch.org","X-Mailman-Version":"2.1.12","Precedence":"list","List-Id":"<ovs-dev.openvswitch.org>","List-Unsubscribe":"<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>","List-Archive":"<http://mail.openvswitch.org/pipermail/ovs-dev/>","List-Post":"<mailto:ovs-dev@openvswitch.org>","List-Help":"<mailto:ovs-dev-request@openvswitch.org?subject=help>","List-Subscribe":"<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Sender":"ovs-dev-bounces@openvswitch.org","Errors-To":"ovs-dev-bounces@openvswitch.org"},"content":"This patch makes ovs-save to use a file to restore flows instead of using\nshell script here-document.\nThis is needed since eval + here-documents are much slower than reading a file\nwith the rules directly.\n\nSigned-off-by: Timothy Redaelli <tredaelli@redhat.com>\n---\n utilities/ovs-save | 13 +++++++------\n 1 file changed, 7 insertions(+), 6 deletions(-)","diff":"diff --git a/utilities/ovs-save b/utilities/ovs-save\nindex fc9418c3d..da65c41ec 100755\n--- a/utilities/ovs-save\n+++ b/utilities/ovs-save\n@@ -110,6 +110,7 @@ save_flows () {\n         exit 1\n     fi\n \n+    workdir=$(mktemp -d \"${TMPDIR:-/tmp}/ovs-save.XXXXXXXXXX\")\n     for bridge in \"$@\"; do\n         # Get the highest enabled OpenFlow version\n         ofp_version=$(get_highest_ofp_version \"$bridge\")\n@@ -120,19 +121,19 @@ save_flows () {\n              cnt++;printf \"{class=\"$1\",type=\"$2\",len=\"$3\"}->\"$4}'\n         echo \"'\"\n \n-        echo -n \"ovs-ofctl -O $ofp_version add-flows ${bridge} \"\n+        echo -n \"ovs-ofctl -O $ofp_version add-flows ${bridge} \" \\\n+            \"\\\"$workdir/$bridge.flows.dump\\\"\"\n \n         # If possible, use OpenFlow 1.4 atomic bundle transaction to add flows\n-        [ ${ofp_version#OpenFlow} -ge 14 ] && echo -n \"--bundle \"\n-\n-        echo  \"- << EOF\"\n+        [ ${ofp_version#OpenFlow} -ge 14 ] && echo \" --bundle\" || echo\n \n         ovs-ofctl -O $ofp_version dump-flows --no-names --no-stats \"$bridge\" | \\\n             sed -e '/NXST_FLOW/d' \\\n                 -e '/OFPST_FLOW/d' \\\n-                -e 's/\\(idle\\|hard\\)_age=[^,]*,//g'\n-        echo \"EOF\"\n+                -e 's/\\(idle\\|hard\\)_age=[^,]*,//g' > \\\n+                \"$workdir/$bridge.flows.dump\"\n     done\n+    echo \"rm -rf \\\"$workdir\\\"\"\n }\n \n while [ $# -ne 0 ]\n","prefixes":["ovs-dev","v2","2/3"]}