Merge "netbpfload: is now *always* mainline" into main

This commit is contained in:
Treehugger Robot 2024-03-08 13:04:52 +00:00 committed by Gerrit Code Review
commit 09f372dc4a

View file

@ -171,8 +171,6 @@ int writeProcSysFile(const char *filename, const char *value) {
#define APEX_MOUNT_POINT "/apex/com.android.tethering"
const char * const platformBpfLoader = "/system/bin/bpfloader";
const char * const platformNetBpfLoad = "/system/bin/netbpfload";
const char * const apexNetBpfLoad = APEX_MOUNT_POINT "/bin/netbpfload";
int logTetheringApexVersion(void) {
char * found_blockdev = NULL;
@ -232,12 +230,6 @@ int main(int argc, char** argv, char * const envp[]) {
ALOGI("NetBpfLoad '%s' starting...", argv[0]);
// true iff we are running from the module
const bool is_mainline = !strcmp(argv[0], apexNetBpfLoad);
// true iff we are running from the platform
const bool is_platform = !strcmp(argv[0], platformNetBpfLoad);
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__);
@ -248,24 +240,11 @@ int main(int argc, char** argv, char * const envp[]) {
// first in U QPR2 beta~2
const bool has_platform_netbpfload_rc = exists("/system/etc/init/netbpfload.rc");
ALOGI("NetBpfLoad api:%d/%d kver:%07x platform:%d mainline:%d rc:%d%d",
ALOGI("NetBpfLoad api:%d/%d kver:%07x rc:%d%d",
android_get_application_target_sdk_version(), device_api_level,
android::bpf::kernelVersion(), is_platform, is_mainline,
android::bpf::kernelVersion(),
has_platform_bpfloader_rc, has_platform_netbpfload_rc);
if (!is_platform && !is_mainline) {
ALOGE("Unable to determine if we're platform or mainline netbpfload.");
return 1;
}
if (is_platform) {
ALOGI("Executing apex netbpfload...");
const char * args[] = { apexNetBpfLoad, NULL, };
execve(args[0], (char**)args, envp);
ALOGE("exec '%s' fail: %d[%s]", apexNetBpfLoad, errno, strerror(errno));
return 1;
}
if (!has_platform_bpfloader_rc && !has_platform_netbpfload_rc) {
ALOGE("Unable to find platform's bpfloader & netbpfload init scripts.");
return 1;
@ -278,7 +257,7 @@ int main(int argc, char** argv, char * const envp[]) {
logTetheringApexVersion();
if (is_mainline && has_platform_bpfloader_rc && !has_platform_netbpfload_rc) {
if (has_platform_bpfloader_rc && !has_platform_netbpfload_rc) {
// Tethering apex shipped initrc file causes us to reach here
// but we're not ready to correctly handle anything before U QPR2
// in which the 'bpfloader' vs 'netbpfload' split happened