blob: ede1a29d57e17b06a3327a5e1e9da9ef3999ff55 [file] [log] [blame]
Neill Kaprondd93f852024-08-07 22:39:57 +00001/*
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 Kapron01249cb2024-08-22 19:09:18 +000019#[cfg(enable_libbpf)]
20fn load_libbpf_progs() {
21 // Libbpf loader functionality here.
22}
23
24#[cfg(not(enable_libbpf))]
25fn load_libbpf_progs() {
26 // Empty stub for feature flag disabled case
27}
28
Neill Kaprondd93f852024-08-07 22:39:57 +000029fn main() {
Neill Kapron01249cb2024-08-22 19:09:18 +000030 load_libbpf_progs();
31
Neill Kaprondd93f852024-08-07 22:39:57 +000032 // SAFETY: Linking in the existing legacy bpfloader functionality.
Maciej Żenczykowski7ff83102024-08-13 20:04:00 +000033 // Any of the four following bindgen functions can abort() or exit()
Neill Kaprondd93f852024-08-07 22:39:57 +000034 // on failure and execNetBpfLoadDone() execve()'s.
35 unsafe {
36 bpf_android_bindgen::initLogging();
Maciej Żenczykowski7ff83102024-08-13 20:04:00 +000037 bpf_android_bindgen::createBpfFsSubDirectories();
Neill Kaprondd93f852024-08-07 22:39:57 +000038 bpf_android_bindgen::legacyBpfLoader();
39 bpf_android_bindgen::execNetBpfLoadDone();
40 }
41}