-
Notifications
You must be signed in to change notification settings - Fork 412
Fix packetcapture bpf filter issue (#6815) #6821
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In PacketCapture, packets which don’t match the target BPF can be received after the socket is created and before the bpf filter is applied.This patch use a zero bpf filter(match no packet), then empty out any packets that arrived before the “zero-BPF” filter was applied.At this point the socket is definitely empty and it can’t fill up with junk because the zero-BPF is in place. Then we replace the zero-BPF with the real BPF we want. Signed-off-by: Hang Yan <yhang@vmware.com> Co-authored-by: Antonin Bas <antonin.bas@broadcom.com>
tnqn
approved these changes
Nov 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
antoninbas
approved these changes
Nov 19, 2024
/test-all |
@antoninbas should we back port this to release 2.2? |
@luolanzone yes I think we should backport this |
hangyan
added a commit
to hangyan/antrea
that referenced
this pull request
Nov 21, 2024
In PacketCapture, packets which don’t match the target BPF can be received after the socket is created and before the bpf filter is applied. This patch uses a zero bpf filter (matches no packet), then empties out any packets that arrived before the "zero-BPF" filter was applied. At this point the socket is definitely empty and it can’t fill up with junk because the zero-BPF is in place. Then we replace the zero-BPF with the real BPF we want. Signed-off-by: Hang Yan <yhang@vmware.com> Co-authored-by: Antonin Bas <antonin.bas@broadcom.com>
hangyan
added a commit
to hangyan/antrea
that referenced
this pull request
Feb 10, 2025
In PacketCapture, packets which don’t match the target BPF can be received after the socket is created and before the bpf filter is applied. This patch uses a zero bpf filter (matches no packet), then empties out any packets that arrived before the "zero-BPF" filter was applied. At this point the socket is definitely empty and it can’t fill up with junk because the zero-BPF is in place. Then we replace the zero-BPF with the real BPF we want. Signed-off-by: Hang Yan <yhang@vmware.com> Co-authored-by: Antonin Bas <antonin.bas@broadcom.com>
antoninbas
added a commit
that referenced
this pull request
Feb 10, 2025
…6815) (#6821)#6804: Fix PacketCapture pcapng file issue on macOS (#6804) (#6983) * Fix packetcapture bpf filter issue (#6815) (#6821) In PacketCapture, packets which don’t match the target BPF can be received after the socket is created and before the bpf filter is applied. This patch uses a zero bpf filter (matches no packet), then empties out any packets that arrived before the "zero-BPF" filter was applied. At this point the socket is definitely empty and it can’t fill up with junk because the zero-BPF is in place. Then we replace the zero-BPF with the real BPF we want. Signed-off-by: Hang Yan <yhang@vmware.com> Co-authored-by: Antonin Bas <antonin.bas@broadcom.com> * Fix PacketCapture pcapng file issue on macOS (#6804) By default, gopacket will write snap length=0 in the pcapng file header, means unlimited snaplen. tcpdump on macOS (libpcap version 1.10.1) cannot recognize this and will report error. This patch sets a default value (65535) for it. For #6795 Signed-off-by: Hang Yan <yhang@vmware.com> --------- Signed-off-by: Hang Yan <yhang@vmware.com> Co-authored-by: Antonin Bas <antonin.bas@broadcom.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In PacketCapture, packets which don’t match the target BPF can be received after the socket is created and before the bpf filter is applied.This patch use a zero bpf filter(match no packet), then empty out any packets that arrived before the “zero-BPF” filter was applied.At this point the socket is definitely empty and it can’t fill up with junk because the zero-BPF is in place. Then we replace the zero-BPF with the real BPF we want.