For example, the packet library detects the TCP payload type by using
the TCP src/dst port, but in case of the BGP packet, the packet
library will try to parse a TCP ACK packet as a BGP packet, and will
fail to parse.

This patch enables to ignore an empty buffer and fixes this problem.

Signed-off-by: IWASE Yusuke <iwase.yusu...@gmail.com>
---
 ryu/lib/packet/packet.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/ryu/lib/packet/packet.py b/ryu/lib/packet/packet.py
index 043dae7..7de24c1 100644
--- a/ryu/lib/packet/packet.py
+++ b/ryu/lib/packet/packet.py
@@ -69,6 +69,9 @@ class Packet(StringifyMixin):
     def _parser(self, cls):
         rest_data = self.data
         while cls:
+            # Ignores an empty buffer
+            if not six.binary_type(rest_data).strip(b'\x00'):
+                break
             try:
                 proto, cls, rest_data = cls.parser(rest_data)
             except struct.error:
-- 
2.7.4


------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to