On Wed, 22 Oct 2014 20:47:47 +0200
Benjamin Eggerstedt <[email protected]> wrote:

> Hi,
> 
>> I think so unless such flow is installed. What flows are installed on
>> your switch?
> 
> Flow 2 was added afterwards to discard the packet that Ryu didn't like.
> Basically just the "Send everything to the controller" flow.
> 
> OS6900-OF-> debug openflow flow-id all
> 
> Flow ID: 1
>   Logical Switch: vswitch
>   Priority: 0
>   Idle Timeout: 0
>   Hard Timeout: 0
>   Flow Type: Wildcard
>   Match:
>   Action: Out: Controller;

The maximu size of a packet that the switch sends to a controller is
128 bytes?

> Flow ID: 2
>   Logical Switch: vswitch
>   Priority: 1
>   Idle Timeout: 0
>   Hard Timeout: 0
>   Flow Type: Wildcard
>   Match:  Dst MAC: 01:80:c2:00:00:0e/ff:ff:ff:ff:ff:ff, Ether-type: 88cc
>   Action: Drop
> 
>>> b) The lldp.py needs to handle this?
>> Yeap, it should. I'll take care of it shortly.
> 
> Very good, I shall be able to test that in my lab and confirm the
> behaviour/fix.

Here is a fix.

Thanks!

diff --git a/ryu/lib/packet/lldp.py b/ryu/lib/packet/lldp.py
index 1202225..d0cae2f 100644
--- a/ryu/lib/packet/lldp.py
+++ b/ryu/lib/packet/lldp.py
@@ -124,7 +124,7 @@ class lldp(packet_base.PacketBase):
                 self.tlvs[-1].tlv_type == LLDP_TLV_END)
 
     @classmethod
-    def parser(cls, buf):
+    def _parser(cls, buf):
         tlvs = []
 
         while buf:
@@ -144,6 +144,13 @@ class lldp(packet_base.PacketBase):
 
         return lldp_pkt, None, buf
 
+    @classmethod
+    def parser(cls, buf):
+        try:
+            return cls._parser(buf)
+        except:
+            return None, None, buf
+
     def serialize(self, payload, prev):
         data = bytearray()
         for tlv in self.tlvs:
diff --git a/ryu/tests/unit/packet/test_lldp.py 
b/ryu/tests/unit/packet/test_lldp.py
index 646af1e..c8daf58 100644
--- a/ryu/tests/unit/packet/test_lldp.py
+++ b/ryu/tests/unit/packet/test_lldp.py
@@ -286,6 +286,10 @@ class TestLLDPOptionalTLV(unittest.TestCase):
         # End
         eq_(tlvs[16].tlv_type, lldp.LLDP_TLV_END)
 
+    def test_parse_corrupted(self):
+        buf = self.data
+        pkt = packet.Packet(buf[:128])
+
     def test_serialize(self):
         pkt = packet.Packet()
 

------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to