Thank you for testing.

On Mon, Mar 25, 2013 at 03:23:15PM +0800, can. wrote:
> Hello, 
> 
> I tried to apply your patch to the latest master on github, but got an error 
> at
> line 12:
> 
> fatal: corrupt patch at line 12
> (the line with "import struct")

Oops, will fix.


> So I manually patched it, and found that the error is still:
> 
> Error in the datapath 2 from ('10.109.242.118', 57275)
> Traceback (most recent call last):
>   File "build/bdist.macosx-10.8-intel/egg/gevent/greenlet.py", line 390, in 
> run
>     result = self._run(*self.args, **self.kwargs)
>   File "/Library/Python/2.7/site-packages/ryu-1.7-py2.7.egg/ryu/controller/
> controller.py", line 308, in datapath_connection_factory
>     datapath.serve()
>   File "/Library/Python/2.7/site-packages/ryu-1.7-py2.7.egg/ryu/controller/
> controller.py", line 228, in serve
>     self._recv_loop()
>   File "/Library/Python/2.7/site-packages/ryu-1.7-py2.7.egg/ryu/controller/
> controller.py", line 97, in deactivate
>     method(self)
>   File "/Library/Python/2.7/site-packages/ryu-1.7-py2.7.egg/ryu/controller/
> controller.py", line 170, in _recv_loop
>     version, msg_type, msg_len, xid, buf)
>   File "/Library/Python/2.7/site-packages/ryu-1.7-py2.7.egg/ryu/ofproto/
> ofproto_parser.py", line 52, in msg
>     return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
>   File "/Library/Python/2.7/site-packages/ryu-1.7-py2.7.egg/ryu/ofproto/
> ofproto_v1_0_parser.py", line 52, in msg_parser
>     return parser(datapath, version, msg_type, msg_len, xid, buf)
>   File "/Library/Python/2.7/site-packages/ryu-1.7-py2.7.egg/ryu/ofproto/
> ofproto_v1_0_parser.py", line 1564, in parser
>     msg.buf, ofproto_v1_0.OFP_HEADER_SIZE)
> error: unpack_from requires a buffer of at least 12 bytes
> <Greenlet at 0x1018360f0: datapath_connection_factory(<socket at 0x101bc4ad0
> fileno=8 sock=10.109.242.11, ('10.109.242.118', 57275))> failed with error

Before message, didn't you find something like the following?
(If no, it should be fixed.)
 'This implies switch sending a malfold OpenFlow packet.'
 'version 0x%02x msg_type %d msg_len %d xid %d buf %s'

I think it's worthwhile of stack trace in this case because the switch sent
a malformed OF packet.
So I intentionally didn't suppress the stack trace as something critical
happened.

thanks,

> 2013/3/25 Isaku Yamahata <[email protected]>
> 
>     Signed-off-by: Isaku Yamahata <[email protected]>
>     ---
>      ryu/ofproto/ofproto_parser.py |   11 ++++++++++-
>      ryu/utils.py                  |    8 +++++++-
>      2 files changed, 17 insertions(+), 2 deletions(-)
> 
>     diff --git a/ryu/ofproto/ofproto_parser.py b/ryu/ofproto/ofproto_parser.py
>     index 26adead..dd04f1f 100644
>     --- a/ryu/ofproto/ofproto_parser.py
>     +++ b/ryu/ofproto/ofproto_parser.py
>     @@ -18,6 +18,7 @@ import logging
>      import struct
> 
>      from ryu import exception
>     +from ryu import utils
> 
>      from . import ofproto_common
> 
>     @@ -47,7 +48,15 @@ def msg(datapath, version, msg_type, msg_len, xid, 
> buf):
>          if msg_parser is None:
>              raise exception.OFPUnknownVersion(version=version)
> 
>     -    return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
>     +    try:
>     +        return msg_parser(datapath, version, msg_type, msg_len, xid, buf)
>     +    except struct.error:
>     +        LOG.exception(
>     +            'Encounter an error during parsing OpenFlow packet from
>     switch.'
>     +            'This implies switch sending a malfold OpenFlow packet.'
>     +            'version 0x%02x msg_type %d msg_len %d xid %d buf %s',
>     +            version, msg_type, msg_len, xid, utils.bytearray_to_hex(buf))
>     +        raise
> 
> 
>      class MsgBase(object):
>     diff --git a/ryu/utils.py b/ryu/utils.py
>     index d5b4479..88dce4b 100644
>     --- a/ryu/utils.py
>     +++ b/ryu/utils.py
>     @@ -42,7 +42,13 @@ def round_up(x, y):
> 
> 
>      def hex_array(data):
>     -    return ' '.join(hex(ord(chr)) for chr in data)
>     +    """Convert string into array of hexes to be printed."""
>     +    return ' '.join(hex(ord(char)) for char in data)
>     +
>     +
>     +def bytearray_to_hex(data):
>     +    """Convert bytearray into array of hexes to be printed."""
>     +    return ' '.join(hex(byte) for byte in data)
> 
> 
>      # the following functions are taken from OpenStack
>     --
>     1.7.10.4
> 
> 
> 
> 
> 
> --
> Best regards, 
> Can Zhang

-- 
yamahata

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to