ofctl_rest is now enabled to parse flags multiply as follows:

  curl -X POST -d '{"dpid": 1,
                    "meter_id": 1,
                    "flags": ["KBPS", "BURST"],
                    "bands": [{"type": "DROP", "rate": 1000}]}' 
http://localhost:8080/stats/meterentry/add

And now enabled to show flags as follows:

  curl http://localhost:8080/stats/meterconfig/1

  {
    "1": [
      {"bands": [{"burst_size": 0, "rate": 1000, "type": "DROP"}],
       "flags": ["KBPS", "BURST"], "meter_id": 1}
    ]
  }

Reported-by: cheers <[email protected]>
Signed-off-by: Yuichi Ito <[email protected]>
---
 ryu/lib/ofctl_v1_3.py |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index af6ac81..63356cd 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -699,7 +699,11 @@ def get_meter_config(dp, waiters):
                 elif band.type == dp.ofproto.OFPMBT_EXPERIMENTER:
                     b['experimenter'] = band.experimenter
                 bands.append(b)
-            c = {'flags': flags.get(config.flags, 0),
+            c_flags = []
+            for k, v in flags.items():
+                if k & config.flags:
+                    c_flags.append(v)
+            c = {'flags': c_flags,
                  'meter_id': config.meter_id,
                  'bands': bands}
             configs.append(c)
@@ -856,7 +860,12 @@ def mod_meter_entry(dp, flow, cmd):
                      'BURST': dp.ofproto.OFPMF_BURST,
                      'STATS': dp.ofproto.OFPMF_STATS}

-    flags = flags_convert.get(flow.get('flags'))
+    flow_flags = flow.get('flags')
+    if not isinstance(flow_flags, list):
+        flow_flags = [flow_flags]
+    flags = 0
+    for flag in flow_flags:
+        flags |= flags_convert.get(flag, 0)
     if not flags:
         LOG.debug('Unknown flags: %s', flow.get('flags'))

--
1.7.10.4


------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to