I've been recently dealing with someone else in Ryu and ran across errors.
The key to understanding what is wrong (somewhat) is looking at the
OFPErrorMsg print out. Your error says it has code=9 and type=4. If we look
at the OF1.3 spec
<https://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifications/openflow/openflow-spec-v1.3.0.pdf>
on
page 79 it outlines error codes/types.
type=4 means OFPET_BAD_MATCH
code=9 means OFPBMC_BAD_PREREQ
This implies to me you're match is missing something in your match.
Check out page 30 of the spec, it mentions this bad prereq error and says: "If
the match in a flow mod message specifies a field but fail to specify its
associated prerequisites, for example specifies an IPv4 address without
matching the EtherType to 0x800, the switch must return an ofp_error_msg
with OFPET_BAD_MATCH type and OFPBMC_BAD_PREREQ code."
I would do something like this instead: parser.OFPMatch(eth_type=0x800,
ipv4_src="10.0.0.5") The reason for this is that if you're trying to set a
field in the IP header you have to first make sure you are only trying to
modifying headers that are actually IP headers and not modifying incorrect
bits of an ARP packet for example.
As a side note, it would be really awesome if Ryu could output the
OFPET_BAD_MATCH and OFPBMC_BAD_PREREQ messages instead of error codes, but
I guess these could be protocol dependent. It's kind of annoying to have to
keep referencing the OF spec each time I see an error :)
On Wed Feb 25 2015 at 3:28:05 PM jinxuan wu <[email protected]> wrote:
> Hello,
>
> After some more investigation, I find out the problem in in this line
>
> *match1 = parser.OFPMatch(ipv4_dst="10.0.0.5”)*
>
> Can anyone tell me what is the correct format to set the ipv4 address? In
> the documentation it only mention its format is a IPV4 address. I also
> failed to find work code to set IPV4 open flow rules in rye online.
>
> Thank you!
>
> On Feb 24, 2015, at 5:36 PM, jinxuan wu <[email protected]> wrote:
>
> Hello,
>
> I’m new to Ryu controller, currently I’m trying to add a small function to
> the simple_switch_l3.py in ryu app. Testbed I'm using is mininet +
> openvswitch + openflow 1.3.
>
> Function I want to implement is write a rule to modify the destination ip
> address for matching packet(Match packet whose destination ip add is 10.0.4
> and rewrite that to 10.0.0.3). I'm trying to implement this based on
> existing simple_switch_13.py code. But now I get a error which indicate the
> rules is unable to write into the switch.
>
> @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
>
> match = parser.OFPMatch()
> actions = [parser.OFPActionOutput(ofproto.OFPP_CONTROLLER,
> ofproto.OFPCML_NO_BUFFER)]
> self.add_flow(datapath, 0, match, actions)
>
> *#Here is what I add *
> * match1 = parser.OFPMatch(ipv4_dst="10.0.0.5")*
> * action1 = [parser.OFPActionSetField(ipv4_dst="10.0.0.3")]*
>
> * self.add_flow(datapath, 2, match1, action1)*
>
> def add_flow(self, datapath, priority, match, actions):
> ofproto = datapath.ofproto
> parser = datapath.ofproto_parser
>
> inst = [parser.OFPInstructionActions(ofproto.OFPIT_APPLY_ACTIONS,
> actions)]
>
> mod = parser.OFPFlowMod(datapath=datapath, priority=priority,
> match=match, instructions=inst)
> datapath.send_msg(mod)
>
> After I run this code I get
>
> error msg ev version: 0x4 msg_type 0x1 xid 0x9168c30a
> OFPErrorMsg(code=9,data='\x04\x0e\x00X\x91h\xc3\n\x00\x00\
> x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
> x00\x00\x00\x00\x00\x00\x00\x01\xff\xff\xff\xff\x00\x00\
> x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x0c\
> x80\x00\x18\x04\n\x00\x00\x05\x00\x00\x00\x00',type=4) type 0x4 code 0x9
> 0x4 0xe 0x0 0x58 0x91 0x68 0xc3 0xa 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0
> 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 0xff 0xff 0xff 0xff
> 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x1 0x0 0xc 0x80 0x0
> 0x18 0x4 0xa 0x0 0x0 0x5 0x0 0x0 0x0 0x0
>
> Anyone could tell me how can I correctly write this rule to openvswitch in
> Ryu?
>
> Thank you very much!
>
>
> ------------------------------------------------------------
> ------------------
> Dive into the World of Parallel Programming The Go Parallel Website,
> sponsored
> by Intel and developed in partnership with Slashdot Media, is your hub for
> all
> things parallel software development, from weekly thought leadership blogs
> to
> news, videos, case studies, tutorials and more. Take a look and join the
> conversation now. http://goparallel.sourceforge.net/
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel
>
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel