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

[BUG] conflicting types for '____ovs_dp_upcall' #317

Open
qingwusunny opened this issue Nov 2, 2023 · 3 comments
Open

[BUG] conflicting types for '____ovs_dp_upcall' #317

qingwusunny opened this issue Nov 2, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@qingwusunny
Copy link

qingwusunny commented Nov 2, 2023

my probe code:

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

SEC("kprobe/ovs_dp_upcall")
int BPF_KPROBE(ovs_dp_upcall, struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key,
        const struct dp_upcall_info *upcall_info, uint32_t cutlen)
{
    bpf_printk("ovs_dp_upcall point\n");
    return 0;
};

SEC("kretprobe/ovs_dp_upcall")
int BPF_KPROBE(ovs_dp_upcall_exit, long ret)
{
    bpf_printk("ovs_dp_upcall ret point ret=%d\n", ret);
    return 0;
};
char LICENSE[] SEC("license") = "Dual BSD/GPL";

And I run docker run -it -v `pwd`/:/src/ ghcr.io/eunomia-bpf/ecc-`uname -m`:latest failed, error and warning , error is conflicting types for '____ovs_dp_upcall':

/src/kprobe_ovs_dp_upcall.bpf.c:6:86: warning: declaration of 'struct sw_flow_key' will not be visible outside of this function [-Wvisibility]
int BPF_KPROBE(ovs_dp_upcall, struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key,
                                                                                     ^
/src/kprobe_ovs_dp_upcall.bpf.c:7:22: warning: declaration of 'struct dp_upcall_info' will not be visible outside of this function [-Wvisibility]
        const struct dp_upcall_info *upcall_info, uint32_t cutlen)
                     ^
/src/kprobe_ovs_dp_upcall.bpf.c:6:38: warning: declaration of 'struct datapath' will not be visible outside of this function [-Wvisibility]
int BPF_KPROBE(ovs_dp_upcall, struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key,
                                     ^
/src/kprobe_ovs_dp_upcall.bpf.c:6:86: warning: declaration of 'struct sw_flow_key' will not be visible outside of this function [-Wvisibility]
int BPF_KPROBE(ovs_dp_upcall, struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key,
                                                                                     ^
/src/kprobe_ovs_dp_upcall.bpf.c:7:22: warning: declaration of 'struct dp_upcall_info' will not be visible outside of this function [-Wvisibility]
        const struct dp_upcall_info *upcall_info, uint32_t cutlen)
                     ^
/src/kprobe_ovs_dp_upcall.bpf.c:6:5: error: conflicting types for '____ovs_dp_upcall'
int BPF_KPROBE(ovs_dp_upcall, struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key,
    ^
/tmp/.tmpG6eqsI/include/bpf/bpf_tracing.h:579:48: note: expanded from macro 'BPF_KPROBE'
static __always_inline typeof(name(0))                                      \
                                                                            ^
<scratch space>:17:1: note: expanded from here
____ovs_dp_upcall
^
/src/kprobe_ovs_dp_upcall.bpf.c:6:5: note: previous declaration is here
/tmp/.tmpG6eqsI/include/bpf/bpf_tracing.h:570:48: note: expanded from macro 'BPF_KPROBE'
static __always_inline typeof(name(0))                                      \
                                                                            ^
<scratch space>:8:1: note: expanded from here
____ovs_dp_upcall
^
6 warnings and 1 error generated.
@qingwusunny qingwusunny added the bug Something isn't working label Nov 2, 2023
Copy link

github-actions bot commented Nov 2, 2023

Thanks for using eunomia-bpf! We appreciate your help and we’ll take care of this as soon as possible.

@qingwusunny
Copy link
Author

Can someone help me?

@Officeyutong
Copy link
Contributor

#include "vmlinux.h"
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>

SEC("kprobe/ovs_dp_upcall")
int BPF_KPROBE(ovs_dp_upcall, struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key,
const struct dp_upcall_info *upcall_info, uint32_t cutlen)
{
bpf_printk("ovs_dp_upcall point\n");
return 0;
};

SEC("kretprobe/ovs_dp_upcall")
int BPF_KPROBE(ovs_dp_upcall_exit, long ret)
{
bpf_printk("ovs_dp_upcall ret point ret=%d\n", ret);
return 0;
};
char LICENSE[] SEC("license") = "Dual BSD/GPL";

Seems that the rootcause is the undefinition of struct datapath, sw_flow_key, dp_upcall_info. The expansion of macro KPROBE will produce a function proto like static inline __attribute__((always_inline)) typeof(ovs_dp_upcall(0)) ____ovs_dp_upcall(struct pt_regs *ctx, struct datapath *dp, struct sk_buff *skb, const struct sw_flow_key *key, const struct dp_upcall_info *upcall_info, uint32_t cutlen); , and the function implementation in the same signature. But since the structures were not predefined, but first-introduced in the function prototype, they are not visible by outer things. So in this way, clang treats the struct datapath* (and other struct pointers) as different types in the function proto and function implementation, and leads to a definition mismatch error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants