Add tc police support to jni lib
Bug: 157552970
Test: TreeHugger
Change-Id: I63b4324bbb8d20b7d401921dad1f8e73ccc26a39
diff --git a/staticlibs/native/bpfmapjni/com_android_net_module_util_TcUtils.cpp b/staticlibs/native/bpfmapjni/com_android_net_module_util_TcUtils.cpp
index e5a3668..2307a6b 100644
--- a/staticlibs/native/bpfmapjni/com_android_net_module_util_TcUtils.cpp
+++ b/staticlibs/native/bpfmapjni/com_android_net_module_util_TcUtils.cpp
@@ -54,6 +54,24 @@
}
}
+// tc filter add dev .. ingress prio .. protocol .. matchall \
+// action police rate .. burst .. conform-exceed pipe/continue \
+// action bpf object-pinned .. \
+// drop
+static void com_android_net_module_util_TcUtils_tcFilterAddDevIngressPolice(
+ JNIEnv *env, jobject clazz, jint ifIndex, jshort prio, jshort proto,
+ jint rateInBytesPerSec, jstring bpfProgPath) {
+ ScopedUtfChars pathname(env, bpfProgPath);
+ int error = tcAddIngressPoliceFilter(ifIndex, prio, proto, rateInBytesPerSec,
+ pathname.c_str());
+ if (error) {
+ throwIOException(env,
+ "com_android_net_module_util_TcUtils_"
+ "tcFilterAddDevIngressPolice error: ",
+ error);
+ }
+}
+
// tc filter del dev .. in/egress prio .. protocol ..
static void com_android_net_module_util_TcUtils_tcFilterDelDev(
JNIEnv *env, jobject clazz, jint ifIndex, jboolean ingress, jshort prio,
@@ -75,6 +93,8 @@
(void *)com_android_net_module_util_TcUtils_isEthernet},
{"tcFilterAddDevBpf", "(IZSSLjava/lang/String;)V",
(void *)com_android_net_module_util_TcUtils_tcFilterAddDevBpf},
+ {"tcFilterAddDevIngressPolice", "(ISSILjava/lang/String;)V",
+ (void *)com_android_net_module_util_TcUtils_tcFilterAddDevIngressPolice},
{"tcFilterDelDev", "(IZSS)V",
(void *)com_android_net_module_util_TcUtils_tcFilterDelDev},
};