[ovs-dev] [PATCH v2] ovn: OVN changes for QOS settings

Babu Shanmugam bschanmu at redhat.com
Wed Feb 10 05:27:39 UTC 2016


From: Ben Pfaff <blp at ovn.org>

Signed-off-by: Ben Pfaff <blp at ovn.org>
Signed-off-by: Babu Shanmugam <bschanmu at redhat.com>
---
 ovn/controller/binding.c        | 46 ++++++++++++++++++++++++++++-------------
 ovn/controller/ovn-controller.c |  4 ++++
 ovn/ovn-nb.xml                  | 17 +++++++++++++++
 ovn/ovn-sb.xml                  | 17 +++++++++++++++
 4 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/ovn/controller/binding.c b/ovn/controller/binding.c
index ce9cccf..f295473 100644
--- a/ovn/controller/binding.c
+++ b/ovn/controller/binding.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2015 Nicira, Inc.
+/* Copyright (c) 2015, 2016 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -47,7 +47,7 @@ binding_register_ovs_idl(struct ovsdb_idl *ovs_idl)
 }
 
 static void
-get_local_iface_ids(const struct ovsrec_bridge *br_int, struct sset *lports)
+get_local_iface_ids(const struct ovsrec_bridge *br_int, struct shash *lports)
 {
     int i;
 
@@ -68,7 +68,7 @@ get_local_iface_ids(const struct ovsrec_bridge *br_int, struct sset *lports)
             if (!iface_id) {
                 continue;
             }
-            sset_add(lports, iface_id);
+            shash_add(lports, iface_id, iface_rec);
         }
     }
 }
@@ -132,6 +132,17 @@ add_local_datapath(struct hmap *local_datapaths,
     }
 }
 
+static void
+update_qos(const struct ovsrec_interface *iface_rec,
+           const struct sbrec_port_binding *pb)
+{
+    int rate = smap_get_int(&pb->options, "policing_rate", 0);
+    int burst = smap_get_int(&pb->options, "policing_burst", 0);
+
+    ovsrec_interface_set_ingress_policing_rate(iface_rec, MAX(0, rate));
+    ovsrec_interface_set_ingress_policing_burst(iface_rec, MAX(0, burst));
+}
+
 void
 binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
             const char *chassis_id, struct simap *ct_zones,
@@ -139,8 +150,6 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
 {
     const struct sbrec_chassis *chassis_rec;
     const struct sbrec_port_binding *binding_rec;
-    struct sset lports, all_lports;
-    const char *name;
 
     if (!ctx->ovnsb_idl_txn) {
         return;
@@ -151,15 +160,19 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
         return;
     }
 
-    sset_init(&lports);
-    sset_init(&all_lports);
+    struct shash lports = SHASH_INITIALIZER(&lports);
     if (br_int) {
         get_local_iface_ids(br_int, &lports);
     } else {
         /* We have no integration bridge, therefore no local logical ports.
          * We'll remove our chassis from all port binding records below. */
     }
-    sset_clone(&all_lports, &lports);
+
+    struct sset all_lports = SSET_INITIALIZER(&all_lports);
+    struct shash_node *node;
+    SHASH_FOR_EACH (node, &lports) {
+        sset_add(&all_lports, node->name);
+    }
 
     ovsdb_idl_txn_add_comment(
         ctx->ovnsb_idl_txn,"ovn-controller: updating port bindings for '%s'",
@@ -169,14 +182,19 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
      * chassis and update the binding accordingly.  This includes both
      * directly connected logical ports and children of those ports. */
     SBREC_PORT_BINDING_FOR_EACH(binding_rec, ctx->ovnsb_idl) {
-        if (sset_find_and_delete(&lports, binding_rec->logical_port) ||
-                (binding_rec->parent_port && binding_rec->parent_port[0] &&
-                 sset_contains(&all_lports, binding_rec->parent_port))) {
+        const struct ovsrec_interface *iface_rec
+            = shash_find_and_delete(&lports, binding_rec->logical_port);
+        if (iface_rec
+            || (binding_rec->parent_port && binding_rec->parent_port[0] &&
+                sset_contains(&all_lports, binding_rec->parent_port))) {
             if (binding_rec->parent_port && binding_rec->parent_port[0]) {
                 /* Add child logical port to the set of all local ports. */
                 sset_add(&all_lports, binding_rec->logical_port);
             }
             add_local_datapath(local_datapaths, binding_rec);
+            if (iface_rec) {
+                update_qos(iface_rec, binding_rec);
+            }
             if (binding_rec->chassis == chassis_rec) {
                 continue;
             }
@@ -199,13 +217,13 @@ binding_run(struct controller_ctx *ctx, const struct ovsrec_bridge *br_int,
         }
     }
 
-    SSET_FOR_EACH (name, &lports) {
-        VLOG_DBG("No port binding record for lport %s", name);
+    SHASH_FOR_EACH (node, &lports) {
+        VLOG_DBG("No port binding record for lport %s", node->name);
     }
 
     update_ct_zones(&all_lports, ct_zones, ct_zone_bitmap);
 
-    sset_destroy(&lports);
+    shash_destroy(&lports);
     sset_destroy(&all_lports);
 }
 
diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index 3638342..ac824ad 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -240,6 +240,10 @@ main(int argc, char *argv[])
     ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_name);
     ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_type);
     ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_interface_col_options);
+    ovsdb_idl_add_column(ovs_idl_loop.idl,
+                         &ovsrec_interface_col_ingress_policing_rate);
+    ovsdb_idl_add_column(ovs_idl_loop.idl,
+                         &ovsrec_interface_col_ingress_policing_burst);
     ovsdb_idl_add_table(ovs_idl_loop.idl, &ovsrec_table_port);
     ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_port_col_name);
     ovsdb_idl_add_column(ovs_idl_loop.idl, &ovsrec_port_col_interfaces);
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index 4e414ce..c3b4934 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -182,6 +182,23 @@
           Required.  A logical switch name connected by the VTEP gateway.
         </column>
       </group>
+
+      <group title="VMI (or VIF) Options">
+        <p>
+          These options apply to logical ports with <ref column="type"/> having
+          (empty string)
+        </p>
+
+        <column name="options" key="policing_rate">
+          If set, indicates the maximum rate for data sent from this interface,
+          in kbps. Data exceeding this rate is dropped.
+        </column>
+
+        <column name="options" key="policing_burst">
+          If set, indicates the maximum burst size for data sent from this
+          interface, in kb.
+        </column>
+      </group>
     </group>
 
     <group title="Containers">
diff --git a/ovn/ovn-sb.xml b/ovn/ovn-sb.xml
index e674f3a..1ea35d5 100644
--- a/ovn/ovn-sb.xml
+++ b/ovn/ovn-sb.xml
@@ -1300,6 +1300,23 @@ tcp.flags = RST;
       </column>
     </group>
 
+    <group title="VMI (or VIF) Options">
+      <p>
+        These options apply to logical ports with <ref column="type"/> having
+        (empty string)
+      </p>
+
+      <column name="options" key="policing_rate">
+        If set, indicates the maximum rate for data sent from this interface,
+        in kbps. Data exceeding this rate is dropped.
+      </column>
+
+      <column name="options" key="policing_burst">
+        If set, indicates the maximum burst size for data sent from this
+        interface, in kb.
+      </column>
+    </group>
+
     <group title="Nested Containers">
       <p>
         These columns support containers nested within a VM.  Specifically,
-- 
1.9.1




More information about the dev mailing list