Hi,

On 2016年04月07日 00:06, Rimac, Ivica (Nokia - DE) wrote:
> Hi,
>
> I have implemented and configured a load balancer on an OVS levering the 
> nicira multipath extension and using the ovs-ofctl tool. Moving from local 
> ovs controls to a RYU app leaves me wondering about some details. Following 
> are my ofctl instructions with related questions:
>
> 1. Multipath action
>
> $> ovs-ofctl add-flow ovsbr 
> ip,nw_dst=${VIP},actions=multipath(symmetric_l4,1024,hrw,${NUM_LINKS},0,NXM_NX_REG0[0..3]),resubmit(,1)
>
> Q1) The multipath extension is only supported in ofproto_v1_0_parser, correct?

Currently, yes.
the Nicira extensions are not fully ported into ofproto_v1_[2345]_parser...

>
> I am trying to use the classes in my ryu-app to create the corresponding 
> actions
>
>     -> ofproto_v1_0_parser.NXActionMultipath(…)
>
>      -> ofproto_v1_0_parser.NXResubmitTable(…)
>
> I found  ofproto.NX_HASH_FIELDS_SYMMETRIC_L4 and ofproto.NX_MP_ALG_HRW for 
> the fields and algorithm but wonder
>
> Q2) how to set/address the register NXM_NX_REG0 (and the corresponding bits)  
> in NXActionMultipath?
>
> Q3) what is the ofs_nbits param used for in ryu MP Action? (There is no such 
> argument in the ofctl multipath action.)
>
> 2. Register match
>
> $> ovs-ofctl add-flow ovsbr 
> table=1,reg0=0/15,actions=mod_dl_dst=${MAC},output:${OFPORT}
>
> Q4) How do I read the value (hash) previously written into reg0 by the 
> multipath action? (related to Q1)

For Q2,3,4, please refer to the following snippet.

$ git diff
diff --git a/ryu/app/simple_switch.py b/ryu/app/simple_switch.py
index 862b830..0666deb 100644
--- a/ryu/app/simple_switch.py
+++ b/ryu/app/simple_switch.py
@@ -20,7 +20,7 @@ An OpenFlow 1.0 L2 learning switch implementation.
  
  from ryu.base import app_manager
  from ryu.controller import ofp_event
-from ryu.controller.handler import MAIN_DISPATCHER
+from ryu.controller.handler import MAIN_DISPATCHER, CONFIG_DISPATCHER
  from ryu.controller.handler import set_ev_cls
  from ryu.ofproto import ofproto_v1_0
  from ryu.lib.mac import haddr_to_bin
@@ -28,6 +28,9 @@ from ryu.lib.packet import packet
  from ryu.lib.packet import ethernet
  from ryu.lib.packet import ether_types
  
+from ryu.ofproto import nx_match
+from ryu.ofproto import nicira_ext
+
  
  class SimpleSwitch(app_manager.RyuApp):
      OFP_VERSIONS = [ofproto_v1_0.OFP_VERSION]
@@ -36,6 +39,44 @@ class SimpleSwitch(app_manager.RyuApp):
          super(SimpleSwitch, self).__init__(*args, **kwargs)
          self.mac_to_port = {}
  
+    @set_ev_cls(ofp_event.EventOFPSwitchFeatures, CONFIG_DISPATCHER)
+    def switch_features_handler(self, ev):
+        datapath = ev.msg.datapath
+        ofproto = datapath.ofproto
+        parser = datapath.ofproto_parser
+
+        # Register match in ovs-ofctl command is corresponding as follows:
+        #  format)
+        #    reg<reg_index>=value/mask
+        #    nx_match.ClsRule.set_reg_masked(self, reg_idx, value, mask)
+        #  e.g.)
+        #    reg0=0/15
+        rule = nx_match.ClsRule()
+        rule.set_reg_masked(0, 0x0, 0x15)
+
+        # Multipath action in ovs-ofctl command is corresponding as follows:
+        #  format)
+        #    multipath(fields, basis, algorithm, n_links, arg, dst[start..end])
+        #    NXActionMultipath.__init__(
+        #        self,fields, basis, algorithm, max_link, arg, ofs_nbits, dst)
+        #    * Note: max_link = n_links - 1.
+        #            ofs_nbits = ((start << 6) | end)
+        #  e.g.)
+        #     multipath(symmetric_l4,1024,hrw,6,0,NXM_NX_REG0[0..3])
+        actions = [parser.NXActionMultipath(
+            fields=nicira_ext.NX_HASH_FIELDS_SYMMETRIC_L4,
+            basis=1024,
+            algorithm=nicira_ext.NX_MP_ALG_HRW,
+            max_link=5,
+            arg=0,
+            ofs_nbits=((0 << 6) | 3),
+            dst=ofproto.nxm_nx_reg(0))]
+
+        # Send nxt_flow_mod by using the utility method of Datapath class
+        datapath.send_flow_mod(
+            rule=rule, cookie=0, command=ofproto.OFPFC_ADD,
+            idle_timeout=0, hard_timeout=0, actions=actions)
+
      def add_flow(self, datapath, in_port, dst, actions):
          ofproto = datapath.ofproto


$ sudo ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
  cookie=0x0, duration=3.228s, table=0, n_packets=2, n_bytes=140, idle_age=2, 
reg0=0/0x15 actions=multipath(symmetric_l4,1024,hrw,6,0,NXM_NX_REG0[0..3])


Thanks,
Iwase

>
> I appreciate any help since I am new to RYU and don’t seem to find answers 
> myself by going through the ryu code base.
>
> Ivica
>
>
>
> ------------------------------------------------------------------------------
>
>
>
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>

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

Reply via email to