feat: Support pcap-filter expression for pcap mode#478
Merged
Conversation
9de6fbd to
1987e97
Compare
Member
./bin/ecapture tls -m pcap -i ens33 --pcapfile test.pcapng host 142.251.10.100It seems that 看上去, |
f3efccc to
96f3571
Compare
cfc4n
reviewed
Feb 19, 2024
074a4d9 to
9a0a416
Compare
9a0a416 to
8687ce2
Compare
cfc4n
reviewed
Feb 21, 2024
Member
|
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
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
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.
Fix #474
It's better to use pcap-filter expression to filter packets like tcpdump instead of
--portlike options.e.g.
./bin/ecapture tls -m pcap -i ens33 --pcapfile test.pcapng host 142.251.10.100So, in this PR:
makein Makefile will build and install libpcap.target_portin bpf code.filter_pcap_ebpf_l2()as a stub to inject pcap-filter.ebpfmanager@v0.4.5to inject pcap-filter into bpf program spec withelibpcaplibrary.--portoption.