switch to classic bpf macros
Note: this switches
com_android_networkstack_tethering_util_setupIcmpFilter
over to relative cbpf which in turn is called from:
com_android_networkstack_tethering_util_setupNaSocket
com_android_networkstack_tethering_util_setupNsSocket
and tested by p/m/C's:
TetheringUtilsTest.java - testIcmpSocketFilters()
Test: TreeHugger, atest TetheringUtilsTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I22a5ea8f8e3b879a37fe4acd84f61020661eaa71
diff --git a/framework/Android.bp b/framework/Android.bp
index 2d729c5..8476a5d 100644
--- a/framework/Android.bp
+++ b/framework/Android.bp
@@ -183,6 +183,7 @@
"libnativehelper",
],
header_libs: [
+ "bpf_headers",
"dnsproxyd_protocol_headers",
],
stl: "none",
diff --git a/framework/jni/android_net_NetworkUtils.cpp b/framework/jni/android_net_NetworkUtils.cpp
index 38e0059..ca297e5 100644
--- a/framework/jni/android_net_NetworkUtils.cpp
+++ b/framework/jni/android_net_NetworkUtils.cpp
@@ -23,6 +23,7 @@
#include <netinet/in.h>
#include <string.h>
+#include <bpf/BpfClassic.h>
#include <DnsProxydProtocol.h> // NETID_USE_LOCAL_NAMESERVERS
#include <nativehelper/JNIPlatformHelp.h>
#include <utils/Log.h>
@@ -55,11 +56,10 @@
static void android_net_utils_attachDropAllBPFFilter(JNIEnv *env, jclass clazz, jobject javaFd)
{
- struct sock_filter filter_code[] = {
- // Reject all.
- BPF_STMT(BPF_RET | BPF_K, 0)
+ static struct sock_filter filter_code[] = {
+ BPF_REJECT,
};
- struct sock_fprog filter = {
+ static const struct sock_fprog filter = {
sizeof(filter_code) / sizeof(filter_code[0]),
filter_code,
};