-
Notifications
You must be signed in to change notification settings - Fork 854
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
Add support for B.A.T.M.A.N. Advanced #980
base: master
Are you sure you want to change the base?
Conversation
One remark: pcap/batadv_packet.h and pcap/batadv_legacy_packet.h are basically copies from the Linux kernel and are therefore GPLv2 licensed. Let me know if that's okay for you or if I should ask the other maintainers and contributors for a BSD-3-Clause (compatible) dual-license for these two header files. |
Thank you for preparing this feature. Neither macOS nor FreeBSD like the new Linux-specific headers. As you mentioned, these are GPL, also the amount of filter-specific code seems to be much smaller than the amount of declarations. So it might be worth to consider if the new code could have just the declarations it needs, then it would be simpler to make these portable and have the same licence as the rest of libpcap. Other opinions are welcome. |
My opinion can be summarized as "+1". :-) I.e., no GPLed code, please. |
pcap/batadv_packet.h
Outdated
#ifndef _UAPI_LINUX_BATADV_PACKET_H_ | ||
#define _UAPI_LINUX_BATADV_PACKET_H_ | ||
|
||
#include <asm/byteorder.h> |
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.
None of those three headers are available on all the operating systems on which libpcap operates. (Note that one of those operating systems is Windows.)
Find a way not to use them.
pcap/batadv_packet.h
Outdated
@@ -0,0 +1,631 @@ | |||
/* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) */ |
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.
No GPLed code, please.
Here's a tarball containing a patch, pcap/batadv_legacy_packet.h, and pcap/batadv_packet.h. The patch is a variant of your change that compiles on macOS Catalina and Xcode 11.7, so it rips out enough Linuxisms to get it to compile there, at least. It also gets rid of all #pragma pack stuff (not all compilers necessarily support it), instead declaring 2-byte and 4-byte integral values as arrays of Do those headers need to be part of the libpcap distribution, rather than being internal to the libpcap source? |
a26e995
to
cf95dad
Compare
Thanks for the great feedback! Changelog v2:
|
cf95dad
to
53f2460
Compare
Changelog v3:
|
Passed FreeBSD build this time, that's better. One other thing that would complement this feature is some tcpdump test(s) to flex the new keywords. Do you have enough batman packets with the right protocol fields? |
ed25b1c
to
5a89e57
Compare
Changelog v4:
|
@infrastation sure, generating some test packets is no issue, can do that next weekend. According tests need to be added to the tcpdump repository in a separate commit over there, right? |
Yes, that's correct, and the tests will not pass until this feature has been merged, but eventually it would be consistent. |
Some simple tests for tcpdump for the batman-adv version 15 packet types and their decoding offsets can be found here: the-tcpdump-group/tcpdump#891 |
Thank you. For what it's worth, I have just looked through the proposed changes one more time and could not find any immediate issues to fix (which does not automatically mean everything is good, but still). Other reviewers are welcome. |
I'm a bit hesitant to ask, as I can see with all the frequent commits that everyone is very eagerly working on libpcap/tcpdump. But any chance to get this merged? Would help me adding it to the collaborative projects I would want to use this in. Which are usually reluctant in adding changes that are not upstream yet. |
Hi, @fenner , you've been down the pcap compiler space more than I, do you have any final comments before I merge this? |
type = pcap_nametobatadvtype_v15($2); | ||
break; | ||
default: | ||
YYABORT; |
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.
This should probably call bpf_set_error()
to report that $1 is an unsupported batman-adv version.
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.
Thanks! I've added an according error message with bpf_set_error().
5a89e57
to
3dcde32
Compare
a576d46
to
555ee39
Compare
Rebased. "All checks have failed" => There are some errors fo fix. |
555ee39
to
e3698e7
Compare
This adds support for the layer 2 mesh routing protocol B.A.T.M.A.N. Advanced. "batadv" can be used to filter on batman-adv packets. It also allows later filters to look at frames inside the tunnel when both "version" and "type" are specified. Documentation for the batman-adv protocol can be found at the following locations: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/batman-adv.rst https://www.open-mesh.org/ -- This is a backport of the following upstream pull request: the-tcpdump-group/libpcap#980 -> "Add support for B.A.T.M.A.N. Advanced coolsnowwolf#980" Signed-off-by: Linus Lüssing <[email protected]>
A huge rewrite in libpcap was introduced by dc14a7babca1 ("rpcap: have the server tell the client its byte order.") [0]. The patch "201-space_optimization.patch" does not apply at all anymore. So remove it. Refresh: - 100-no-openssl.patch - 102-skip-manpages.patch Update the "300-Add-support-for-B.A.T.M.A.N.-Advanced.patch" with latest PR [1]. old ipkg size: 90964 bin/packages/mips_24kc/base/libpcap1_1.10.1-5_mips_24kc.ipk new ipkg size: 93340 bin/packages/mips_24kc/base/libpcap1_1.10.2-1_mips_24kc.ipk [0] - the-tcpdump-group/libpcap@dc14a7b [1] - the-tcpdump-group/libpcap#980 Signed-off-by: Nick Hainke <[email protected]>
This adds support for the layer 2 mesh routing protocol B.A.T.M.A.N. Advanced. "batadv" can be used to filter on batman-adv packets. It also allows later filters to look at frames inside the tunnel when both "version" and "type" are specified. Documentation for the batman-adv protocol can be found at the following locations: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/batman-adv.rst https://www.open-mesh.org/ -- This is a backport of the following upstream pull request: the-tcpdump-group/libpcap#980 -> "Add support for B.A.T.M.A.N. Advanced coolsnowwolf#980" Signed-off-by: Linus Lüssing <[email protected]>
A huge rewrite in libpcap was introduced by dc14a7babca1 ("rpcap: have the server tell the client its byte order.") [0]. The patch "201-space_optimization.patch" does not apply at all anymore. So remove it. Refresh: - 100-no-openssl.patch - 102-skip-manpages.patch Update the "300-Add-support-for-B.A.T.M.A.N.-Advanced.patch" with latest PR [1]. old ipkg size: 90964 bin/packages/mips_24kc/base/libpcap1_1.10.1-5_mips_24kc.ipk new ipkg size: 93340 bin/packages/mips_24kc/base/libpcap1_1.10.2-1_mips_24kc.ipk [0] - the-tcpdump-group/libpcap@dc14a7b [1] - the-tcpdump-group/libpcap#980 Signed-off-by: Nick Hainke <[email protected]>
This adds support for the layer 2 mesh routing protocol B.A.T.M.A.N. Advanced. "batadv" can be used to filter on batman-adv packets. It also allows later filters to look at frames inside the tunnel when both "version" and "type" are specified. Documentation for the batman-adv protocol can be found at the following locations: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/batman-adv.rst https://www.open-mesh.org/ -- This is a backport of the following upstream pull request: the-tcpdump-group/libpcap#980 -> "Add support for B.A.T.M.A.N. Advanced coolsnowwolf#980" Signed-off-by: Linus Lüssing <[email protected]>
A huge rewrite in libpcap was introduced by dc14a7babca1 ("rpcap: have the server tell the client its byte order.") [0]. The patch "201-space_optimization.patch" does not apply at all anymore. So remove it. Refresh: - 100-no-openssl.patch - 102-skip-manpages.patch Update the "300-Add-support-for-B.A.T.M.A.N.-Advanced.patch" with latest PR [1]. old ipkg size: 90964 bin/packages/mips_24kc/base/libpcap1_1.10.1-5_mips_24kc.ipk new ipkg size: 93340 bin/packages/mips_24kc/base/libpcap1_1.10.2-1_mips_24kc.ipk [0] - the-tcpdump-group/libpcap@dc14a7b [1] - the-tcpdump-group/libpcap#980 Signed-off-by: Nick Hainke <[email protected]>
This adds support for the layer 2 mesh routing protocol B.A.T.M.A.N. Advanced. "batadv" can be used to filter on batman-adv packets. It also allows later filters to look at frames inside the tunnel when both "version" and "type" are specified. Documentation for the batman-adv protocol can be found at the following locations: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/batman-adv.rst https://www.open-mesh.org/ -- This is a backport of the following upstream pull request: the-tcpdump-group/libpcap#980 -> "Add support for B.A.T.M.A.N. Advanced coolsnowwolf#980" Signed-off-by: Linus Lüssing <[email protected]>
A huge rewrite in libpcap was introduced by dc14a7babca1 ("rpcap: have the server tell the client its byte order.") [0]. The patch "201-space_optimization.patch" does not apply at all anymore. So remove it. Refresh: - 100-no-openssl.patch - 102-skip-manpages.patch Update the "300-Add-support-for-B.A.T.M.A.N.-Advanced.patch" with latest PR [1]. old ipkg size: 90964 bin/packages/mips_24kc/base/libpcap1_1.10.1-5_mips_24kc.ipk new ipkg size: 93340 bin/packages/mips_24kc/base/libpcap1_1.10.2-1_mips_24kc.ipk [0] - the-tcpdump-group/libpcap@dc14a7b [1] - the-tcpdump-group/libpcap#980 Signed-off-by: Nick Hainke <[email protected]>
@fxlb Have you gotten any feedback from @guyharris on this? |
3d8d268
to
2deb0a7
Compare
The current types/sub-types in libpcap filter syntax use "-" and not "_". Examples:
Thus for batman-adv packet types,
it should be better to replace "_" by "-". |
5f47568
to
512ae9f
Compare
512ae9f
to
f8cbaf1
Compare
Changelog v6:
|
Changelog v7:
|
I would also like to add the correct offset to the batadv_mcast_packet type, which has a variable payload offset. I would need to add the contents of the two bytes tvlv_len field to the offset: My tries so far were not successful with this, I might need some help/guidance for that. |
This adds support for the layer 2 mesh routing protocol B.A.T.M.A.N. Advanced. "batadv" can be used to filter on batman-adv packets. It also allows later filters to look at frames inside the tunnel when both "version" and "type" are specified. Documentation for the batman-adv protocol can be found at the following locations: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/batman-adv.rst https://www.open-mesh.org/ Signed-off-by: Linus Lüssing <[email protected]>
Changelog v8:
|
The batman-adv multicast packet type has a variable offset for its encapsulated payload frames. The offset depends not only on the batman-adv mcast packet header length but also the length of a potential, variable length TVLV between the batman-adv mcast packet header and the payload. This adds according BPF instructions to take the TVLV length into account for a batman-adv mcast packet and adjusts the payload offset accordingly. Signed-off-by: Linus Lüssing <[email protected]>
Changelog v9:
|
I would love to see this in tcpdump, too! @mcr @fenner @infrastation @guyharris any chance you could help getting it merged? It sounded like @mcr was ready to merge it in 2021 already, but it's been stalled since then. Some embedded distributions already took the code as patch in to support their users, but having actually it merged would be great ... |
This adds support for the layer 2 mesh routing protocol
B.A.T.M.A.N. Advanced. "batadv" can be used to filter on batman-adv
packets. It also allows later filters to look at frames inside the
tunnel when both "version" and "type" are specified.
Documentation for the batman-adv protocol can be found at the following
locations:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/batman-adv.rst
https://www.open-mesh.org/
Signed-off-by: Linus Lüssing <[email protected]>