Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OS, bcc and kernel versions #1

Closed
Rochet2 opened this issue Apr 14, 2022 · 5 comments
Closed

OS, bcc and kernel versions #1

Rochet2 opened this issue Apr 14, 2022 · 5 comments

Comments

@Rochet2
Copy link

Rochet2 commented Apr 14, 2022

Hello. I am trying to run the code, but I am having a bit of trouble with it as the kernel, bcc and other versions do not match.
I was trying originally to run the example on Ubuntu, but there were errors that I could not resolve.
It seems that Debian 11 works ok after patching py-virtnet see CN-TU/py-virtnet#4

Could you post the OS and kernel versions, and if possible, the bcc version that you tested with? Thanks.

@muxamilian
Copy link
Collaborator

muxamilian commented Apr 14, 2022

Hi, thank you for your merge request in py-virtnet! I'm afraid I can't tell you the exact versions I used (except for the ones listed in the readme) since I don't have the original experiment setup anymore. It was on Debian Buster though and I don't remember using any packages except for the official ones included in Debian Buster. If you tell me the exact errors you're getting it might be easier to debug what exactly is wrong.

@Rochet2
Copy link
Author

Rochet2 commented Apr 20, 2022

Debian Buster

I think that knowing that is enough.

With the py-virtnet changes it is possible to build and run the example on Debian 10 (buster) as well as Debian 11 (bullseye).
If running on debian 10, you need to update your linux kernel to match the Readme requirement. Debian 11 is easier as it has the required kernel version already, so I preferred to use that now. The Debian and kernel I tested with were 11.3.0 and 5.10.0-13-amd64.

The code requires sudo apt install iperf3 linux-headers-$(uname -r) to be installed in order to run.
These are the iperf3 program used by the script and the linux kernel headers required by ebpf which did not seem to exist by default on Debian images I got from Debian.org.

The program keeps reporting server err iperf3: interrupt - the server has terminated but it seems to me that this is expected as the code terminates launched programs with server_popen.terminate() for example.


Here is a bit more information on running the code, in case it is useful for others for troubleshooting.
On Debian 11 I get the following if I start and abruptly stop the script and then try to run the script again. It can be fixed simply by restarting the machine.

Traceback (most recent call last):
  File "test.py", line 186, in <module>
    client_output, ebpf_output, timestamp = run(context, "just_one_flow")
  File "test.py", line 77, in run
    switch = vnet.Switch("sw")
  File "/home/user/Documents/custom-py-virtnet/virtnet/__init__.py", line 20, in create
    return creator(*args, **kwargs, manager=self)
  File "/home/user/Documents/custom-py-virtnet/virtnet/switch.py", line 45, in __init__
    super().__init__(name, ipdb)
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 194, in __init__
    super().__init__(*args, **kwargs)
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 55, in __init__
    self.start()
  File "/home/user/Documents/custom-py-virtnet/virtnet/switch.py", line 75, in start
    self.__intf = self.ipdb.create(kind="bridge", ifname=self.name).up().commit()
  File "/usr/local/lib/python3.7/site-packages/pr2modules/ipdb/main.py", line 1188, in create
    return self.interfaces.add(kind, ifname, reuse, **kwarg)
  File "/usr/local/lib/python3.7/site-packages/pr2modules/ipdb/interfaces.py", line 1226, in add
    raise CreateException("interface %s exists" % ifname)
pr2modules.ipdb.exceptions.CreateException: interface sw exists

I also get the following errors, but simply trying to rerun a few times seemed to fix the issue.

  File "test.py", line 186, in <module>
    client_output, ebpf_output, timestamp = run(context, "just_one_flow")
  File "test.py", line 80, in run
    host = vnet.Host("host{}".format(i))
  File "/home/user/Documents/custom-py-virtnet/virtnet/__init__.py", line 20, in create
    return creator(*args, **kwargs, manager=self)
  File "/home/user/Documents/custom-py-virtnet/virtnet/host.py", line 150, in __init__
    super().__init__(name)
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 194, in __init__
    super().__init__(*args, **kwargs)
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 55, in __init__
    self.start()
  File "/home/user/Documents/custom-py-virtnet/virtnet/host.py", line 176, in start
    self.__ns = NetNS(self.name)
  File "/usr/local/lib/python3.7/site-packages/pr2modules/nslink/nslink.py", line 154, in __init__
    self.remote_trnsp_in, self.remote_trnsp_out, target=target
  File "/usr/local/lib/python3.7/site-packages/pr2modules/remote/transport.py", line 175, in Server
    ipr.sendto_gate(msg, cmd['argv'][2])
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/rtnl/iprsocket.py", line 67, in _gate_linux
    msg.encode()
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/rtnl/ifinfmsg/__init__.py", line 542, in encode
    return super(ifinfbase, self).encode()
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/__init__.py", line 1078, in encode
    offset, diff = self.ft_encode(offset)
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/__init__.py", line 1516, in ft_encode
    log.error(''.join(traceback.format_stack()))

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/__init__.py", line 1514, in ft_encode
    struct.pack_into(efmt, self.data, offset, value)
