Closed ghost closed 7 years ago
Okay the problem is solved, it was very easy but I didn't recognized it:
A second instance of my program is created to execute "setup_switch" in the namespace. This program instance loads the bpf programs and attatches the hello program to tc. Then the program instance stops, and thus the unattatched ciao program is deleted. If I add a sleep to avoid that the second instance stops everything works as expected.
You can find my python script below. I am working with a virtual machine running Ubuntu 16.04 and Kernel 4.4.
My program creates a network namespace "sw1" and interfaces that connect the new namespace to the default namespace. A simple hello world ebpf program is attatched to the ingress path of the new namespace. It prints "Hello, World!", executes a tail-call to a second ebpf program and finally prints "Tail-call not executed!". The second print should not be visible if the tail-call was successful. The result is:
If I modify the program to work without namespaces the tail-call works correctly and the output is:
Thus, it seems to be a problem with my namespace, but I have no idea where the problem is. Unfortunately its impossible to lookup the prog_array, but if I write the fd of the second program into a hash map and look this up in the .c code the fd is displayed correctly. Hence, I assume the correct fd is inside the prog_array, so why it is not called?