Skip to content

Commit be4c3ca

Browse files
authored
feat(context): Add --disable-reverse-match flag to control reverse match behavior (#297)
Closes #284
1 parent 070955a commit be4c3ca

19 files changed

+111
-78
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ If this flag isn't specified, it defaults to `tc`.
296296
--cri-runtime-address string Address of CRI container runtime service (default: uses in order the first successful one of [/var/run/dockershim.sock, /var/run/cri-dockerd.sock, /run/crio/crio.sock, /run/containerd/containerd.sock])
297297
--delay-before-handle-packet-events duration Delay some durations before handle packet events
298298
-Q, --direction string Choose send/receive direction for which packets should be captured. Possible values are 'in', 'out' and 'inout' (default "inout")
299+
--disable-reverse-match Disable reverse match for TCP and UDP packets.
299300
--docker-address string Address of Docker Engine service (default "/var/run/docker.sock")
300301
--embed-keylog-to-pcapng -- CMD [ARGS] Write TLS Key Log file to this path (experimental: only support unstripped Go binary and must combined with -- CMD [ARGS])
301302
--event-chan-size uint Size of event chan (default 20)

bpf/bpf.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ type Options struct {
5858
hookNetDev bool
5959
kernelTypes *btf.Spec
6060
backend types.NetHookBackend
61+
62+
disableReverseMatch bool
6163
}
6264

6365
func NewBPF() (*BPF, error) {
@@ -115,6 +117,9 @@ func (b *BPF) Load(opts Options) error {
115117
if b.useRingBufSubmitSkb {
116118
config.UseRingbufSubmitSkb = 1
117119
}
120+
if opts.disableReverseMatch {
121+
config.DisableReverseMatch = 1
122+
}
118123
if opts.backend != types.NetHookBackendCgroupSkb {
119124
b.disableCgroupSkb()
120125
}
@@ -683,6 +688,11 @@ func (opts *Options) WithMaxPayloadSize(n uint32) *Options {
683688
return opts
684689
}
685690

691+
func (opts *Options) WithDisableReverseMatch(v bool) *Options {
692+
opts.disableReverseMatch = v
693+
return opts
694+
}
695+
686696
func (opts *Options) WithHookMount(v bool) *Options {
687697
opts.hookMount = v
688698
return opts

bpf/bpf_arm64_bpfel.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bpf/bpf_arm64_bpfel.o

137 KB
Binary file not shown.

bpf/bpf_arm_bpfel.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bpf/bpf_arm_bpfel.o

3.63 KB
Binary file not shown.

bpf/bpf_legacy_arm64_bpfel.o

42.9 KB
Binary file not shown.

bpf/bpf_legacy_arm_bpfel.o

2.02 KB
Binary file not shown.

bpf/bpf_legacy_x86_bpfel.o

42.9 KB
Binary file not shown.

bpf/bpf_no_tracing_arm64_bpfel.o

70.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)