Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Connectivity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Connectivity
Commits
4530eaaa
Commit
4530eaaa
authored
1 year ago
by
Maciej Żenczykowski
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "move bpfloader.rc into p/m/C" into main
parents
b0940279
7da54d99
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
netbpfload/Android.bp
+2
-1
2 additions, 1 deletion
netbpfload/Android.bp
netbpfload/netbpfload.rc
+19
-18
19 additions, 18 deletions
netbpfload/netbpfload.rc
with
21 additions
and
19 deletions
netbpfload/Android.bp
+
2
−
1
View file @
4530eaaa
...
@@ -46,5 +46,6 @@ cc_binary {
...
@@ -46,5 +46,6 @@ cc_binary {
// min_sdk_version(30) for "com.android.tethering": newer SDK(34).
// min_sdk_version(30) for "com.android.tethering": newer SDK(34).
min_sdk_version: "30",
min_sdk_version: "30",
// init_rc: ["netbpfload.rc"],
init_rc: ["netbpfload.rc"],
required: ["bpfloader"],
}
}
This diff is collapsed.
Click to expand it.
netbpfload/netbpfload.rc
+
19
−
18
View file @
4530eaaa
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
# a tad earlier. There's no benefit to that though, since on 4.9+ P+ devices netd
# a tad earlier. There's no benefit to that though, since on 4.9+ P+ devices netd
# will just block until bpfloader finishes and sets the bpf.progs_loaded property.
# will just block until bpfloader finishes and sets the bpf.progs_loaded property.
#
#
# It is important that we start
net
bpfload after:
# It is important that we start bpfload
er
after:
# - /sys/fs/bpf is already mounted,
# - /sys/fs/bpf is already mounted,
# - apex (incl. rollback) is initialized (so that in the future we can load bpf
# - apex (incl. rollback) is initialized (so that in the future we can load bpf
# programs shipped as part of apex mainline modules)
# programs shipped as part of apex mainline modules)
...
@@ -15,9 +15,10 @@
...
@@ -15,9 +15,10 @@
# considered to have booted successfully.
# considered to have booted successfully.
#
#
on load_bpf_programs
on load_bpf_programs
exec_start
net
bpfload
exec_start bpfload
er
service netbpfload /system/bin/netbpfload
service bpfloader /system/bin/netbpfload
# netbpfload will do network bpf loading, then execute /system/bin/bpfloader
capabilities CHOWN SYS_ADMIN NET_ADMIN
capabilities CHOWN SYS_ADMIN NET_ADMIN
# The following group memberships are a workaround for lack of DAC_OVERRIDE
# The following group memberships are a workaround for lack of DAC_OVERRIDE
# and allow us to open (among other things) files that we created and are
# and allow us to open (among other things) files that we created and are
...
@@ -27,28 +28,28 @@ service netbpfload /system/bin/netbpfload
...
@@ -27,28 +28,28 @@ service netbpfload /system/bin/netbpfload
group root graphics network_stack net_admin net_bw_acct net_bw_stats net_raw system
group root graphics network_stack net_admin net_bw_acct net_bw_stats net_raw system
user root
user root
#
#
# Set RLIMIT_MEMLOCK to 1GiB for
net
bpfload
# Set RLIMIT_MEMLOCK to 1GiB for bpfload
er
#
#
# Actually only 8MiB would be needed if
net
bpfload ran as its own uid.
# Actually only 8MiB would be needed if bpfload
er
ran as its own uid.
#
#
# However, while the rlimit is per-thread, the accounting is system wide.
# However, while the rlimit is per-thread, the accounting is system wide.
# So, for example, if the graphics stack has already allocated 10MiB of
# So, for example, if the graphics stack has already allocated 10MiB of
# memlock data before
net
bpfload even gets a chance to run, it would fail
# memlock data before bpfload
er
even gets a chance to run, it would fail
# if its memlock rlimit is only 8MiB - since there would be none left for it.
# if its memlock rlimit is only 8MiB - since there would be none left for it.
#
#
#
net
bpfload succeeding is critical to system health, since a failure will
# bpfload
er
succeeding is critical to system health, since a failure will
# cause netd crashloop and thus system server crashloop... and the only
# cause netd crashloop and thus system server crashloop... and the only
# recovery is a full kernel reboot.
# recovery is a full kernel reboot.
#
#
# We've had issues where devices would sometimes (rarely) boot into
# We've had issues where devices would sometimes (rarely) boot into
# a crashloop because
net
bpfload would occasionally lose a boot time
# a crashloop because bpfload
er
would occasionally lose a boot time
# race against the graphics stack's boot time locked memory allocation.
# race against the graphics stack's boot time locked memory allocation.
#
#
# Thus
net
bpfload's memlock has to be 8MB higher then the locked memory
# Thus bpfload
er
's memlock has to be 8MB higher then the locked memory
# consumption of the root uid anywhere else in the system...
# consumption of the root uid anywhere else in the system...
# But we don't know what that is for all possible devices...
# But we don't know what that is for all possible devices...
#
#
# Ideally, we'd simply grant
net
bpfload the IPC_LOCK capability and it
# Ideally, we'd simply grant bpfload
er
the IPC_LOCK capability and it
# would simply ignore it's memlock rlimit... but it turns that this
# would simply ignore it's memlock rlimit... but it turns that this
# capability is not even checked by the kernel's bpf system call.
# capability is not even checked by the kernel's bpf system call.
#
#
...
@@ -57,29 +58,29 @@ service netbpfload /system/bin/netbpfload
...
@@ -57,29 +58,29 @@ service netbpfload /system/bin/netbpfload
rlimit memlock 1073741824 1073741824
rlimit memlock 1073741824 1073741824
oneshot
oneshot
#
#
# How to debug bootloops caused by '
net
bpfload-failed'.
# How to debug bootloops caused by 'bpfload
er
-failed'.
#
#
# 1. On some lower RAM devices (like wembley) you may need to first enable developer mode
# 1. On some lower RAM devices (like wembley) you may need to first enable developer mode
# (from the Settings app UI), and change the developer option "Logger buffer sizes"
# (from the Settings app UI), and change the developer option "Logger buffer sizes"
# from the default (wembley: 64kB) to the maximum (1M) per log buffer.
# from the default (wembley: 64kB) to the maximum (1M) per log buffer.
# Otherwise buffer will overflow before you manage to dump it and you'll get useless logs.
# Otherwise buffer will overflow before you manage to dump it and you'll get useless logs.
#
#
# 2. comment out 'reboot_on_failure reboot,
net
bpfload-failed' below
# 2. comment out 'reboot_on_failure reboot,bpfload
er
-failed' below
# 3. rebuild/reflash/reboot
# 3. rebuild/reflash/reboot
# 4. as the device is booting up capture
net
bpfload logs via:
# 4. as the device is booting up capture bpfload
er
logs via:
# adb logcat -s 'NetBpfLoad:*' 'NetBpfLoader:*'
# adb logcat -s
'bpfloader:*' 'LibBpfLoader:*'
'NetBpfLoad:*' 'NetBpfLoader:*'
#
#
# something like:
# something like:
# $ adb reboot; sleep 1; adb wait-for-device; adb root; sleep 1; adb wait-for-device; adb logcat -s 'NetBpfLoad:*' 'NetBpfLoader:*'
# $ adb reboot; sleep 1; adb wait-for-device; adb root; sleep 1; adb wait-for-device; adb logcat -s
'bpfloader:*' 'LibBpfLoader:*'
'NetBpfLoad:*' 'NetBpfLoader:*'
# will take care of capturing logs as early as possible
# will take care of capturing logs as early as possible
#
#
# 5. look through the logs from the kernel's bpf verifier that
net
bpfload dumps out,
# 5. look through the logs from the kernel's bpf verifier that bpfload
er
dumps out,
# it usually makes sense to search back from the end and find the particular
# it usually makes sense to search back from the end and find the particular
# bpf verifier failure that caused
net
bpfload to terminate early with an error code.
# bpf verifier failure that caused bpfload
er
to terminate early with an error code.
# This will probably be something along the lines of 'too many jumps' or
# This will probably be something along the lines of 'too many jumps' or
# 'cannot prove return value is 0 or 1' or 'unsupported / unknown operation / helper',
# 'cannot prove return value is 0 or 1' or 'unsupported / unknown operation / helper',
# 'invalid bpf_context access', etc.
# 'invalid bpf_context access', etc.
#
#
reboot_on_failure reboot,
net
bpfload-failed
reboot_on_failure reboot,bpfload
er
-failed
# we're not really updatable, but want to be able to load bpf programs shipped in apexes
# we're not really updatable, but want to be able to load bpf programs shipped in apexes
updatable
updatable
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment