[ovs-dev] [PATCH v2 1/4] ovs-bugtool: Bugfix for bugtool plugin queries.

Dávid Patrik Pintér david.patrik.pinter at ericsson.com
Thu Jan 4 16:01:10 UTC 2018


Introducing 'ovs-bugtool-ovs-ofctl-loop-over-bridges' bash script.
It calls ovs-ofctl commands given as first parameter for each
bridge with the corresponding open flow protocol option.
Usage:
ovs-bugtool-ovs-ofctl-loop-over-bridges "param1" "param2"
 - param1: ovs-ofctl command to call (show, dump-flows, etc...)
 - param2: optional, add further parts for the shell command
   (like "| grep something")

Calling ovs-ofctl commands 'show' and 'dump-flows' with the
'ovs-bugtool-ovs-ofctl-loop-over-bridges' bash script.

Signed-off-by: David Patrik Pinter <david.patrik.pinter at ericsson.com>
---
 utilities/bugtool/automake.mk                      |  3 +-
 utilities/bugtool/ovs-bugtool-ovs-ofctl-dump-flows | 24 ----------------
 .../ovs-bugtool-ovs-ofctl-loop-over-bridges        | 33 ++++++++++++++++++++++
 utilities/bugtool/ovs-bugtool-ovs-ofctl-show       | 24 ----------------
 .../bugtool/plugins/network-status/openvswitch.xml |  4 +--
 5 files changed, 36 insertions(+), 52 deletions(-)
 delete mode 100755 utilities/bugtool/ovs-bugtool-ovs-ofctl-dump-flows
 create mode 100755 utilities/bugtool/ovs-bugtool-ovs-ofctl-loop-over-bridges
 delete mode 100755 utilities/bugtool/ovs-bugtool-ovs-ofctl-show

diff --git a/utilities/bugtool/automake.mk b/utilities/bugtool/automake.mk
index b6d5629..5097f2b 100644
--- a/utilities/bugtool/automake.mk
+++ b/utilities/bugtool/automake.mk
@@ -25,8 +25,7 @@ bugtool_scripts = \
 	utilities/bugtool/ovs-bugtool-vsctl-show \
 	utilities/bugtool/ovs-bugtool-ovsdb-dump \
 	utilities/bugtool/ovs-bugtool-daemons-ver \
-	utilities/bugtool/ovs-bugtool-ovs-ofctl-show \
-	utilities/bugtool/ovs-bugtool-ovs-ofctl-dump-flows \
+	utilities/bugtool/ovs-bugtool-ovs-ofctl-loop-over-bridges \
 	utilities/bugtool/ovs-bugtool-ovs-appctl-dpif \
 	utilities/bugtool/ovs-bugtool-bond-show \
 	utilities/bugtool/ovs-bugtool-conntrack-dump
diff --git a/utilities/bugtool/ovs-bugtool-ovs-ofctl-dump-flows b/utilities/bugtool/ovs-bugtool-ovs-ofctl-dump-flows
deleted file mode 100755
index 61fb841..0000000
--- a/utilities/bugtool/ovs-bugtool-ovs-ofctl-dump-flows
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /bin/sh
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of version 2.1 of the GNU Lesser General
-# Public License as published by the Free Software Foundation.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
-#
-# Copyright (C) 2013 Nicira, Inc.
-
-for bridge in `ovs-vsctl list-br`
-do
-    echo "ovs-ofctl dump-flows ${bridge}"
-    ovs-ofctl dump-flows "$bridge"
-    echo ""
-done
diff --git a/utilities/bugtool/ovs-bugtool-ovs-ofctl-loop-over-bridges b/utilities/bugtool/ovs-bugtool-ovs-ofctl-loop-over-bridges
new file mode 100755
index 0000000..e74f474
--- /dev/null
+++ b/utilities/bugtool/ovs-bugtool-ovs-ofctl-loop-over-bridges
@@ -0,0 +1,33 @@
+#! /bin/bash
+
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General
+# Public License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+# USA
+#
+# Copyright (C) 2017 Ericsson AB
+
+for bridge in `ovs-vsctl -- --real list-br`
+do
+    PROTOCOLS="$(ovs-vsctl get Bridge "$bridge" protocols)"
+    if [ "$PROTOCOLS" = "[]" ]
+    then
+        echo "ovs-ofctl $1 ${bridge} $2"
+        eval ovs-ofctl $1 "${bridge}" $2
+    else
+        LENGTHPRO="$(expr length "$PROTOCOLS")"
+        COMMAIND="$(expr index "$PROTOCOLS" ,)"
+        echo "ovs-ofctl $1 -O${PROTOCOLS:${COMMAIND}+2:${LENGTHPRO}-${COMMAIND}-4} ${bridge} $2"
+        eval ovs-ofctl $1 -O"${PROTOCOLS:${COMMAIND}+2:${LENGTHPRO}-${COMMAIND}-4}" "${bridge}" $2
+    fi
+    echo ""
+done
diff --git a/utilities/bugtool/ovs-bugtool-ovs-ofctl-show b/utilities/bugtool/ovs-bugtool-ovs-ofctl-show
deleted file mode 100755
index 2843395..0000000
--- a/utilities/bugtool/ovs-bugtool-ovs-ofctl-show
+++ /dev/null
@@ -1,24 +0,0 @@
-#! /bin/sh
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of version 2.1 of the GNU Lesser General
-# Public License as published by the Free Software Foundation.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
-# USA
-#
-# Copyright (C) 2013 Nicira, Inc.
-
-for bridge in `ovs-vsctl list-br`
-do
-    echo "ovs-ofctl show ${bridge}"
-    ovs-ofctl show "$bridge"
-    echo ""
-done
diff --git a/utilities/bugtool/plugins/network-status/openvswitch.xml b/utilities/bugtool/plugins/network-status/openvswitch.xml
index bb6792a..e3143c6 100644
--- a/utilities/bugtool/plugins/network-status/openvswitch.xml
+++ b/utilities/bugtool/plugins/network-status/openvswitch.xml
@@ -28,8 +28,8 @@
   <command label="ovs-appctl-coverage-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-coverage-show</command>
   <command label="ovs-appctl-bond-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-bond-show</command>
   <command label="ovs-appctl-memory-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-memory-show</command>
-  <command label="ovs-ofctl-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-ovs-ofctl-show</command>
-  <command label="ovs-ofctl-dump-flows" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-ovs-ofctl-dump-flows</command>
+  <command label="ovs-ofctl-show" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-ovs-ofctl-loop-over-bridges "show"</command>
+  <command label="ovs-ofctl-dump-flows" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-ovs-ofctl-loop-over-bridges "dump-flows"</command>
   <command label="ovs-appctl-dpif" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-ovs-appctl-dpif</command>
   <command label="ovs-appctl-list-dbs" filters="ovs">/usr/share/openvswitch/scripts/ovs-bugtool-list-dbs</command>
 </collect>
--
2.7.4


More information about the dev mailing list