Skip to content

Commit

Permalink
Preserve references to metadata when adjusting the program.
Browse files Browse the repository at this point in the history
This fixes the offset issue I mention in
the-tcpdump-group/tcpdump#480 (comment)
  • Loading branch information
fenner committed May 20, 2019
1 parent 9054397 commit d780526
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pcap-linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -7423,6 +7423,14 @@ fix_program(pcap_t *handle, struct sock_fprog *fcode, int is_mmapped)
static int
fix_offset(pcap_t *handle, struct bpf_insn *p)
{
/*
* Existing references to auxiliary data shouldn't be adjusted.
*
* Note that SKF_AD_OFF is negative, but p->k is unsigned, so
* we use >= and cast SKF_AD_OFF to unsigned.
*/
if (p->k >= (bpf_u_int32)SKF_AD_OFF)
return 0;
if (handle->linktype == DLT_LINUX_SLL2) {
/*
* What's the offset?
Expand Down

0 comments on commit d780526

Please sign in to comment.