Hi,
First, OVS does not support OF1.5 enough.
So there are many TODO on OVS GitHub page.
https://github.com/openvswitch/ovs/blob/master/OPENFLOW-1.1%2B.md
If you want to use NXActionRegMove, you can do it with OF1.3.
e.g.)
match = parser.OFPMatch()
actions = [parser.NXActionRegMove('tunnel_id', 'vlan_vid', 12)]
insts = [parser.OFPInstructionActions(
ofproto.OFPIT_APPLY_ACTIONS, actions)]
mod = parser.OFPFlowMod(datapath, match=match, instructions=insts)
datapath.send_msg(mod)
# ovs-ofctl dump-flows s1
NXST_FLOW reply (xid=0x4):
cookie=0x0, duration=6.982s, table=0, n_packets=2, n_bytes=140, idle_age=5,
actions=move:NXM_NX_TUN_ID[0..11]->OXM_OF_VLAN_VID[]
Thanks,
Iwase
On 2015年10月13日 14:13, Takao Magoori wrote:
> Hi all,
>
> As follows, I want to send an OFPFlowMod message, which has an action
> to copy lower 12 bits tunnel_id into vlan_vid (On OVS, which is
> equivalent to"move:NXM_NX_TUN_ID[0..11]->NXM_OF_VLAN_TCI[0..11]" ).
>
> But in case of NXActionRegMove, OFPET_BAD_ACTION
> (OFPBAC_BAD_EXP_TYPE) error occurs.
> In case of OFPActionCopyField, OFPET_BAD_ACTION (OFPBAC_BAD_LEN) error occurs.
> Is there a way to do " move:src[start..end]->dst[start..end]" on Ryu
> application ?
>
> Ryu version: 3.26
>
> #### ovs add-br command
> $ sudo ovs-vsctl --may-exist add-br testbr0 \
> -- set bridge testbr0 protocols=OpenFlow15 fail-mode=secure \
> -- set-controller testbr0 tcp:127.0.0.1:6633
>
>
> ##### test application source code ####
> import functools
> from ryu.base import app_manager
> from ryu.controller import ofp_event
> from ryu.controller import handler
> from ryu.ofproto import ofproto_v1_5
>
> OVS_IN_PORT = 0xfff8
>
> class TestApp(app_manager.RyuApp):
>
> OFP_VERSIONS = [ofproto_v1_5.OFP_VERSION]
>
> @handler.set_ev_cls(
> ofp_event.EventOFPSwitchFeatures,
> handler.CONFIG_DISPATCHER,
> )
> def handle_ovs_switch_features(self, event):
> datapath = event.msg.datapath
> ofproto = datapath.ofproto
> ofparser = datapath.ofproto_parser
> flow_mod_factory = functools.partial(
> ofparser.OFPFlowMod,
> datapath=datapath,
> # cookie=0xf00,
> command=ofproto.OFPFC_ADD,
> )
> apply_actions_factory = functools.partial(
> ofparser.OFPInstructionActions,
> type_=ofproto.OFPIT_APPLY_ACTIONS,
> )
>
> datapath.send_msg(
> flow_mod_factory(
> table_id=0,
> priority=100,
> match=ofparser.OFPMatch(
> tunnel_id=(1 << 12, 0xfff << 12),
> ),
> instructions=[
> apply_actions_factory(actions=[
> ofparser.OFPActionPushVlan(),
> ofparser.OFPActionSetField(
> vlan_pcp=1,
> ),
> ofparser.NXActionRegMove(
> src_field='tunnel_id', src_ofs=0,
> dst_field='vlan_vid', dst_ofs=0,
> n_bits=12,
> ),
> # ofparser.OFPActionCopyField(
> # n_bits=12,
> # src_offset=0,
> # dst_offset=0,
> # oxm_ids=[
> # ofparser.OFPOxmId('tunnel_id'),
> # ofparser.OFPOxmId('vlan_vid'),
> # ]
> # ),
> ofparser.NXActionResubmitTable(
> in_port=OVS_IN_PORT,
> table_id=20,
> ),
> ]),
> ],
> ),
> )
> return
>
>
> #### error message (in case of NXActionRegMove)
> # ryu-manager --verbose testmanager
> loading app testmanager
> loading app ryu.controller.ofp_handler
> instantiating app testmanager of TestApp
> instantiating app ryu.controller.ofp_handler of OFPHandler
> BRICK TestApp
> CONSUMES EventOFPSwitchFeatures
> BRICK ofp_event
> PROVIDES EventOFPSwitchFeatures TO {'TestApp': {'config'}}
> CONSUMES EventOFPSwitchFeatures
> CONSUMES EventOFPPortDescStatsReply
> CONSUMES EventOFPEchoRequest
> CONSUMES EventOFPErrorMsg
> CONSUMES EventOFPHello
> connected socket:<eventlet.greenio.base.GreenSocket object at
> 0x7f911f9dd2b0> address:('127.0.0.1', 56714)
> hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x7f911f9e6d68>
> move onto config mode
> EVENT ofp_event->TestApp EventOFPSwitchFeatures
> switch features ev
> version=0x6,msg_type=0x6,msg_len=0x20,xid=0xd2da111d,OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=183359575435075,n_buffers=256,n_tables=254)
> EventOFPErrorMsg received.
> version=0x6, msg_type=0x1, msg_len=0x24, xid=0xd2da111f
> `-- msg_type: OFPT_ERROR(1)
> OFPErrorMsg(type=0x1, code=0x6,
> data=b'\x06\x12\x00\x18\xd2\xda\x11\x1f\x00\x0d\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00')
> |-- type: OFPET_BAD_REQUEST(1)
> |-- code: OFPBRC_BAD_LEN(6)
> `-- data: version=0x6, msg_type=0x12, msg_len=0x18, xid=0xd2da111f
> `-- msg_type: OFPT_MULTIPART_REQUEST(18)
> EventOFPErrorMsg received.
> version=0x6, msg_type=0x1, msg_len=0x4c, xid=0xd2da1120
> `-- msg_type: OFPT_ERROR(1)
> OFPErrorMsg(type=0x2, code=0x3,
> data=b'\x06\x0e\x00\x90\xd2\xda\x11\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x18\x80\x00\x4d\x10\x00\x00\x00\x00\x00\x00\x10\x00')
> |-- type: OFPET_BAD_ACTION(2)
> |-- code: OFPBAC_BAD_EXP_TYPE(3)
> `-- data: version=0x6, msg_type=0xe, msg_len=0x90, xid=0xd2da1120
> `-- msg_type: OFPT_FLOW_MOD(14)
>
>
> #### error message (in case of OFPActionCopyField)
> # ryu-manager --verbose testmanager
> loading app testmanager
> loading app ryu.controller.ofp_handler
> instantiating app ryu.controller.ofp_handler of OFPHandler
> instantiating app testmanager of TestApp
> BRICK ofp_event
> PROVIDES EventOFPSwitchFeatures TO {'TestApp': {'config'}}
> CONSUMES EventOFPHello
> CONSUMES EventOFPSwitchFeatures
> CONSUMES EventOFPPortDescStatsReply
> CONSUMES EventOFPEchoRequest
> CONSUMES EventOFPErrorMsg
> BRICK TestApp
> CONSUMES EventOFPSwitchFeatures
> connected socket:<eventlet.greenio.base.GreenSocket object at
> 0x7f1a38512278> address:('127.0.0.1', 56730)
> hello ev <ryu.controller.ofp_event.EventOFPHello object at 0x7f1a3851fd68>
> move onto config mode
> EVENT ofp_event->TestApp EventOFPSwitchFeatures
> switch features ev
> version=0x6,msg_type=0x6,msg_len=0x20,xid=0xb8fb0c3c,OFPSwitchFeatures(auxiliary_id=0,capabilities=79,datapath_id=121704233743943,n_buffers=256,n_tables=254)
> EventOFPErrorMsg received.
> version=0x6, msg_type=0x1, msg_len=0x24, xid=0xb8fb0c3e
> `-- msg_type: OFPT_ERROR(1)
> OFPErrorMsg(type=0x1, code=0x6,
> data=b'\x06\x12\x00\x18\xb8\xfb\x0c\x3e\x00\x0d\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00')
> |-- type: OFPET_BAD_REQUEST(1)
> |-- code: OFPBRC_BAD_LEN(6)
> `-- data: version=0x6, msg_type=0x12, msg_len=0x18, xid=0xb8fb0c3e
> `-- msg_type: OFPT_MULTIPART_REQUEST(18)
> EventOFPErrorMsg received.
> version=0x6, msg_type=0x1, msg_len=0x4c, xid=0xb8fb0c3f
> `-- msg_type: OFPT_ERROR(1)
> OFPErrorMsg(type=0x2, code=0x1,
> data=b'\x06\x0e\x00\x88\xb8\xfb\x0c\x3f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x64\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x18\x80\x00\x4d\x10\x00\x00\x00\x00\x00\x00\x10\x00')
> |-- type: OFPET_BAD_ACTION(2)
> |-- code: OFPBAC_BAD_LEN(1)
> `-- data: version=0x6, msg_type=0xe, msg_len=0x88, xid=0xb8fb0c3f
> `-- msg_type: OFPT_FLOW_MOD(14)
>
> ------------------------------------------------------------------------------
> _______________________________________________
> 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