* How to avoid compilation errors like "error: no member named xxx in strut xxx"?
@ 2021-06-16 4:06 Shuyi Cheng
2021-06-16 6:02 ` Andrii Nakryiko
0 siblings, 1 reply; 3+ messages in thread
From: Shuyi Cheng @ 2021-06-16 4:06 UTC (permalink / raw)
To: bpf; +Cc: kafai, andrii, songliubraving, yhs
I am trying to write a bpf program that supports multiple linux kernel
versions. However, there are some differences in the definition of
struct net in these multiple kernel versions.
Therefore, when we include a certain kernel version of vmlinux.h, the
compilation error "error: no member named'proc_inum' in strut net" will
appear.
However, when we include another kernel version of vmlinux.h, the
compilation will appear "error: no member named'ns.inum' in strut net".
Anakryiko mentioned in the issue of libbpf/libbpf-bootstrap: vmlinux.h
is just a convenient way to have most of kernel types defined for you,
so that you don't have to re-define them manually. Link here: https:
//github.com/libbpf/libbpf-bootstrap/issues/31#issuecomment-861035643
But struct net is a very huge structure, and it may be very difficult to
add it manually. So, how can we avoid compilation errors like "error: no
member named'xxx' in xxx"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to avoid compilation errors like "error: no member named xxx in strut xxx"?
2021-06-16 4:06 How to avoid compilation errors like "error: no member named xxx in strut xxx"? Shuyi Cheng
@ 2021-06-16 6:02 ` Andrii Nakryiko
2021-06-16 6:57 ` Shuyi Cheng
0 siblings, 1 reply; 3+ messages in thread
From: Andrii Nakryiko @ 2021-06-16 6:02 UTC (permalink / raw)
To: Shuyi Cheng; +Cc: bpf, Martin Lau, Andrii Nakryiko, Song Liu, Yonghong Song
On Tue, Jun 15, 2021 at 9:06 PM Shuyi Cheng
<chengshuyi@linux.alibaba.com> wrote:
>
> I am trying to write a bpf program that supports multiple linux kernel
> versions. However, there are some differences in the definition of
> struct net in these multiple kernel versions.
>
> Therefore, when we include a certain kernel version of vmlinux.h, the
> compilation error "error: no member named'proc_inum' in strut net" will
> appear.
>
> However, when we include another kernel version of vmlinux.h, the
> compilation will appear "error: no member named'ns.inum' in strut net".
>
> Anakryiko mentioned in the issue of libbpf/libbpf-bootstrap: vmlinux.h
> is just a convenient way to have most of kernel types defined for you,
> so that you don't have to re-define them manually. Link here: https:
> //github.com/libbpf/libbpf-bootstrap/issues/31#issuecomment-861035643
>
> But struct net is a very huge structure, and it may be very difficult to
You don't need to declare the entire struct, it's enough to declare
only fields that you need and use.
If the type has incompatible changes between kernel versions (e.g., if
some field changed it's type), you can use my_type___suffix approach,
see [0] and struct kernfs_iattrs___old example. Let me know if you
need more concrete example (but then also provide more concrete
explanation of what you actually need).
[0] https://nakryiko.com/posts/bcc-to-libbpf-howto-guide/#dealing-with-compile-time-if-s-in-bcc
> add it manually. So, how can we avoid compilation errors like "error: no
> member named'xxx' in xxx"
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to avoid compilation errors like "error: no member named xxx in strut xxx"?
2021-06-16 6:02 ` Andrii Nakryiko
@ 2021-06-16 6:57 ` Shuyi Cheng
0 siblings, 0 replies; 3+ messages in thread
From: Shuyi Cheng @ 2021-06-16 6:57 UTC (permalink / raw)
To: Andrii Nakryiko; +Cc: bpf, Martin Lau, Andrii Nakryiko, Song Liu, Yonghong Song
On 6/16/21 2:02 PM, Andrii Nakryiko wrote:
> On Tue, Jun 15, 2021 at 9:06 PM Shuyi Cheng
> <chengshuyi@linux.alibaba.com> wrote:
>>
>> I am trying to write a bpf program that supports multiple linux kernel
>> versions. However, there are some differences in the definition of
>> struct net in these multiple kernel versions.
>>
>> Therefore, when we include a certain kernel version of vmlinux.h, the
>> compilation error "error: no member named'proc_inum' in strut net" will
>> appear.
>>
>> However, when we include another kernel version of vmlinux.h, the
>> compilation will appear "error: no member named'ns.inum' in strut net".
>>
>> Anakryiko mentioned in the issue of libbpf/libbpf-bootstrap: vmlinux.h
>> is just a convenient way to have most of kernel types defined for you,
>> so that you don't have to re-define them manually. Link here: https:
>> //github.com/libbpf/libbpf-bootstrap/issues/31#issuecomment-861035643
>>
>> But struct net is a very huge structure, and it may be very difficult to
>
> You don't need to declare the entire struct, it's enough to declare
> only fields that you need and use.
>
> If the type has incompatible changes between kernel versions (e.g., if
> some field changed it's type), you can use my_type___suffix approach,
> see [0] and struct kernfs_iattrs___old example. Let me know if you
> need more concrete example (but then also provide more concrete
> explanation of what you actually need).
>
> [0] https://nakryiko.com/posts/bcc-to-libbpf-howto-guide/#dealing-with-compile-time-if-s-in-bcc
>
>> add it manually. So, how can we avoid compilation errors like "error: no
>> member named'xxx' in xxx"
Thank you very much, i get it.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-06-16 6:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-16 4:06 How to avoid compilation errors like "error: no member named xxx in strut xxx"? Shuyi Cheng
2021-06-16 6:02 ` Andrii Nakryiko
2021-06-16 6:57 ` Shuyi Cheng
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.