Re: BCC and passing packet from XDP to user-mode app #bcc

Yonghong Song

On Thu, Mar 18, 2021 at 4:49 AM Federico Parola
<federico.parola@...> wrote:

the virtual function you are looking for is perf_submit_skb():

Strangely it is not documented in the reference guide.
Thanks, Federico and others. Maybe one of you can add it to the We
do have events.perf_submit there. Thanks!

Best regards,
Federico Parola

On 18/03/21 10:29, v.a.bonert@... wrote:
Is it possible to pass full ethernet packet from XDP to user-mode app
using BCC?
I wrote C code like this:
capture(struct xdp_md *ctx)
events.perf_submit(ctx, ...);
But there is no flags argument in perf_submit function (but
bpf_perf_event_output has such argument).
Without BCC I can write such code to pass full packet to user-mode:
struct packet_info
uint32_t packet_len;
uint32_t iface_id;
struct bpf_map_def SEC("maps") captured_data =
.key_size = sizeof(u32),
.value_size = sizeof(u32),
.max_entries = MAX_CPUS
int capture_kern(struct xdp_md *ctx)
u32 len = ctx->data_end - ctx->data;
u64 flags = BPF_F_CURRENT_CPU;
flags |= (u64)len << 32;
struct packet_info info = {len, ctx->ingress_ifindex};
bpf_perf_event_output(ctx, &captured_data, flags, &info, sizeof(info));
return XDP_PASS;
How can I do the same when using BCC?

Join to automatically receive all group messages.