]> git.proxmox.com Git - ovs.git/commitdiff
ovn-controller: Add "meter-table-list" ovs-appctl command.
authorJustin Pettit <jpettit@ovn.org>
Mon, 2 Jul 2018 06:27:38 +0000 (23:27 -0700)
committerJustin Pettit <jpettit@ovn.org>
Tue, 31 Jul 2018 06:09:47 +0000 (23:09 -0700)
Signed-off-by: Justin Pettit <jpettit@ovn.org>
Acked-by: Ben Pfaff <blp@ovn.org>
ovn/controller/ovn-controller.8.xml
ovn/controller/ovn-controller.c

index 0eff2113f52ee33825f2dfaa0a5b43819d57c685..7d8fa66d7313566f77115ca8e312bc184891efe7 100644 (file)
         Lists each local logical port and its connection tracking zone.
       </dd>
 
+      <dt><code>meter-table-list</code></dt>
+      <dd>
+        Lists each meter table entry and its local meter id.
+      </dd>
+
       <dt><code>inject-pkt</code> <var>microflow</var></dt>
       <dd>
       <p>
index 6ee72a9fafb41e76dc54f525b4c3f6e28cb37ed7..62caace247a8c7960a9fc86ab77ce8fb35b8d411 100644 (file)
@@ -65,6 +65,7 @@ VLOG_DEFINE_THIS_MODULE(main);
 
 static unixctl_cb_func ovn_controller_exit;
 static unixctl_cb_func ct_zone_list;
+static unixctl_cb_func meter_table_list;
 static unixctl_cb_func inject_pkt;
 
 #define DEFAULT_BRIDGE_NAME "br-int"
@@ -569,6 +570,8 @@ main(int argc, char *argv[])
     /* Initialize meter ids for QoS. */
     struct ovn_extend_table meter_table;
     ovn_extend_table_init(&meter_table);
+    unixctl_command_register("meter-table-list", "", 0, 0,
+                             meter_table_list, &meter_table);
 
     daemonize_complete();
 
@@ -1024,6 +1027,33 @@ ct_zone_list(struct unixctl_conn *conn, int argc OVS_UNUSED,
     ds_destroy(&ds);
 }
 
+static void
+meter_table_list(struct unixctl_conn *conn, int argc OVS_UNUSED,
+                 const char *argv[] OVS_UNUSED, void *meter_table_)
+{
+    struct ovn_extend_table *meter_table = meter_table_;
+    struct ds ds = DS_EMPTY_INITIALIZER;
+    struct simap meters = SIMAP_INITIALIZER(&meters);
+
+    struct ovn_extend_table_info *m_installed, *next_meter;
+    EXTEND_TABLE_FOR_EACH_INSTALLED (m_installed, next_meter, meter_table) {
+        simap_put(&meters, m_installed->name, m_installed->table_id);
+    }
+
+    const struct simap_node **nodes = simap_sort(&meters);
+    size_t n_nodes = simap_count(&meters);
+    for (size_t i = 0; i < n_nodes; i++) {
+        const struct simap_node *node = nodes[i];
+        ds_put_format(&ds, "%s: %d\n", node->name, node->data);
+    }
+
+    free(nodes);
+    simap_destroy(&meters);
+
+    unixctl_command_reply(conn, ds_cstr(&ds));
+    ds_destroy(&ds);
+}
+
 static void
 inject_pkt(struct unixctl_conn *conn, int argc OVS_UNUSED,
            const char *argv[], void *pending_pkt_)