-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: Support pcap-filter expression for pcap mode #478
Conversation
9de6fbd
to
1987e97
Compare
./bin/ecapture tls -m pcap -i ens33 --pcapfile test.pcapng host 142.251.10.100 It seems that 看上去, |
f3efccc
to
96f3571
Compare
074a4d9
to
9a0a416
Compare
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.
PTAL
9a0a416
to
8687ce2
Compare
It runs normally on x86_64\aarch64 Linux. But you can skip Android for now. |
It's better to use pcap-filter expression to filter packets like tcpdump instead of `--port` like options. e.g. `./bin/ecapture tls -m pcap -i ens33 --pcapfile test.pcapng host 142.251.10.100` So, in this commit: 1. Add libpcap as a Git submodule. 2. `make` in Makefile will build and install libpcap. 3. Remove `target_port` in bpf code. 4. Add `filter_pcap_ebpf_l2()` as a stub to inject pcap-filter. 5. Use `ebpfmanager@v0.4.5` to inject pcap-filter into bpf program spec with `elibpcap` library. 6. Remove `--port` option. 7. Add remain command line args as pcap filter expression. Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
As previous commit adds libpcap submodule, we have to checkout repo with it. Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
When `make nocore`, there will be a compiling error: ```bash In file included from kern/boringssl_a_13_kern.c:72: In file included from ./kern/openssl.h:16: ./kern/tc.h:116:8: error: use of undeclared identifier '__noinline__' static __noinline bool filter_pcap_ebpf_l2(void *_skb, void *__skb, ^ ./kern/bpf/bpf_helpers.h:47:35: note: expanded from macro '__noinline' ^ /lib/modules/6.5.0-15-generic/build/include/linux/compiler_attributes.h:244:56: note: expanded from macro 'noinline' ^ 1 error generated. ``` This is because definition of `noinline` in `compiler_attributes.h` is incorrect for us, which makes `__noinline` expanding to clang-unrecognised `__attribute__((__attribute__((__noinline__))))`. So, we have to `undef noinline` for clang compiling for `make nocore`. Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
8687ce2
to
80094bc
Compare
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
Fix #474
It's better to use pcap-filter expression to filter packets like tcpdump instead of
--port
like options.e.g.
./bin/ecapture tls -m pcap -i ens33 --pcapfile test.pcapng host 142.251.10.100
So, in this PR:
make
in Makefile will build and install libpcap.target_port
in bpf code.filter_pcap_ebpf_l2()
as a stub to inject pcap-filter.ebpfmanager@v0.4.5
to inject pcap-filter into bpf program spec withelibpcap
library.--port
option.