Dear All:

I tried with the newest udp parser and "dhcpPacket = pkt.get_protocol(dhcp.dhcp)" worked well.
Please find the attached pach and  give comments.******

Best regards.

On 2015/10/07 22:36, alyosha wrote:
Sorry, I dropped mailing list.

Hi, Mr. Yi Tseng.
Thank you  for comments.
>>That's strange, because udp parser will check if it's a dhcp packet and parser it......

I created simple_dhcp_server.py with old udp parser, which did not support dhcp packet.
I will try and check with new udp parser, which you pointed out.
So, It may not a bug.

Best regards.

On 2015/10/07 22:16, Yi Tseng wrote:
Please don't drop the mailing list

Hi Shuoling Deng:
It is necessary to parse every packet-in message if you want controller be a simple dhcp server.

Hi alyosha:
That's strange, because udp parser will check if it's a dhcp packet and parser it......
maybe it is a bug for parsing udp packet.

https://github.com/osrg/ryu/blob/master/ryu/lib/packet/udp.py#L54


2015-10-07 20:41 GMT+08:00 alyosha <tan...@gmail.com <mailto:tan...@gmail.com>>:

    Thank you for comments, Mr Shuoling Deng and Mr Yi Tseng.

    >> it looks like parse every PAKCET-IN ?
    would this cause heavy load to Controller.

    As you pointed out, this application parses all PACKET-IN to
    handle DHCP Packet.
    Bit this is a "simple" dhcp server.
    So this application shoud be used in a small network.
    And you shoud set enough flowentries to avoid PACKET-IN.


    >> dhcp_packet = pkt.get_protocol(dhcp.dhcp)
    At first  I tried.
But, DHCP Packet is parsed into buf[msg._MIN_LEN:total_length] in ryu.lib.packet.udp.
    Not DHCP Class.
    So, it did not work.

    Best regards.


    On 2015/10/07 17:48, Yi Tseng wrote:
    Hello

    Maybe you can try


    dhcp_packet = pkt.get_protocol(dhcp.dhcp)
    if not dhcp_packet:
         # not dhcp packet
         return

    # ... handling dhcp packet

    2015-10-07 15:40 GMT+08:00 Shuoling Deng
    <mr.dengshuol...@gmail.com>:

        it looks like parse every PAKCET-IN ?

        would this cause heavy load to Controller.


        On Wed, Oct 7, 2015 at 12:52 AM, alyosha <tan...@gmail.com>
        wrote:

            Nice to e-meet you. My name is Okano Yuu.
            I created a new ryu application, simple_dhcp_server for
            DHCPServer.

            I tested this application with 2 VMs, and this
            application worked well.
            VM1... DHCPClient
            VM2... DHCPServer(Ryu & OpenVSwitch)

            I set  one flowentry on OpenVSwitch  "ovs-ofctl add-flow
            br-test udp,actions=Controller".

            This application supports pep8.
            Check this code and comments please.

            Thanks!




            
------------------------------------------------------------------------------

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




-- Shuoling Deng
        Dept. of Computer Science and Technology
        Xi'an Jiaotong University
        Xi'an, 710049, P.R. China

        
------------------------------------------------------------------------------
        Full-scale, agent-less Infrastructure Monitoring from a
        single dashboard
        Integrate with 40+ ManageEngine ITSM Solutions for complete
        visibility
        Physical-Virtual-Cloud Infrastructure monitoring from one
        console
        Real user monitoring with APM Insights and performance trend
        reports
        Learn More
        http://pubads.g.doubleclick.net/gampad/clk?id=247754911&iu=/4140
        _______________________________________________
        Ryu-devel mailing list
        Ryu-devel@lists.sourceforge.net
        <mailto:Ryu-devel@lists.sourceforge.net>
        https://lists.sourceforge.net/lists/listinfo/ryu-devel




-- Yi Tseng (a.k.a Takeshi)
    Taiwan National Chiao Tung University
    Department of Computer Science
    W2CNLab

    http://blog.takeshi.tw




--
Yi Tseng (a.k.a Takeshi)
Taiwan National Chiao Tung University
Department of Computer Science
W2CNLab

http://blog.takeshi.tw


From 13ba433a9e35cabab6cdf05887641b14a1026515 Mon Sep 17 00:00:00 2001
From: Okano Yuu <alexei.fyodorovich.karama...@gmail.com>
Date: Sat, 10 Oct 2015 00:32:57 +0900
Subject: [PATCH] modify simple_dhcp_server.py

apply pkt.get_protocol(dhcp.dhcp) to get dhcpPacket.

Signed-off-by: Okano Yuu <alexei.fyodorovich.karama...@gmail.com>
---
 ryu/app/simple_dhcp_server.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/ryu/app/simple_dhcp_server.py b/ryu/app/simple_dhcp_server.py
index 5bb986e..3b0295b 100644
--- a/ryu/app/simple_dhcp_server.py
+++ b/ryu/app/simple_dhcp_server.py
@@ -43,11 +43,12 @@ class SimpleDHCPServer(app_manager.RyuApp):
         in_port = msg.match['in_port']
 
         pkt = packet.Packet(msg.data)
-        udpPacket = pkt.get_protocol(udp.udp)
+        dhcpPacket = pkt.get_protocol(dhcp.dhcp)
 
-        # check if DHCP Pacet
-        if udpPacket and udpPacket.src_port == 68:
-            dhcpPacket = dhcp.dhcp.parser(pkt.protocols[-1])[0]
+        if not dhcpPacket:
+            return
+
+        if dhcpPacket:
             msgType = dhcpPacket.options.option_list[0].value
 
             if msgType == '\x01':
-- 
2.3.8 (Apple Git-58)

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

Reply via email to