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

packetloss: ignore non ip packet #232

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions bpf/headers/inspector.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ static __always_inline int set_tuple(struct sk_buff *skb, struct tuple *tpl) {
l3_off = BPF_CORE_READ(skb, network_header);
l4_off = BPF_CORE_READ(skb, transport_header);

if (l3_off == 0){
return -1;
}

ip = (struct iphdr *)(skb_head + l3_off);
bpf_probe_read(&iphdr_first_byte, 1, ip);
ip_vsn = iphdr_first_byte >> 4;
Expand Down
5 changes: 4 additions & 1 deletion bpf/packetloss.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ int kfree_skb(struct kfree_skb_args *args) {
struct sk_buff *skb = (struct sk_buff *)args->skb;
struct insp_pl_event_t event = {0};

set_tuple(skb, &event.tuple);
if (set_tuple(skb, &event.tuple) < 0){
//invalid packet, skip
goto out;
}
event.location = (u64)args->location;

if (enable_packetloss_stack){
Expand Down
Binary file modified pkg/exporter/probe/tracepacketloss/bpf_bpfeb.o
Binary file not shown.
Binary file modified pkg/exporter/probe/tracepacketloss/bpf_bpfel.o
Binary file not shown.
Loading