-
Bug
-
Resolution: Unresolved
-
Medium
-
None
-
None
-
None
-
vpp version 20.09.
vpp-papi version 1.6.2
Hi,
Im having issues requesting the DHCP client details via the Python API using the dhcp_client_details call. It throws an error while parsing the router_address field:
VPP API connected Traceback (most recent call last): File "test.py", line 39, in <module> dumpret = vpp.api.dhcp_client_dump() File "usr/lib/python3.8/site-packages/vpp_papi/vpp_papi.py", line 91, in _call_ File "usr/lib/python3.8/site-packages/vpp_papi/vpp_papi.py", line 424, in f File "usr/lib/python3.8/site-packages/vpp_papi/vpp_papi.py", line 669, in _call_vpp File "usr/lib/python3.8/site-packages/vpp_papi/vpp_papi.py", line 751, in read_blocking File "usr/lib/python3.8/site-packages/vpp_papi/vpp_papi.py", line 572, in decode_incoming_msg File "usr/lib/python3.8/site-packages/vpp_papi/vpp_serializer.py", line 644, in unpack File "usr/lib/python3.8/site-packages/vpp_papi/vpp_serializer.py", line 644, in unpack File "usr/lib/python3.8/site-packages/vpp_papi/vpp_serializer.py", line 320, in unpack File "usr/lib/python3.8/site-packages/vpp_papi/vpp_serializer.py", line 644, in unpack File "usr/lib/python3.8/site-packages/vpp_papi/vpp_serializer.py", line 654, in unpack File "usr/lib/python3.8/site-packages/vpp_papi/vpp_serializer.py", line 66, in conversion_unpacker File "usr/lib/python3.8/site-packages/vpp_papi/vpp_format.py", line 214, in <lambda> File "usr/lib/python3.8/site-packages/vpp_papi/vpp_format.py", line 181, in unformat_api_address_t ValueError: Unknown address family vl_api_address_t(af=<vl_api_address_family_t.128|64: 192>, un=vl_api_address_union_t(ip4=b'\xa8\x00\x02\x00', ip6=b'\xa8\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
The JSON api says it should be a field vl_api_address_family_t, if fails to parse tho. When I change the API to vl_api_ip4_address_t, the field is parsed, but the returned value is invalid.
Im not fully aware of binary format of the field but I assume it only happens in specific cases. (perhaps first bit 1? )
I can reproduce the issue on a network, where a DHCP server ( IP 192.168.0.2) is allocating IP addresses.
vpp# set interface state GigabitEthernet0/6/0 up
vpp# set dhcp client intfc GigabitEthernet0/6/0
vpp# show dhcp client
[0] GigabitEthernet0/6/0 state DHCP_BOUND installed 1 addr 192.168.0.111/24 gw 192.168.0.2 server 192.168.0.2 dns 192.168.0.2
vpp#
# Test Script: import os import fnmatch import functools from vpp_papi import VPP import logging logger = logging.getLogger('vpp') logger.setLevel('DEBUG') # UPDATE PATH HERE TO point to definitions folder dirs=['/usr/share/vpp/api/core/', '/usr/share/vpp/api/plugins/'] jsonfiles = [] for dir in dirs: for root, dirnames, filenames in os.walk(dir): for filename in fnmatch.filter(filenames, '*.api.json'): jsonfiles.append(os.path.join(dir, filename)) vpp = VPP(jsonfiles, loglevel=10, read_timeout=5) #This can throw VPPIOError ret = vpp.connect('sample-client') if ret == 0: print('VPP API connected') dumpret = vpp.api.dhcp_client_dump() print(dumpret) else: print('Failed to connect to VPP') print(ret)
Tested on version:
vpp v20.09-release built by gitlab-runner on bn-builder-aws-1 at 2020-12-21T12:46:21