[ovs-dev] [ovs-dev v2] dpif-netdev: Allow to set max capacity of flow on netdev

Ben Pfaff blp at ovn.org
Wed Jan 8 18:47:14 UTC 2020


On Wed, Jan 08, 2020 at 05:32:48PM +0800, xiangxia.m.yue at gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue at gmail.com>
> 
> For installing more than MAX_FLOWS (65536) flows to netdev datapath.
> Add the ovs-appctl subcommand "dpif-netdev/pmd-set-max-flow" which
> can change the flow number which netdev datapath support.
> 
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com>
> ---
> v2:
> * change int type to atomic_uint32_t
> * check max flow number is whether valid (0 < max-flow < UINT_MAX).

Thanks.  I suggest folding in the following mainly stylistic changes.

Also, please document the new commands in lib/dpif-netdev-unixctl.man
and mention them in NEWS.

Thanks,

Ben.

-8<--------------------------cut here-------------------------->8--

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 38f0c65ab2e4..71aee1f7203f 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1133,9 +1133,9 @@ dpif_netdev_set_max_flow(struct unixctl_conn *conn,
 {
     long long max_flow = atoll(argv[1]);
 
-    if (max_flow <= 0 || max_flow >= UINT_MAX) {
+    if (max_flow <= 0 || max_flow >= UINT32_MAX) {
         unixctl_command_reply_error(conn,
-                                    "max-flow should: > 0 and < UINT_MAX\n");
+                                    "max-flow should: > 0 and < UINT_MAX");
         return;
     }
 
@@ -1149,14 +1149,12 @@ dpif_netdev_show_max_flow(struct unixctl_conn *conn,
                           const char *argv[] OVS_UNUSED,
                           void *aux OVS_UNUSED)
 {
-    struct ds reply = DS_EMPTY_INITIALIZER;
     uint32_t max_flow;
-
     atomic_read_relaxed(&netdev_max_flow, &max_flow);
 
-    ds_put_format(&reply,"%u\n", max_flow);
-    unixctl_command_reply(conn, ds_cstr(&reply));
-    ds_destroy(&reply);
+    char *reply = xasprintf("%u", max_flow);
+    unixctl_command_reply(conn, reply);
+    free(reply);
 }
 
 static int
@@ -3390,7 +3388,6 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd,
                 struct dpif_flow_stats *stats)
 {
     struct dp_netdev_flow *netdev_flow;
-    uint32_t max_flow;
     int error = 0;
 
     if (stats) {
@@ -3401,6 +3398,7 @@ flow_put_on_pmd(struct dp_netdev_pmd_thread *pmd,
     netdev_flow = dp_netdev_pmd_lookup_flow(pmd, key, NULL);
     if (!netdev_flow) {
         if (put->flags & DPIF_FP_CREATE) {
+            uint32_t max_flow;
             atomic_read_relaxed(&netdev_max_flow, &max_flow);
             if (cmap_count(&pmd->flow_table) < max_flow) {
                 dp_netdev_flow_add(pmd, match, ufid, put->actions,


More information about the dev mailing list