Skip to content

Commit

Permalink
Correctly calculate data_end
Browse files Browse the repository at this point in the history
 *     ,---------------------------  + head
 *    /          ,-----------------  + data
 *   /          /      ,-----------  + tail
 *  |          |      |            , + end
 *  |          |      |           |
 *  v          v      v           v
 *   -----------------------------------------------
 *  | headroom | data |  tailroom | skb_shared_info |
 *   -----------------------------------------------

According to above illustration of skb, data_end should be skb->head +
skb->tail.

Signed-off-by: Zhichuan Liang <gray.liang@isovalent.com>
  • Loading branch information
jschwinger233 authored and brb committed Sep 25, 2023
1 parent b8dbecf commit 5d66305
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions bpf/kprobe_pwru.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,11 @@ filter_pcap_ebpf(void *_skb, void *__skb, void *___skb, void *data, void* data_e
}

static __always_inline bool
filter_pcap(struct sk_buff *skb) {
BPF_CORE_READ(skb, head);
filter_pcap(struct sk_buff *skb)
{
void *skb_head = BPF_CORE_READ(skb, head);
u16 l3_off = BPF_CORE_READ(skb, network_header);
void *data = skb_head + l3_off;
u16 l4_off = BPF_CORE_READ(skb, transport_header);
u16 len = BPF_CORE_READ(skb, len);
void *data_end = skb_head + l4_off + len;
void *data = skb_head + BPF_CORE_READ(skb, network_header);
void *data_end = skb_head + BPF_CORE_READ(skb, tail);
return filter_pcap_ebpf((void *)skb, (void *)skb, (void *)skb, data, data_end);
}

Expand Down

0 comments on commit 5d66305

Please sign in to comment.