Yamahata,

When I convert to the required type (sequence of 8 hex) from the type given 
when iterating over the packet with ryu.lib.packet packet it works correctly.


Thanks for the quick response,
--Matt

-----Original Message-----
From: Isaku Yamahata [mailto:yamah...@valinux.co.jp] 
Sent: Thursday, July 11, 2013 6:27 PM
To: Claiborne, Matt
Cc: ryu-devel@lists.sourceforge.net
Subject: Re: Ryu - flow mod with IPv6 source/dest match issue

On Fri, Jul 12, 2013 at 10:20:33AM +0900, Isaku Yamahata wrote:
> Hi, thank you for reporting this.
> Please use ryu-devel@lists.sourceforge.net. Added it to CC:
> 
> ipv6 value is supported.
> > match.set_ipv6_src(ipsrc)
> This line caught my eyes.
> 
> What type is ipsrc? The serializer expects the value to be '!8H'.
> Not bytearray/str of 16byte length. Nor single integer.
> I guess that ipsrc is different from what the serializer expects.
> So conversion is needed before passing set_ipv6_src().
> (Clean up is going on right now.)

Example is 

ryu/tests/unit/packet/test_parser_v12.py
class TestOFPMatch(unittest.TestCase):
    def _test_set_ipv6_src(self, ipv6, mask=None):

thanks,

> 
> 
> from ofproto_v1_3_parser.py,
> > class MTIPv6Src(MTIPv6, OFPMatchField):
> >    pack_str = '!8H'
> 
> thanks,
> 
> On Thu, Jul 11, 2013 at 09:41:37PM +0000, Claiborne, Matt wrote:
> > I am seeing the following error when trying to send a flow mod with 
> > a match rule for ipv6 source or destination addresses.  IPv4 flow mods work 
> > correctly.
> > Are there any other options needed in RYU to send a flow mod with ipv6 
> > rules? 
> > Any help/suggestions would be greatly appreciated.
> > 
> >  
> > 
> > [0x1000082e5f694c00] ('143.0.1.211', 60641): ADD FLOW:
> > 
> > hub: uncaught exception: Traceback (most recent call last):
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/lib/
> > hub.py", line 48, in _launch
> > 
> >     func(*args, **kwargs)
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/base/
> > app_manager.py", line 110, in _event_loop
> > 
> >     handler(ev)
> > 
> >   File "/root/app/3base.py", line 602, in packet_in_handler
> > 
> >     self.send_flow_mod(msg.datapath, match, actions, inst, 10, 0, 
> > cookie)
> > 
> >   File "/root/app/3base.py", line 971, in send_flow_mod
> > 
> >     datapath.send_msg(req)
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/contro
> > ller /controller.py", line 220, in send_msg
> > 
> >     msg.serialize()
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/ofprot
> > o/ ofproto_parser.py", line 145, in serialize
> > 
> >     self._serialize_body()
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/ofprot
> > o/ ofproto_v1_3_parser.py", line 1488, in _serialize_body
> > 
> >     match_len = self.match.serialize(self.buf, offset)
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/ofprot
> > o/ ofproto_v1_3_parser.py", line 570, in serialize
> > 
> >     f.serialize(buf, field_offset)
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/ofprot
> > o/ ofproto_v1_3_parser.py", line 1198, in serialize
> > 
> >     self.putv6(buf, offset, self.value, self.mask)
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/ofprot
> > o/ ofproto_v1_3_parser.py", line 913, in putv6
> > 
> >     self._putv6(buf, offset + self.length, value)
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/ofprot
> > o/ ofproto_v1_3_parser.py", line 908, in _putv6
> > 
> >     *value)
> > 
> >   File 
> > "/usr/local/lib/python2.6/dist-packages/ryu-2.1-py2.6.egg/ryu/ofprot
> > o/ ofproto_parser.py", line 154, in msg_pack_into
> > 
> >     buf += struct.pack(fmt, *args)
> > 
> > error: pack requires exactly 8 arguments
> > 
> >  
> > 
> >  
> > 
> > Code:
> > 
> > ?
> > 
> >                 @set_ev_cls(ofp_event.EventOFPPacketIn, 
> > MAIN_DISPATCHER)
> > 
> >                 def packet_in_handler(self, ev):
> > 
> >                                 ?
> > 
> >                                                 if (protocol_name ==
> > "ipv6"):    
> > 
> >                                                                 
> > print (vars(p))
> > 
> >                                                                 
> > ipsrc = p.src
> > 
> >                                                                 
> > ipdst = p.dst
> > 
> > ?
> > 
> >  
> > 
> >                                 if (v_ethertype == 0x86DD):
> > 
> >                                                 if dst in 
> > self.mac_to_port[dp]:
> > 
> >                                                                 
> > out_port = self.mac_to_port[dp][dst]
> > 
> >                                                 else:
> > 
> >                                                                 
> > out_port = ofp.OFPP_FLOOD
> > 
> >  
> > 
> >                                                 self.send_packet_out 
> > (msg.datapath, 0xffffffff, in_port, ev.msg.data, out_port)
> > 
> >  
> > 
> >                                                 match = 
> > ofp_parser.OFPMatch()
> > 
> >                                                 
> > match.set_dl_type(v_ethertype)
> > 
> >                                                 
> > match.set_ipv6_src(ipsrc)
> > 
> >                                                 
> > match.set_in_port(in_port)
> > 
> >                                                 
> > match.set_vlan_vid(vid)
> > 
> >  
> > 
> >                                                 actions = 
> > [ofp_parser.OFPActionOutput(out_port, 0)]
> > 
> >                                                 inst = 
> > [ofp_parser.OFPInstructionActions(ofp.OFPIT_APPLY_ACTIONS, actions)]
> > 
> >  
> > 
> >                                                 cookie = in_port ^ 
> > dp.id ^ out_port
> > 
> >                                                 self.send_flow_mod 
> > (msg.datapath, match, actions, inst, 10, 0, cookie)
> > 
> >  
> > 
> > ?
> > 
> >                 def send_flow_mod(self, datapath, match, actions, 
> > inst, hardtime, idletime, cookie):
> > 
> >                                 self.printme("ADD FLOW:", datapath)
> > 
> >                                
> > 
> >                                 if self.ipControlTableMode:
> > 
> >                                                 tableID = 50
> > 
> >                                 else:
> > 
> >                                                 tableID = 100
> > 
> >                                                
> > 
> >                                 ofp = datapath.ofproto
> > 
> >                                 ofp_parser = datapath.ofproto_parser
> > 
> >                                 req = 
> > ofp_parser.OFPFlowMod(datapath=datapath,
> > 
> >                                                 cookie=cookie, 
> > cookie_mask=0,
> > 
> >                                                 table_id=tableID, 
> > command= ofp.OFPFC_ADD,
> > 
> >                                                 
> > idle_timeout=idletime, hard_timeout=hardtime,
> > 
> >                                                 priority=32768,
> > 
> >                                                 
> > buffer_id=0xffffffff,
> > 
> >                                                 
> > out_port=ofp.OFPP_ANY,
> > 
> >                                                 
> > out_group=ofp.OFPG_ANY,
> > 
> >                                                 flags=0,
> > 
> >                                                 match=match, 
> > instructions=inst)
> > 
> >                                 datapath.send_msg(req)
> > 
> >  
> > 
> >  
> > 
> >  
> > 
> > Thanks,
> > 
> > --Matt
> > 
> >  
> > 
> 
> --
> yamahata
> 

-- 
yamahata

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to