On Mon, 31 Aug 2015 11:35:10 -0400
A Sydney <[email protected]> wrote:

> Questions:
> 
> 1. Based on your reply, if "_MIN_LEN" is set to 1, the parser should crash.
> However, that is not the case. In fact, I am able to obtain the dhcp header
> just fine.

Sorry, I didn't clearly explain.

_MIN_LEN tells other protocols that the _minimum_ length of the buffer
can be parsed.

For example, if dhcp's _MIN_LEN is set to 1, udp parser _could_ pass
one-byte-length buffer to dhcp's parse. Then, dhcp parser crashes at:

https://github.com/osrg/ryu/blob/master/ryu/lib/packet/dhcp.py#L179

Normally, even if you set dhcp _MIN_LEN to 1, dhcp parser works fine
because full dhcp packets are used. In such case, dhcp parser never
get one-byte-length buffer. But with a truncated packet, you might hit
the problem with setting _MIN_LEN to 1.


> 2. How do I set "_MIN_LEN" to 236?

I've pushed the following patch.

> REF:
> Also note that since I've included your path, I now use the following to
> obtain the dhcp header:
> 
> dhcp_pkt = pkt.get_protocol(dhcp.dhcp)

Thanks for the testings. I've also pushed that patch.

Ryu 3.25 that I've just released should work for you. If not, please
let me know.

=
>From 396c32d4aa3950ae2cb9715cf23607397acd7837 Mon Sep 17 00:00:00 2001
From: FUJITA Tomonori <[email protected]>
Date: Thu, 3 Sep 2015 22:47:35 +0900
Subject: [PATCH 1/2] packet: dhcp should set _MIN_LEN

Signed-off-by: FUJITA Tomonori <[email protected]>
---
 ryu/lib/packet/dhcp.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ryu/lib/packet/dhcp.py b/ryu/lib/packet/dhcp.py
index e82a645..b0d6092 100644
--- a/ryu/lib/packet/dhcp.py
+++ b/ryu/lib/packet/dhcp.py
@@ -133,6 +133,7 @@ class dhcp(packet_base.PacketBase):
                     every DHCP message).
     ============== ====================
     """
+    _MIN_LEN = 236
     _HLEN_UNPACK_STR = '!BBB'
     _HLEN_UNPACK_LEN = struct.calcsize(_HLEN_UNPACK_STR)
     _DHCP_UNPACK_STR = '!BIHH4s4s4s4s%ds%ds64s128s'
-- 
1.9.5 (Apple Git-50.3)


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to