8000 Fix packetcapture bpf filter issue (#6815) by hangyan · Pull Request #6821 · antrea-io/antrea · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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 2 commits into from
Nov 19, 2024

Conversation

hangyan
Copy link
Member
@hangyan hangyan commented Nov 19, 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 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.

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>
@hangyan hangyan requested review from tnqn and antoninbas November 19, 2024 09:40
Signed-off-by: Hang Yan <yhang@vmware.com>
Copy link
Member
@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@antoninbas
Copy link
Contributor

/test-all

@antoninbas antoninbas merged commit ec6f9c6 into antrea-io:main Nov 19, 2024
58 of 59 checks passed
@luolanzone
Copy link
Contributor

@antoninbas should we back port this to release 2.2?

@antoninbas
Copy link
Contributor

@luolanzone yes I think we should backport this

@antoninbas antoninbas added the action/backport Indicates a PR that requires backports. label Nov 21, 2024
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 hangyan deleted the fix-packetcapture-filter branch November 21, 2024 07:44
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
Labels
action/backport Indicates a PR that requires backports.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0