Revert "24Q2: use mainline netbpfload from apex" am: e36d77c385

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/2986117

Change-Id: If153c0a21b7dd5f35ac35f6c24652b889d5008f5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/netbpfload/netbpfload.rc b/netbpfload/netbpfload.rc
index ffbc33c..14181dc 100644
--- a/netbpfload/netbpfload.rc
+++ b/netbpfload/netbpfload.rc
@@ -17,7 +17,7 @@
 on load_bpf_programs
     exec_start bpfloader
 
-service bpfloader /apex/com.android.tethering/bin/netbpfload
+service bpfloader /system/bin/netbpfload
     # netbpfload will do network bpf loading, then execute /system/bin/bpfloader
     capabilities CHOWN SYS_ADMIN NET_ADMIN
     # The following group memberships are a workaround for lack of DAC_OVERRIDE
diff --git a/service/src/com/android/server/BpfLoaderRcUtils.java b/service/src/com/android/server/BpfLoaderRcUtils.java
index 99754d5..293e757 100644
--- a/service/src/com/android/server/BpfLoaderRcUtils.java
+++ b/service/src/com/android/server/BpfLoaderRcUtils.java
@@ -72,17 +72,6 @@
             "updatable"
     );
 
-    private static final List<String> BPF_LOADER_RC_UQPR3 = List.of(
-            "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",
-            "updatable"
-    );
-
 
     private static final String BPF_LOADER_RC_FILE_PATH = "/etc/init/bpfloader.rc";
     private static final String NET_BPF_LOAD_RC_FILE_PATH = "/etc/init/netbpfload.rc";
@@ -143,31 +132,30 @@
                                 + " exist.");
                 return false;
             }
-            // Check bpf rc file in U QPR2 and U QPR3
-            return compareBpfLoaderRc(bpfRcFile, List.of(BPF_LOADER_RC_UQPR2, BPF_LOADER_RC_UQPR3));
+            // Check bpf rc file in U QPR2
+            return compareBpfLoaderRc(bpfRcFile, BPF_LOADER_RC_UQPR2);
         }
 
         if (SdkLevel.isAtLeastU()) {
             // Check bpf rc file in U
-            return compareBpfLoaderRc(bpfRcFile, List.of(BPF_LOADER_RC_U));
+            return compareBpfLoaderRc(bpfRcFile, BPF_LOADER_RC_U);
         }
         // Check bpf rc file in S/T
-        return compareBpfLoaderRc(bpfRcFile, List.of(BPF_LOADER_RC_S_T));
+        return compareBpfLoaderRc(bpfRcFile, BPF_LOADER_RC_S_T);
     }
 
     private static boolean compareBpfLoaderRc(@NonNull File bpfRcFile,
-            @NonNull List<List<String>> templates) {
-        List<String> actualContent;
+            @NonNull List<String> template) {
         try {
-            actualContent = loadExistingBpfRcFile(new FileInputStream(bpfRcFile));
+            List<String> actualContent = loadExistingBpfRcFile(new FileInputStream(bpfRcFile));
+            if (!actualContent.equals(template)) {
+                Log.wtf(TAG, "BPF rc file is not same as the template files " + actualContent);
+                return false;
+            }
         } catch (FileNotFoundException e) {
             Log.wtf(bpfRcFile.getPath() + " doesn't exist.", e);
             return false;
         }
-        for (List<String> template : templates) {
-            if (actualContent.equals(template)) return true;
-        }
-        Log.wtf(TAG, "BPF rc file is not same as the template files " + actualContent);
-        return false;
+        return true;
     }
 }