summaryrefslogtreecommitdiff
path: root/utilities
diff options
context:
space:
mode:
authorTimothy Redaelli <tredaelli@redhat.com>2017-09-25 16:44:04 +0200
committerBen Pfaff <blp@ovn.org>2017-10-27 09:51:46 -0700
commitd3b41dd957fc74001e43e59367890461c6f4f159 (patch)
treea0015c3b84afcac41173aeb1e9b18b9d2bc95f6c /utilities
parenta694ead1e2781891f5da8999f06c27367e0adec2 (diff)
downloadopenvswitch-d3b41dd957fc74001e43e59367890461c6f4f159.tar.gz
ovs-save: Use --bundle to restore flows (on OpenFlow 1.4+)
If possible, use OpenFlow 1.4 atomic bundle transaction to restore flows. The patch uses also the highest enabled OpenFlow version to do the queries. With the actual implementation, if you have the default OpenFlow version disabled then ovs-save fails. This patch also fixes that problem. Signed-off-by: Timothy Redaelli <tredaelli@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Flavio Leitner <fbl@sysclose.org>
Diffstat (limited to 'utilities')
-rwxr-xr-xutilities/ovs-save22
1 files changed, 19 insertions, 3 deletions
diff --git a/utilities/ovs-save b/utilities/ovs-save
index 8b8dbf421..fc9418c3d 100755
--- a/utilities/ovs-save
+++ b/utilities/ovs-save
@@ -99,6 +99,11 @@ save_interfaces () {
fi
}
+get_highest_ofp_version() {
+ ovs-vsctl get bridge "$1" protocols | \
+ awk -F '"' '{ print (NF>1)? $(NF-1) : "OpenFlow14" }'
+}
+
save_flows () {
if (ovs-ofctl --version) > /dev/null 2>&1; then :; else
echo "$0: ovs-ofctl not found in $PATH" >&2
@@ -106,15 +111,26 @@ save_flows () {
fi
for bridge in "$@"; do
+ # Get the highest enabled OpenFlow version
+ ofp_version=$(get_highest_ofp_version "$bridge")
+
echo -n "ovs-ofctl add-tlv-map ${bridge} '"
ovs-ofctl dump-tlv-map ${bridge} | \
awk '/^ 0x/ {if (cnt != 0) printf ","; \
cnt++;printf "{class="$1",type="$2",len="$3"}->"$4}'
echo "'"
- echo "ovs-ofctl add-flows ${bridge} - << EOF"
- ovs-ofctl dump-flows "${bridge}" | sed -e '/NXST_FLOW/d' \
- -e 's/\(idle\|hard\)_age=[^,]*,//g'
+ echo -n "ovs-ofctl -O $ofp_version add-flows ${bridge} "
+
+ # If possible, use OpenFlow 1.4 atomic bundle transaction to add flows
+ [ ${ofp_version#OpenFlow} -ge 14 ] && echo -n "--bundle "
+
+ echo "- << EOF"
+
+ 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"
done
}