From 4f224538e119ebce4a6fe71b3e0a2e280dba80d0 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Wed, 13 Oct 2021 15:51:43 +0200 Subject: [PATCH] Fix convertion of ipv4 to string on i386 and arch On architectures like i386 or arm convertion of IPv4 to string was failing in some cases. It was like that because some integer values were converted to long which is not the case on x86_64. It was like that for example with value "2871386400" which is used in ryu.tests.unit.ofproto.test_parser_v10:TestOFPMatch unit test. Because of that this test was failing when running on architectures where integer range was too small to handle this value. Signed-off-by: Slawek Kaplonski Reviewed-by: IWASE Yusuke Signed-off-by: FUJITA Tomonori Backport from https://github.com/faucetsdn/ryu/commit/d7d526ad Story: #2009283 Task: #43613 Change-Id: I5770ee66f7863c50847c3560b70f0d4360605561 --- os_ken/lib/ip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/os_ken/lib/ip.py b/os_ken/lib/ip.py index 62144b14..e2176c6f 100644 --- a/os_ken/lib/ip.py +++ b/os_ken/lib/ip.py @@ -84,7 +84,7 @@ def ipv4_to_str(ip): :param ip: binary or int type representation of IPv4 address :return: IPv4 address string """ - if isinstance(ip, int): + if isinstance(ip, numbers.Integral): return addrconv.ipv4.bin_to_text(struct.pack("!I", ip)) else: return addrconv.ipv4.bin_to_text(ip)