From 31c0941fb8b734b47b948b8aa0346c0d6eb506e4 Mon Sep 17 00:00:00 2001 From: Yuichi Ito Date: Thu, 12 Dec 2013 13:56:32 +0900 Subject: [PATCH] packet lib: ipv6: correct a default parameter of opt_header the length of opt_header has to be a multiple of 8. wrong: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | nxt | size | (opt)type=1 | (opt)len=6 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | (opt)data='\x00\x00\x00\x00\x00\x00' (6 octet) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ right: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | nxt | size | (opt)type=1 | (opt)len=4 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | (opt)data='\x00\x00\x00\x00' (4 octet) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Signed-off-by: Yuichi Ito Signed-off-by: FUJITA Tomonori --- ryu/lib/packet/ipv6.py | 4 ++-- ryu/tests/unit/packet/test_ipv6.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ryu/lib/packet/ipv6.py b/ryu/lib/packet/ipv6.py index 9f04da5f..59d7e18f 100644 --- a/ryu/lib/packet/ipv6.py +++ b/ryu/lib/packet/ipv6.py @@ -203,8 +203,8 @@ class opt_header(header): buf = struct.pack(self._PACK_STR, self.nxt, self.size) buf = bytearray(buf) if self.data is None: - self.data = [option(type_=1, len_=6, - data='\x00\x00\x00\x00\x00\x00')] + self.data = [option(type_=1, len_=4, + data='\x00\x00\x00\x00')] for opt in self.data: buf.extend(opt.serialize()) return buf diff --git a/ryu/tests/unit/packet/test_ipv6.py b/ryu/tests/unit/packet/test_ipv6.py index 4e46d31d..a2a13433 100644 --- a/ryu/tests/unit/packet/test_ipv6.py +++ b/ryu/tests/unit/packet/test_ipv6.py @@ -528,7 +528,7 @@ class Test_hop_opts(unittest.TestCase): eq_(res[0], 6) eq_(res[1], 0) - opt = ipv6.option(type_=1, len_=6, data='\x00\x00\x00\x00\x00\x00') + opt = ipv6.option(type_=1, len_=4, data='\x00\x00\x00\x00') eq_(str(buf[2:]), opt.serialize()) @@ -609,7 +609,7 @@ class Test_dst_opts(unittest.TestCase): eq_(res[0], 6) eq_(res[1], 0) - opt = ipv6.option(type_=1, len_=6, data='\x00\x00\x00\x00\x00\x00') + opt = ipv6.option(type_=1, len_=4, data='\x00\x00\x00\x00') eq_(str(buf[2:]), opt.serialize())