netbpfload: enable mainline on API V/35+
netbpfload.mainline.rc is derived from: initrc-doc/bpfloader-sdk34-14-U.rc, except that it is 'override' instead of 'updatable' and uses the apex netbpfload instead of the platform bpfloader. Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I1ecf14e3d927ece136a0669a9b209be7112e55b5
This commit is contained in:
parent
1c6a7a71dc
commit
041be52b08
4 changed files with 54 additions and 3 deletions
|
|
@ -117,8 +117,9 @@ apex {
|
|||
"ServiceConnectivityResources",
|
||||
],
|
||||
prebuilts: [
|
||||
"ot-daemon.init.34rc",
|
||||
"current_sdkinfo",
|
||||
"netbpfload.mainline.rc",
|
||||
"ot-daemon.init.34rc",
|
||||
],
|
||||
manifest: "manifest.json",
|
||||
key: "com.android.tethering.key",
|
||||
|
|
|
|||
|
|
@ -49,3 +49,16 @@ cc_binary {
|
|||
init_rc: ["netbpfload.rc"],
|
||||
required: ["bpfloader"],
|
||||
}
|
||||
|
||||
// Versioned netbpfload init rc: init system will process it only on api V/35+ devices
|
||||
// (TODO: consider reducing to T/33+ - adjust the comment up above in line 43 as well)
|
||||
// Note: S[31] Sv2[32] T[33] U[34] V[35])
|
||||
//
|
||||
// For details of versioned rc files see:
|
||||
// https://android.googlesource.com/platform/system/core/+/HEAD/init/README.md#versioned-rc-files-within-apexs
|
||||
prebuilt_etc {
|
||||
name: "netbpfload.mainline.rc",
|
||||
src: "netbpfload.mainline.rc",
|
||||
filename: "netbpfload.35rc",
|
||||
installable: false,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -173,11 +173,40 @@ int main(int argc, char** argv, char * const envp[]) {
|
|||
(void)argc;
|
||||
android::base::InitLogging(argv, &android::base::KernelLogger);
|
||||
|
||||
const int device_api_level = android_get_device_api_level();
|
||||
const bool isAtLeastU = (device_api_level >= __ANDROID_API_U__);
|
||||
ALOGI("NetBpfLoad '%s' starting...", argv[0]);
|
||||
|
||||
if (!android::bpf::isAtLeastKernelVersion(4, 19, 0)) {
|
||||
ALOGE("Android U QPR2 requires kernel 4.19.");
|
||||
// true iff we are running from the module
|
||||
const bool is_mainline = !strcmp(argv[0], "/apex/com.android.tethering/bin/netbpfload");
|
||||
|
||||
// true iff we are running from the platform
|
||||
const bool is_platform = !strcmp(argv[0], "/system/bin/netbpfload");
|
||||
|
||||
const int device_api_level = android_get_device_api_level();
|
||||
const bool isAtLeastT = (device_api_level >= __ANDROID_API_T__);
|
||||
const bool isAtLeastU = (device_api_level >= __ANDROID_API_U__);
|
||||
const bool isAtLeastV = (device_api_level >= __ANDROID_API_V__);
|
||||
|
||||
ALOGI("NetBpfLoad api:%d/%d kver:%07x platform:%d mainline:%d",
|
||||
android_get_application_target_sdk_version(), device_api_level,
|
||||
android::bpf::kernelVersion(), is_platform, is_mainline);
|
||||
|
||||
if (!is_platform && !is_mainline) {
|
||||
ALOGE("Unable to determine if we're platform or mainline netbpfload.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (isAtLeastT && !android::bpf::isAtLeastKernelVersion(4, 9, 0)) {
|
||||
ALOGE("Android T requires kernel 4.9.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (isAtLeastU && !android::bpf::isAtLeastKernelVersion(4, 14, 0)) {
|
||||
ALOGE("Android U requires kernel 4.14.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (isAtLeastV && !android::bpf::isAtLeastKernelVersion(4, 19, 0)) {
|
||||
ALOGE("Android V requires kernel 4.19.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
8
netbpfload/netbpfload.mainline.rc
Normal file
8
netbpfload/netbpfload.mainline.rc
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
service bpfloader /apex/com.android.tethering/bin/netbpfload
|
||||
capabilities CHOWN SYS_ADMIN NET_ADMIN
|
||||
group root graphics network_stack net_admin net_bw_acct net_bw_stats net_raw system
|
||||
user root
|
||||
rlimit memlock 1073741824 1073741824
|
||||
oneshot
|
||||
reboot_on_failure reboot,bpfloader-failed
|
||||
override
|
||||
Loading…
Reference in a new issue