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

variable has incomplete type Error #190

Closed
zaafar opened this issue Sep 8, 2015 · 7 comments
Closed

variable has incomplete type Error #190

zaafar opened this issue Sep 8, 2015 · 7 comments

Comments

@zaafar
Copy link
Contributor

zaafar commented Sep 8, 2015

I am using Ubuntu 14.04 with kernel 4.2.0-999-generic (Build Date 03/Sep/2015) as a VM on the virtual box and when I try to execute the distributed-bridge code using the root account I receive following error. Weird part about this error is that if I reboot the machine and execute the distributed-bridge code it will work fine in the first attempt only however, on all substituent executions it will give following error.

/usr/share/bcc/examples/distributed_bridge/tunnel.c:31:25: error: variable has incomplete type 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:31:10: note: forward declaration of 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:32:3: warning: implicit declaration of function 'bpf_skb_get_tunnel_key' is invalid in C99 [-Wimplicit-function-declaration]
bpf_skb_get_tunnel_key(skb, &tkey, sizeof(tkey), 0);
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:61:25: error: variable has incomplete type 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:61:10: note: forward declaration of 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:66:5: warning: implicit declaration of function 'bpf_skb_set_tunnel_key' is invalid in C99 [-Wimplicit-function-declaration]
bpf_skb_set_tunnel_key(skb, &tkey, sizeof(tkey), 0);
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:69:27: error: variable has incomplete type 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:61:10: note: forward declaration of 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
2 warnings and 3 errors generated.
Traceback (most recent call last):
File "tunnel.py", line 18, in
b = BPF(src_file="tunnel.c")
File "/usr/lib/python3/dist-packages/bcc/init.py", line 298, in init
raise Exception("Failed to compile BPF module %s" % src_file)
Exception: Failed to compile BPF module tunnel.c
Validating connectivity

Also, where is the "struct bpf_tunnel_key" defined?

Zaafar

@yonghong-song
Copy link
Collaborator

Zaafar,

Could you show the exact steps you reach the problem? Where did you get the
kernel 4.2.0-999-generic (Build Date 03/Sep/2015)?
Multiple different ways exist for installation of bcc. More details will
enable us to reproduce/resolve the issue.

Thanks,

Yonghong

On Tue, Sep 8, 2015 at 1:34 AM, zaafar notifications@github.com wrote:

I am using Ubuntu 14.04 with kernel 4.2.0-999-generic (Build Date
03/Sep/2015) and when I try to execute the distributed-bridge code using
the root account I receive following error. Weird part about this error is
that if I reboot the machine and execute the distributed-bridge code it
will work fine in the first attempt only however, on all substituent
executions it will give following error.

/usr/share/bcc/examples/distributed_bridge/tunnel.c:31:25: error: variable
has incomplete type 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:31:10: note: forward
declaration of 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:32:3: warning:
implicit declaration of function 'bpf_skb_get_tunnel_key' is invalid in C99
[-Wimplicit-function-declaration]
bpf_skb_get_tunnel_key(skb, &tkey, sizeof(tkey), 0);
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:61:25: error: variable
has incomplete type 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:61:10: note: forward
declaration of 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:66:5: warning:
implicit declaration of function 'bpf_skb_set_tunnel_key' is invalid in C99
[-Wimplicit-function-declaration]
bpf_skb_set_tunnel_key(skb, &tkey, sizeof(tkey), 0);
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:69:27: error: variable
has incomplete type 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
/usr/share/bcc/examples/distributed_bridge/tunnel.c:61:10: note: forward
declaration of 'struct bpf_tunnel_key'
struct bpf_tunnel_key tkey = {};
^
2 warnings and 3 errors generated.
Traceback (most recent call last):
File "tunnel.py", line 18, in
b = BPF(src_file="tunnel.c")
File "/usr/lib/python3/dist-packages/bcc/init.py", line 298, in init
raise Exception("Failed to compile BPF module %s" % src_file)
Exception: Failed to compile BPF module tunnel.c
Validating connectivity

Also, where is the "struct bpf_tunnel_key" defined?

Zaafar


Reply to this email directly or view it on GitHub
#190.

@zaafar
Copy link
Contributor Author

zaafar commented Sep 9, 2015

Yonghong,

I installed "ubuntu-14.04.3-desktop-amd64" on the virtualbox vm and updated it fully using apt-get. After that I updated the kernel to 4.2.0-999 using following script.

rm -rf *.deb
PREFIX=http://kernel.ubuntu.com/~kernel-ppa/mainline/daily/2015-09-08-unstable/
VER=4.2.0-999
REL=201509072200
wget ${PREFIX}/linux-headers-${VER}-generic_${VER}.${REL}_amd64.deb
wget ${PREFIX}/linux-headers-${VER}_${VER}.${REL}_all.deb
wget ${PREFIX}/linux-image-${VER}-generic_${VER}.${REL}_amd64.deb
sudo dpkg -i linux-*${VER}.${REL}*.deb

After installing the kernel, it gives me following output with <uname -a> command

Linux zaafar-VirtualBox 4.2.0-999-generic #201509072200 SMP Tue Sep 8 02:02:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

In order to install LLVM and bcc I followed the steps given in install.md (Ubuntu from source)

https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---from-source

