mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-08 22:06:10 +02:00
packet lib: make vrrp get_payload robust
Let's not make an assumption about the position of IP(v4 or v6) and VRRP. The original code excepts pure ether or vlan and search them in try-and-error way. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
0b5291856b
commit
38893d906b
@ -211,21 +211,25 @@ 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
|
||||
idx = 0
|
||||
for protocol in packet_:
|
||||
if isinstance(protocol, ipv4.ipv4) or isinstance(protocol,
|
||||
ipv6.ipv6):
|
||||
may_ip = protocol
|
||||
try:
|
||||
if isinstance(packet_.protocols[idx + 1], vrrp):
|
||||
may_vrrp = packet_.protocols[idx + 1]
|
||||
finally:
|
||||
break
|
||||
idx += 1
|
||||
|
||||
if (not isinstance(may_ip, ipv4.ipv4) and
|
||||
not isinstance(may_ip, ipv6.ipv6)):
|
||||
if may_ip and may_vrrp:
|
||||
return may_ip, may_vrrp
|
||||
else:
|
||||
return None, None
|
||||
if not isinstance(may_vrrp, vrrp):
|
||||
return None, None
|
||||
return may_ip, may_vrrp
|
||||
|
||||
@classmethod
|
||||
def register_vrrp_version(cls, version,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user