For bionic, the provided test case needs some tweaks as the neutron version on bionic does not have the provided functions. Instead, I've written a quick test script that will exercise the pyroute2 code path to exercise the errors. Still requires enabling vfs as James did.
Simple script is:
#!/usr/bin/python3
import pyroute2
ip = pyroute2.IPRoute()
devname = 'enp3s0f0'
link_idx = ip.link_lookup(ifname=devname)[0]
link = ip.link('get', index=link_idx, ext_mask=1)[0]
Running test on bionic without this fix to prove its enough to show the error:
$ dpkg -l | grep python3-pyroute2
ii python3-pyroute2 0.4.21-0.1ubuntu2 all Python3 Netlink library
$ sudo ./lp1904730-test.py
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pyroute2/netlink/__init__.py", line 1232, in _ft_decode_generic
self.decode_nlas(offset)
File "/usr/lib/python3/dist-packages/pyroute2/netlink/__init__.py", line 1357, in decode_nlas
offset)
struct.error: unpack_from requires a buffer of at least 4 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./lp1904730-test.py", line 7, in <module>
link = ip.link('get', index=link_idx, ext_mask=1)[0]
File "/usr/lib/python3/dist-packages/pyroute2/iproute.py", line 1310, in link
msg_flags=msg_flags)
File "/usr/lib/python3/dist-packages/pyroute2/netlink/nlsocket.py", line 804, in nlm_request
return do_try()
File "/usr/lib/python3/dist-packages/pyroute2/netlink/nlsocket.py", line 783, in do_try
callback=callback)
File "/usr/lib/python3/dist-packages/pyroute2/netlink/nlsocket.py", line 648, in get
raise msg['header']['error']
File "/usr/lib/python3/dist-packages/pyroute2/netlink/nlsocket.py", line 171, in parse
msg.decode()
File "/usr/lib/python3/dist-packages/pyroute2/netlink/__init__.py", line 941, in decode
self._ft_decode(self, offset)
File "/usr/lib/python3/dist-packages/pyroute2/netlink/__init__.py", line 1235, in _ft_decode_generic
raise NetlinkNLADecodeError(e)
pyroute2.netlink.exceptions.NetlinkNLADecodeError: unpack_from requires a buffer of at least 4 bytes
Running with the proposed patch:
$ dpkg -l | grep python3-pyroute2
ii python3-pyroute2 0.4.21-0.1ubuntu2.1 all Python3 Netlink library
$ sudo ./lp1904730-test.py
63
For bionic, the provided test case needs some tweaks as the neutron version on bionic does not have the provided functions. Instead, I've written a quick test script that will exercise the pyroute2 code path to exercise the errors. Still requires enabling vfs as James did.
Simple script is:
#!/usr/bin/python3
import pyroute2
ip = pyroute2.IPRoute() lookup( ifname= devname) [0]
devname = 'enp3s0f0'
link_idx = ip.link_
link = ip.link('get', index=link_idx, ext_mask=1)[0]
num_vfs = link.get_ attr('IFLA_ NUM_VF' )
print(num_vfs)
Running test on bionic without this fix to prove its enough to show the error:
$ dpkg -l | grep python3-pyroute2
ii python3-pyroute2 0.4.21-0.1ubuntu2 all Python3 Netlink library
$ sudo ./lp1904730-test.py python3/ dist-packages/ pyroute2/ netlink/ __init_ _.py", line 1232, in _ft_decode_generic decode_ nlas(offset) python3/ dist-packages/ pyroute2/ netlink/ __init_ _.py", line 1357, in decode_nlas
Traceback (most recent call last):
File "/usr/lib/
self.
File "/usr/lib/
offset)
struct.error: unpack_from requires a buffer of at least 4 bytes
During handling of the above exception, another exception occurred:
Traceback (most recent call last): test.py" , line 7, in <module> python3/ dist-packages/ pyroute2/ iproute. py", line 1310, in link flags=msg_ flags) python3/ dist-packages/ pyroute2/ netlink/ nlsocket. py", line 804, in nlm_request python3/ dist-packages/ pyroute2/ netlink/ nlsocket. py", line 783, in do_try callback) python3/ dist-packages/ pyroute2/ netlink/ nlsocket. py", line 648, in get ]['error' ] python3/ dist-packages/ pyroute2/ netlink/ nlsocket. py", line 171, in parse python3/ dist-packages/ pyroute2/ netlink/ __init_ _.py", line 941, in decode _ft_decode( self, offset) python3/ dist-packages/ pyroute2/ netlink/ __init_ _.py", line 1235, in _ft_decode_generic eError( e) netlink. exceptions. NetlinkNLADecod eError: unpack_from requires a buffer of at least 4 bytes
File "./lp1904730-
link = ip.link('get', index=link_idx, ext_mask=1)[0]
File "/usr/lib/
msg_
File "/usr/lib/
return do_try()
File "/usr/lib/
callback=
File "/usr/lib/
raise msg['header'
File "/usr/lib/
msg.decode()
File "/usr/lib/
self.
File "/usr/lib/
raise NetlinkNLADecod
pyroute2.
Running with the proposed patch:
$ dpkg -l | grep python3-pyroute2
ii python3-pyroute2 0.4.21-0.1ubuntu2.1 all Python3 Netlink library
$ sudo ./lp1904730-test.py
63