After installing bcc I installed the required python modules in order to run the distributed-bridge code via following commands

sudo pip install pyroute2
sudo pip install future
sudo pip install netaddr

After that I run following command in order to execute the distributed-bridge code

sudo python main.py

Following is the error i am getting

LLVM ERROR: Program used external function 'bpf_skb_get_tunnel_key' which could not be resolved!

@yonghong-song
Copy link
Collaborator

Zaafar,

This is kernel version issue. In helpers.h
(/usr/share/bcc/include/bcc/helpers.h):

#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0)
static u64 (_bpf_get_cgroup_classid)(void *ctx) =
(void *) BPF_FUNC_get_cgroup_classid;
static u64 (_bpf_skb_vlan_push)(void _ctx, u16 proto, u16 vlan_tci) =
(void *) BPF_FUNC_skb_vlan_push;
static u64 (_bpf_skb_vlan_pop)(void _ctx) =
(void *) BPF_FUNC_skb_vlan_pop;
static int (_bpf_skb_get_tunnel_key)(void _ctx, void *to, u32 size, u64
flags) =
(void *) BPF_FUNC_skb_get_tunnel_key;
static int (_bpf_skb_set_tunnel_key)(void *ctx, void *from, u32 size, u64
flags) =
(void *) BPF_FUNC_skb_set_tunnel_key;
#endif

It is because of the kernel you downloaded do not support the above
functionality yet.
It will be available in 4.3.

If you want to experiment with the distributed bridge, you need to use the
latest net-next tree:
https://kernel.googlesource.com/pub/scm/linux/kernel/git/davem/net-next
(It still use version 4.2.0, you need manually change the above helpers.h
to check against 4.2.0,
but all the functionality is there.)

The change has also been pulled into latest Linus tree,
https://github.com/torvalds/linux

Let me know if you are not able to experiment.

On Wed, Sep 9, 2015 at 5:23 AM, zaafar notifications@github.com wrote:

Yonghong,

I installed "ubuntu-14.04.3-desktop-amd64" on the virtualbox vm and
updated it fully using apt-get. After that I updated the kernel to
4.2.0-999 using following script.

rm -rf .deb
PREFIX=http://kernel.ubuntu.com/~kernel-ppa/mainline/daily/2015-09-08-unstable/
VER=4.2.0-999
REL=201509072200 http://kernel.ubuntu.com/~kernel-ppa/mainline/daily/2015-09-08-unstable/VER=4.2.0-999REL=201509072200
wget ${PREFIX}/linux-headers-${VER}-generic
${VER}.${REL}amd64.deb
wget ${PREFIX}/linux-headers-${VER}
${VER}.${REL}all.deb
wget ${PREFIX}/linux-image-${VER}-generic
${VER}.${REL}amd64.deb
sudo dpkg -i linux-
${VER}.${REL}*.deb

After installing the kernel, it gives me following output with <uname -a>
command

Linux zaafar-VirtualBox 4.2.0-999-generic #201509072200 SMP Tue Sep 8
02:02:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

In order to install LLVM and bcc I followed the steps given in install.md
(Ubuntu from source)

https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---from-source

After installing bcc I installed the required python modules in order to
run the distributed-bridge code via following commands

sudo pip install pyroute2
sudo pip install future
sudo pip install netaddr

After that I run following command in order to execute the
distributed-bridge code

sudo python main.py

Following is the error i am getting

LLVM ERROR: Program used external function 'bpf_skb_get_tunnel_key' which
could not be resolved!


Reply to this email directly or view it on GitHub
#190 (comment).

@affansyed
Copy link
Contributor

Just to followup (and possibly I will try and update the bridge example with a README), with 4.2 kernel we cannot hope to run the distributed bridge example. (I also observed similar failure while running vlan learning example, and sure enough skb related bpf calls are present there as well).

In your comment above, when you say all the functionality is there, you mean to say we first download the kernel from latest net-next tree and then rebuild it first?

@yonghong-song
Copy link
Collaborator

Yes. build the kernel and install it like the below:
make defconfig
make -j4
sudo make modules_install install
reboot

The following is a link which is useful to install or remove a new kernel
either through packaging or through manual install.
http://community.linuxmint.com/tutorial/view/1718

On Wed, Sep 9, 2015 at 10:52 AM, affansyed notifications@github.com wrote:

Just to followup (and possibly I will try and update the bridge example
with a README), with 4.2 kernel we cannot hope to run the distributed
bridge example. (I also observed similar failure while running vlan
learning example, and sure enough skb related bpf calls are present there
as well).

In your comment above, when you say all the functionality is there, you
mean to say we first download the kernel from latest net-next tree and then
rebuild it first?


Reply to this email directly or view it on GitHub
#190 (comment).

@zaafar
Copy link
Contributor Author

zaafar commented Sep 9, 2015

Thank you Yonghong, This does solve my issue.

Regards,
Zaafar

@zaafar zaafar closed this as completed Sep 9, 2015
@affansyed
Copy link
Contributor

Just to further elaborate -- on investigating the following mainline kernel version supports both the bridge and vlan learning code.

PREFIX=http://kernel.ubuntu.com/~kernel-ppa/mainline/daily/2015-09-08-unstable/
VER=4.2.0-999
REL=201509072200

I am going to pull and put in a change request for the install.md to reflect this

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