This commit adds a new command 'qos/show-types' for use with appctl.
This allows a user to query the types of QoS which are configurable via
Open vSwitch on a given interface.

Signed-off-by: Ian Stokes <ian.sto...@intel.com>
---
 vswitchd/bridge.c          |   46 ++++++++++++++++++++++++++++++++++++++++++++
 vswitchd/ovs-vswitchd.8.in |    3 ++
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 25a0663..2f603ff 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -269,6 +269,7 @@ static bool bridge_has_bond_fake_iface(const struct bridge 
*,
                                        const char *name);
 static bool port_is_bond_fake_iface(const struct port *);
 
+static unixctl_cb_func qos_unixctl_show_types;
 static unixctl_cb_func qos_unixctl_show;
 
 static struct port *port_create(struct bridge *, const struct ovsrec_port *);
@@ -476,6 +477,8 @@ bridge_init(const char *remote)
     ovsdb_idl_omit(idl, &ovsrec_ssl_col_external_ids);
 
     /* Register unixctl commands. */
+    unixctl_command_register("qos/show-types", "interface", 1, 1,
+                             qos_unixctl_show_types, NULL);
     unixctl_command_register("qos/show", "interface", 1, 1,
                              qos_unixctl_show, NULL);
     unixctl_command_register("bridge/dump-flows", "bridge", 1, 1,
@@ -3122,6 +3125,49 @@ qos_unixctl_show_queue(unsigned int queue_id,
 }
 
 static void
+qos_unixctl_show_types(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                 const char *argv[], void *aux OVS_UNUSED)
+{
+    struct ds ds = DS_EMPTY_INITIALIZER;
+    struct sset types = SSET_INITIALIZER(&types);
+    struct iface *iface;
+    const char * types_name;
+    int error;
+
+    iface = iface_find(argv[1]);
+    if (!iface) {
+        unixctl_command_reply_error(conn, "no such interface");
+        return;
+    }
+
+    error = netdev_get_qos_types(iface->netdev, &types);
+
+    if(!error) {
+        if(!sset_is_empty(&types)) {
+            SSET_FOR_EACH(types_name, &types) {
+            ds_put_format(&ds, "QoS type: %s\n", types_name);
+            }
+            unixctl_command_reply(conn, ds_cstr(&ds));
+        }
+        else {
+            ds_put_format(&ds, "No QoS types supported for interface: %s\n",
+                            iface->name);
+            unixctl_command_reply(conn, ds_cstr(&ds));
+        }
+    }
+    else {
+        ds_put_format(&ds, "Could not retrieve supported QoS types on %s due"
+                            " to error\n", iface->name);
+        unixctl_command_reply_error(conn, ds_cstr(&ds));
+        VLOG_ERR("interface %s could not get supported QoS types, failed with"
+                    " errno %d", iface->name, error);
+    }
+
+    sset_destroy(&types);
+    ds_destroy(&ds);
+}
+
+static void
 qos_unixctl_show(struct unixctl_conn *conn, int argc OVS_UNUSED,
                  const char *argv[], void *aux OVS_UNUSED)
 {
diff --git a/vswitchd/ovs-vswitchd.8.in b/vswitchd/ovs-vswitchd.8.in
index b628f2f..601b7a1 100644
--- a/vswitchd/ovs-vswitchd.8.in
+++ b/vswitchd/ovs-vswitchd.8.in
@@ -112,6 +112,9 @@ how to configure Open vSwitch.
 .SS "GENERAL COMMANDS"
 .IP "\fBexit\fR"
 Causes \fBovs\-vswitchd\fR to gracefully terminate.
+.IP "\fBqos/show-types\fR \fIinterface\fR"
+Queries the interface for a list of Quality of Service types that are
+configurable via Open vSwitch for the given \fIinterface\fR.
 .IP "\fBqos/show\fR \fIinterface\fR"
 Queries the kernel for Quality of Service configuration and statistics
 associated with the given \fIinterface\fR.
-- 
1.7.4.1

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to