> On Fri,  2 Aug 2013 16:36:29 +0900
> YAMAMOTO Takashi <[email protected]> wrote:
> 
>> 
>> Signed-off-by: YAMAMOTO Takashi <[email protected]>
>> ---
>>  ryu/lib/packet/vrrp.py | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/ryu/lib/packet/vrrp.py b/ryu/lib/packet/vrrp.py
>> index 772d913..747d0c4 100644
>> --- a/ryu/lib/packet/vrrp.py
>> +++ b/ryu/lib/packet/vrrp.py
>> @@ -215,7 +215,7 @@ class vrrp(packet_base.PacketBase):
>>  
>>          try:
>>              may_ip, may_vrrp = protocols[-2], protocols[-1]
>> -            if isinstance(may_vrrp, bytearray):
>> +            if isinstance(may_vrrp, bytearray):  # padding?
>>                  may_ip, may_vrrp = protocols[-3], protocols[-2]
>>          except IndexError:
>>              return None, None
> 
> What the purpose is this function? Just getting ipv4(or v6) header and
> vrrp content? Then why we can't do simply in the following way instead
> of searching in the 'try and error' manner?

it looks like a matter of preference to me.
the current code ensures the order of headers, though.

the name "get_payload" is quite odd.
"get_ip_and_vrrp" or something like that would be better.

YAMAMOTO Takashi

> 
> =
>>From 0a757cbffbcdcf504f46003c92660b991b711a1a Mon Sep 17 00:00:00 2001
> From: FUJITA Tomonori <[email protected]>
> Date: Fri, 2 Aug 2013 18:01:23 +0900
> Subject: [PATCH] packet lib: make vrrp get_payload robust
> 
> Don't assume that ip and vrrp are at specific locations.
> 
> Signed-off-by: FUJITA Tomonori <[email protected]>
> ---
>  ryu/lib/packet/vrrp.py | 25 +++++++++++++------------
>  1 file changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/ryu/lib/packet/vrrp.py b/ryu/lib/packet/vrrp.py
> index 772d913..56fc8ae 100644
> --- a/ryu/lib/packet/vrrp.py
> +++ b/ryu/lib/packet/vrrp.py
> @@ -211,21 +211,22 @@ class vrrp(packet_base.PacketBase):
>  
>      @staticmethod
>      def get_payload(packet_):
> -        protocols = packet_.protocols
> +        may_ip = None
> +        may_vrrp = None
>  
> -        try:
> -            may_ip, may_vrrp = protocols[-2], protocols[-1]
> -            if isinstance(may_vrrp, bytearray):
> -                may_ip, may_vrrp = protocols[-3], protocols[-2]
> -        except IndexError:
> -            return None, None
> +        for protocol in packet_:
> +            if isinstance(protocol, ipv4.ipv4) or isinstance(protocol,
> +                                                             ipv6.ipv6):
> +                may_ip = protocol
> +                continue
>  
> -        if (not isinstance(may_ip, ipv4.ipv4) and
> -                not isinstance(may_ip, ipv6.ipv6)):
> -            return None, None
> -        if not isinstance(may_vrrp, vrrp):
> +            if isinstance(protocol, vrrp):
> +                may_vrrp = protocol
> +
> +        if may_ip and may_vrrp:
> +            return may_ip, may_vrrp
> +        else:
>              return None, None
> -        return may_ip, may_vrrp
>  
>      @classmethod
>      def register_vrrp_version(cls, version,
> -- 
> 1.7.12.4 (Apple Git-37)
> 
> 
> ------------------------------------------------------------------------------
> Get your SQL database under version control now!
> Version control is standard for application code, but databases havent 
> caught up. So what steps can you take to put your SQL databases under 
> version control? Why should you start doing it? Read more to find out.
> http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
> _______________________________________________
> Ryu-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/ryu-devel

------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to