checksum() was modifying argument when it is bytearray.  Make sure
checksum() doesn't modify its argument.

Signed-off-by: IWAMOTO Toshihiro <[email protected]>
---
 ryu/lib/packet/packet_utils.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ryu/lib/packet/packet_utils.py b/ryu/lib/packet/packet_utils.py
index 58a9e69..546b49c 100644
--- a/ryu/lib/packet/packet_utils.py
+++ b/ryu/lib/packet/packet_utils.py
@@ -26,10 +26,10 @@ def carry_around_add(a, b):
 
 
 def checksum(data):
+    data = six.binary_type(data)    # input can be bytearray.
     if len(data) % 2:
         data += b'\x00'
 
-    data = six.binary_type(data)    # input can be bytearray.
     s = sum(array.array('H', data))
     s = (s & 0xffff) + (s >> 16)
     s += (s >> 16)
-- 
2.1.4


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to