Neill Kapron | dd93f85 | 2024-08-07 22:39:57 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2024 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | //! BPF loader for system and vendor applications |
| 18 | |
Neill Kapron | 01249cb | 2024-08-22 19:09:18 +0000 | [diff] [blame] | 19 | #[cfg(enable_libbpf)] |
| 20 | fn load_libbpf_progs() { |
| 21 | // Libbpf loader functionality here. |
| 22 | } |
| 23 | |
| 24 | #[cfg(not(enable_libbpf))] |
| 25 | fn load_libbpf_progs() { |
| 26 | // Empty stub for feature flag disabled case |
| 27 | } |
| 28 | |
Neill Kapron | dd93f85 | 2024-08-07 22:39:57 +0000 | [diff] [blame] | 29 | fn main() { |
Neill Kapron | 01249cb | 2024-08-22 19:09:18 +0000 | [diff] [blame] | 30 | load_libbpf_progs(); |
| 31 | |
Neill Kapron | dd93f85 | 2024-08-07 22:39:57 +0000 | [diff] [blame] | 32 | // SAFETY: Linking in the existing legacy bpfloader functionality. |
Maciej Żenczykowski | 7ff8310 | 2024-08-13 20:04:00 +0000 | [diff] [blame] | 33 | // Any of the four following bindgen functions can abort() or exit() |
Neill Kapron | dd93f85 | 2024-08-07 22:39:57 +0000 | [diff] [blame] | 34 | // on failure and execNetBpfLoadDone() execve()'s. |
| 35 | unsafe { |
| 36 | bpf_android_bindgen::initLogging(); |
Maciej Żenczykowski | 7ff8310 | 2024-08-13 20:04:00 +0000 | [diff] [blame] | 37 | bpf_android_bindgen::createBpfFsSubDirectories(); |
Neill Kapron | dd93f85 | 2024-08-07 22:39:57 +0000 | [diff] [blame] | 38 | bpf_android_bindgen::legacyBpfLoader(); |
| 39 | bpf_android_bindgen::execNetBpfLoadDone(); |
| 40 | } |
| 41 | } |