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 <skaplons@redhat.com>
Reviewed-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>

Backport from https://github.com/faucetsdn/ryu/commit/d7d526ad

Story: #2009283
Task: #43613
Change-Id: I5770ee66f7863c50847c3560b70f0d4360605561
This commit is contained in:
Slawek Kaplonski 2021-10-13 15:51:43 +02:00
parent 2e8cf5bed2
commit 4f224538e1
1 changed files with 1 additions and 1 deletions

View File

@ -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)