struct.error: required argument is not an integer

error pack: i None <class 'NoneType'>
Traceback (most recent call last):
  File "test.py", line 186, in <module>
    client_output, ebpf_output, timestamp = run(context, "just_one_flow")
  File "test.py", line 81, in run
    host.connect(vnet.VirtualLink, switch, "eth0")
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 211, in connect
    intf = intf(name, [self, remote], remotename, route=route)
  File "/home/user/Documents/custom-py-virtnet/virtnet/__init__.py", line 20, in create
    return creator(*args, **kwargs, manager=self)
  File "/home/user/Documents/custom-py-virtnet/virtnet/interface.py", line 95, in __init__
    super().__init__(*args, **kwargs)
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 177, in __init__
    super().__init__(name, list(obj.ipdb for obj in peers))
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 55, in __init__
    self.start()
  File "/home/user/Documents/custom-py-virtnet/virtnet/interface.py", line 147, in start
    self.ipdb[0], self, self.route)
  File "/home/user/Documents/custom-py-virtnet/virtnet/interface.py", line 61, in __init__
    super().__init__(name, interface, ipdb, route)
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 119, in __init__
    super().__init__(name, ipdb)
  File "/home/user/Documents/custom-py-virtnet/virtnet/container.py", line 55, in __init__
    self.start()
  File "/home/user/Documents/custom-py-virtnet/virtnet/interface.py", line 66, in start
    intf.up()
  File "/usr/local/lib/python3.7/site-packages/pr2modules/ipdb/transactional.py", line 207, in __exit__
    self.commit()
  File "/usr/local/lib/python3.7/site-packages/pr2modules/ipdb/interfaces.py", line 608, in commit
    self.nl.link('add', **request)
  File "/usr/local/lib/python3.7/site-packages/pr2modules/iproute/linux.py", line 1499, in link
    ret = self.nlm_request(msg, msg_type=command, msg_flags=msg_flags)
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/nlsocket.py", line 403, in nlm_request
    return tuple(self._genlm_request(*argv, **kwarg))
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/nlsocket.py", line 907, in nlm_request
    self.put(msg, msg_type, msg_flags, msg_seq=msg_seq)
  File "/usr/local/lib/python3.7/site-packages/pr2modules/netlink/nlsocket.py", line 646, in put
    self.sendto_gate(msg, addr)
  File "/usr/local/lib/python3.7/site-packages/pr2modules/remote/transport.py", line 253, in _gate
    raise ret['error']
struct.error: required argument is not an integer

I got the following error

ebpf err chdir(/lib/modules/4.19.0-20-amd64/build): No such file or directory
Unable to initialize BPF program

It is caused by missing kernel headers. One can install them with the following

sudo apt install linux-headers-$(uname -r)

I got the following on Debian 10, however, it just means that I had the older kernel that does not support loops.

bpf: Failed to load program: Invalid argument
back-edge from insn XX to YY

@Rochet2 Rochet2 closed this as completed Apr 20, 2022
@muxamilian
Copy link
Collaborator

Thank you for your effort of documenting which things were necessary for you to run it. I will amend the readme.

Regarding the problem of leftover network interfaces: It should be also possible to delete them using ip link del <device name>.

@noahwalugembe
Copy link

I Get this error even after installing (No module named 'pyroute2.netns.nslink) after sudo pip3 install pyroute2 Requirement already satisfied: pyroute2 in /usr/local/lib/python3.9/dist-packages (0.7.12)

sudo python3 test.py --run_scenario just_one_flow
Traceback (most recent call last):
File "/home/noah/aiebpf/test.py", line 15, in
import virtnet
File "/usr/local/lib/python3.9/dist-packages/virtnet/init.py", line 9, in
from . host import Host, PhysicalHost, Router
File "/usr/local/lib/python3.9/dist-packages/virtnet/host.py", line 16, in
from pyroute2.netns.nslink import NetNS
ModuleNotFoundError: No module named 'pyroute2.netns.nslink'

@noahwalugembe
Copy link

How do I install import virtnet

pip install virtnet
ERROR: Could not find a version that satisfies the requirement virtnet (from versions: none)
ERROR: No matching distribution found for virtnet
WARNING: You are using pip version 20.1.1; however, version 24.0 is available.
You should consider upgrading via the '/home/noah/.pyenv/versions/3.7.9/bin/python3.7 -m pip install --upgrade pip' command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants