Commit graph

55 commits

Author SHA1 Message Date
Maciej Żenczykowski
8b74cbb34b NetBpfLoad: add describeArch() to log
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I959caf62dbf06b8a4fcac1e33a6e540b879b398e
2024-04-26 22:27:11 +00:00
Maciej Żenczykowski
75c2def0ea NetBpfLoad: move into android namespace
Change-Id: I5f841f796e49eebbf882b769cecf352b76800cf5
2024-04-25 14:26:50 -07:00
Maciej Żenczykowski
89efcc36e7 NetBpfLoad: prog names are only valid on 4.15+
The following commit is only in 4.15:

  commit cb4d2b3f03d8eed90be3a194e5b54b734ec4bbe9
  Author: Martin KaFai Lau <kafai@fb.com>
  Date:   Wed Sep 27 14:37:52 2017 -0700

    bpf: Add name, load_time, uid and map_ids to bpf_prog_info

  $ git describe cb4d2b3f03d8eed90be3a194e5b54b734ec4bbe9
  v4.14-rc1-661-gcb4d2b3f03d8

Bug: 335390828
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I246a7a8640bea1e939f12f3ffd3fedc25a0a6422
2024-04-23 03:16:05 +00:00
Maciej Żenczykowski
d0bb172371 NetBpfLoad: map names are only valid on 4.15+
$ git checkout v4.14
HEAD is now at bebc6082da0a Linux 4.14

$ git grep map_name | egrep -v '^(arch|drivers|fs|include|samples|tools)/'

(nothing)

$ git checkout v4.15
HEAD is now at d8a5b80568a9 Linux 4.15

$ git co remotes/linux-$ git grep map_name | egrep -v '^(arch|drivers|fs|include|samples|tools)/'
kernel/bpf/syscall.c:381:#define BPF_MAP_CREATE_LAST_FIELD map_name
kernel/bpf/syscall.c:408:	err = bpf_obj_name_cpy(map->name, attr->map_name);

  commit ad5b177bd73f5107d97c36f56395c4281fb6f089
  Author: Martin KaFai Lau <kafai@fb.com>
  Date:   Wed Sep 27 14:37:53 2017 -0700

    bpf: Add map_name to bpf_map_info

  $ git describe ad5b177bd73f5
  v4.14-rc1-662-gad5b177bd73f

Bug: 335390828
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I74f8ac8bbf78184a06b3ce005d0bb520b1d1feeb
2024-04-22 23:42:10 +00:00
Maciej Żenczykowski
3d14144698 NetBpfLoad: consistently use logging tag of 'NetBpfLoad'
instead of using 'NetBpfLoad' from NetBpfLoad.cpp
and 'NetBpfLoader' from loader.cpp

This will make it easier to filter logcat.

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ibd4e0b04592e8b41cde651c5596ce84bd8893c19
2024-04-20 00:03:19 +00:00
Maciej Żenczykowski
3218a81a57 NetBpfLoad: use exec path for api level 35+ (ie. V)
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I075b2a6166454d36599b0ecc25ccaeec545d183c
2024-04-15 02:13:56 -07:00
Theodore Dubois
6e8c1aa03d NetBpfLoad: Get logs back
r.android.com/3005052 changed the user id of the bpfloader service to
system, which cut off its access to /dev/kmsg, resulting in its logs
silently being dropped. Give back its access to /dev/kmsg.

See //system/core/init/README.md:

file <path> <type>

Open a file path and pass its fd to the launched process. type must be "r", "w" or "rw". For native executables see libcutils android_get_control_file().

and //system/libbase/logging.cpp's OpenKmsg()

Test: boot sdk_phone64_x86_64, check logs
Change-Id: I65f00545400140983737f3ff92e2c912eebce1fd
2024-03-25 22:49:56 +00:00
Maciej Żenczykowski
732a14164f NetBpfLoad: rework mainline bpf execution codepath
(for now for better testing we don't make V special)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id2835bd393c0ec9e1710644681bc5aab0d7d2aae
2024-03-19 21:45:21 +00:00
Maciej Żenczykowski
11141da623 NetBpfLoad: enable mainline on T+
Note:
   2 == BPFLOADER_S_VERSION
  19 == BPFLOADER_T_VERSION
  25 == BPFLOADER_OBJ_AT_VER_VERSION
  33 == BPFLOADER_IGNORED_ON_VERSION
  37 == BPFLOADER_U_VERSION [*]
  41 == BPFLOADER_V_VERSION [**]
and currently we have:
  42 == BPFLOADER_MAINLINE_VERSION
  43 == BPFLOADER_MAINLINE_T_VERSION
  44 == BPFLOADER_MAINLINE_U_VERSION
  45 == BPFLOADER_MAINLINE_V_VERSION

[*] udc-dev/udc-release are actually 38, as 37 was some earlier
    udc beta2 (2.1 ifirc), and beta3+ switched to 38

[**] 24Q{1,2}-release (ie. U QPR2+) are technically actually 41,
     but their platform bpfloader no longer even looks in /apex/com.android.tethering/etc/bpf/...
     so it doesn't really matter (although 24Q1's platform
     netbpfload still does, however that is obsoleted by
     this change)

Thus we need to (as minimum for NetBpfLoad):
  BPFLOADER_T_VERSION -> BPFLOADER_MAINLINE_T_VERSION
  BPFLOADER_IGNORED_ON_VERSION -> BPFLOADER_MAINLINE_U_VERSION
to cause these to load appropriately from mainline.

One would perhaps also expect (as minimum for NetBpfLoad):
  BPFLOADER_OBJ_AT_VERSION -> BPFLOADER_MAINLINE_U_VERSION
but (as maximum for platform bpfloader):
  BPFLOADER_OBJ_AT_VERSION -> BPFLOADER_MAINLINE_U_VERSION

However, since the goal is actually for those to load via mainline on T+,
(with the 'old' version of the .o's loading on S via platform bpfloader)
thus one actually needs (as minimum for NetBpfLoad):
  BPFLOADER_OBJ_AT_VERSION -> BPFLOADER_MAINLINE_T_VERSION
and (as maximum for platform bpfloader):
  BPFLOADER_OBJ_AT_VERSION -> BPFLOADER_T_VERSION

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4b688692ffca0db7ead20cefd9e7e892ca92c70a
2024-03-19 21:33:55 +00:00
Maciej Żenczykowski
a2706bf76c NetBpfLoad: add a few more consts for safety
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4f59ec295b34d6942732bb5f636699385e998bba
2024-03-18 22:28:25 -07:00
Maciej Żenczykowski
65f7022461 NetBpfLoad: chose bpfloader version at runtime based on Android OS
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iee55d9c6f828f05d4096dff2e874abc6c41eadeb
2024-03-18 15:02:53 -07:00
Maciej Żenczykowski
221b248c6e NetBpfLoad - change BPFLOADER_VERSION macro into an argument
(in preparation for this being run-time dynamic)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Icac8d1afdd3d55b80c232dd5a124a79a9063f350
2024-03-18 14:40:08 -07:00
Maciej Żenczykowski
22836357ec NetBpfLoad: more 4.9-T support
(older kernels don't support naming maps/programs)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If59b8947021394e1ce0a91326fee4272a5bddd38
2024-03-15 23:32:27 +00:00
Maciej Żenczykowski
0de80f1a9f Eliminate spurious COMPILE_FOR_BPFLOADER_VERSION macro
and make platform bpf.o's target V's platform bpfloader.

Note that all mainline shipped bpf.o's already manually
specify BPFLOADER_MIN_VER.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I67b73969def24e1e169c70c5fb1a402bf6e8cabc
2024-03-15 18:14:16 +00:00
Maciej Żenczykowski
7e5b09a37e netbpfload: add back support for 4.9-T kernels
This effectively reverts aosp/2268766

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I42da5c56fe4b69635b9678ff57ade7788c17f7c8
2024-03-11 12:40:33 +00:00
Maciej Żenczykowski
60414671ec NetBpfLoad: remove support for 'old' formats
cannot happen as it only loads mainline code
that it was built (and tested) along side of.

ie. a failure here would cause a TH boot failure.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia350deb10b4e40c9f4f01ea140a0bf97db508086
2024-03-08 19:31:17 +00:00
Maciej Żenczykowski
8c21593e6a netbpfload.rc - directly exec apex netbpfload
(instead of going via platform symlink to it)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5ae8105525733788b62f2866fc4eedcce3f51085
2024-03-08 19:07:40 +00:00
Treehugger Robot
09f372dc4a Merge "netbpfload: is now *always* mainline" into main 2024-03-08 13:04:52 +00:00
Maciej Żenczykowski
59fb77f8bf NetBpfLoad: bump version to 0.42
(this may well be the last version bump ever)

To get mainline version > any existing platform version.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I20c5dc515b0f94fae2c2fb6f45b6b8907fe7506e
2024-03-08 08:00:48 +00:00
Maciej Żenczykowski
08d4b8c27b netbpfload: is now *always* mainline
since there is no longer a platform netbpfload...
hence we can simplify

Now:
  git grep 'platformNetBpfLoad|apexNetBpfLoad|is_mainline|is_platform'
comes up empty

Test: TreeHugger, manual
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I834656bc4860386b6463db3f6a898d249a05e3a4
2024-03-08 02:19:09 +00:00
Maciej Żenczykowski
e0dd869f25 Reapply "replace platform netbpfload binary with a symlink to apex"
This reverts commit e636c61fd7.

Reason for revert: main is now building mainline modules from source

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0fc96a9eda10deed8f2d014fcb6f12a71ba73571
2024-03-07 02:09:18 +00:00
Vaibhav Devmurari
e636c61fd7 Revert "replace platform netbpfload binary with a symlink to apex"
This reverts commit 7f3d748cef.

Reason for revert: Potential cause for Build failures: b/328408957

Change-Id: I2a1e2375429ce1556362d369a97724c829b5aeb6
2024-03-06 14:38:33 +00:00
Maciej Żenczykowski
7f3d748cef replace platform netbpfload binary with a symlink to apex
(since the platform one just execs the apex one anyway)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ied0b890040ad9f6d77042f37cef82ddc47bff936
2024-03-05 18:32:19 -08:00
Maciej Żenczykowski
e678f57c88 netbpfload: introduce 'mainline_tethering_platform_components' phony/group target
this is to provide a convenient target for netd to depend on

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I5ceda32dbcbe4c0d1b420cc79880f9fe226ac458
2024-03-03 22:22:41 -08:00
Maciej Żenczykowski
a9209da871 NetBpfLoader: create /sys/fs/bpf/loader dir
(instead of in platform bpfloader)

Better to do it earlier so we can use it for
auto/permanently pinned/attached networking programs.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I202e150e6d48e63ba643c1bd2247cefcdebc07a5
2024-02-29 02:02:19 +00:00
Maciej Żenczykowski
a0b201c433 netbpfload: fail if platform exec of apex fails
should never fail, since we now have M-2024-1 module prebuilts:
  $ adb shell ls -d /apex/com.android.tethering*
  /apex/com.android.tethering
  /apex/com.android.tethering@341310230

Test: TreeHugger, manually on a Pixel device
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib145fba8e3c47bc300f4589723d9c80749770a19
2024-02-28 01:23:32 -08:00
Maciej Żenczykowski
7f6a42672d netbpfload: V+ x86 require 64-bit kernel
For reasoning see:
  https://android-review.googlesource.com/c/platform/system/netd/+/2966803

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If479b0443a64e0bf98ca89016d42ca37e231c576
2024-02-17 03:47:52 +00:00
Maciej Żenczykowski
03ef12cc79 netbpfload: enable on U QPR2 (aka 24Q1)
(this will land in M-2024-05 ie. May mainline tethering module)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I250b691eb03751da05ce10d41d6721f4964dd1d5
2024-02-13 00:31:30 +00:00
Maciej Żenczykowski
b60599b705 NetBpfLoad - log Tethering Apex version
(super useful for debugging)

Sample output:
  I NetBpfLoad: NetBpfLoad '/apex/com.android.tethering/bin/netbpfload' starting...
  I NetBpfLoad: NetBpfLoad api:10000/34 kver:6010019 platform:0 mainline:1
  D NetBpfLoad: Found Tethering Apex mounted from blockdev /dev/block/dm-55
  I NetBpfLoad: Tethering APEX version 340090000

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iaf1bc22b02913ea21ff9368abd9933e6ef4017f1
2024-02-09 23:31:17 +00:00
Maciej Żenczykowski
2fe2db52f6 netbpfload: use apex version whenever available
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8833451acc031b8b2137d23e9a6763851f149081
2024-02-07 01:24:26 +00:00
Maciej Żenczykowski
9128ac317d Merge "netbpfload: enable mainline on API V/35+" into main 2024-02-01 01:00:10 +00:00
Maciej Żenczykowski
041be52b08 netbpfload: enable mainline on API V/35+
netbpfload.mainline.rc is derived from:
  initrc-doc/bpfloader-sdk34-14-U.rc,
except that it is 'override' instead of 'updatable' and uses
the apex netbpfload instead of the platform bpfloader.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1ecf14e3d927ece136a0669a9b209be7112e55b5
2024-01-31 22:36:39 +00:00
Aditya Choudhary
01b5ede2b2 [DON'T BLOCK] Test ownership migration rules
This CL is created as a best effort to migrate test targets
to the new android ownership model. If you find incorrect or unnecessary
attribution in this CL, please create a separate CL to fix that.

For more details please refer to the link below,
<add g3 doc link>

Bug: 304529413
Test: N/A
Change-Id: I243f17b3f0ad7af9ffa15ca242456e36688733f5
Merged-In: I243f17b3f0ad7af9ffa15ca242456e36688733f5
2024-01-31 12:34:50 +00:00
Maciej Żenczykowski
f33f12876f netbpfload: prep work to support <U
proc file writes were only moved from .rc into bpfloader binary in U.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I20eda71d4f4e16130401d1cfff239c7cd8ea9bf6
2023-10-25 18:40:53 +00:00
Maciej Żenczykowski
4530eaaa9e Merge "move bpfloader.rc into p/m/C" into main 2023-10-25 00:07:02 +00:00
Maciej Żenczykowski
b0940279c4 doc: add bpfloader rc files from previous Android releases
Stripping comments since those are not interesting
for the purposes of what these things actually do.

Doing R+ since tethering apex only supports R+ now.

Generated via:
  (cd ../../../../../system/bpf && git cat-file -p remotes/aosp/android11-release:bpfloader/bpfloader.rc; ) | egrep -v '^ *#' > bpfloader-sdk30-11-R.rc
  (cd ../../../../../system/bpf && git cat-file -p remotes/aosp/android12-release:bpfloader/bpfloader.rc; ) | egrep -v '^ *#' > bpfloader-sdk31-12-S.rc
  (cd ../../../../../system/bpf && git cat-file -p remotes/aosp/android13-release:bpfloader/bpfloader.rc; ) | egrep -v '^ *#' > bpfloader-sdk33-13-T.rc
  (cd ../../../../../system/bpf && git cat-file -p remotes/aosp/android14-release:bpfloader/bpfloader.rc; ) | egrep -v '^ *#' > bpfloader-sdk34-14-U.rc
  (cd ../../../../../system/bpf && git cat-file -p remotes/aosp/main:bpfloader/bpfloader.rc;              ) | egrep -v '^ *#' > bpfloader-sdk34-14-U-QPR2.rc

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Idd8032ce66ef07a1d9e42343e75b26d764e6d8c1
2023-10-24 19:26:55 +00:00
Maciej Żenczykowski
7da54d9940 move bpfloader.rc into p/m/C
Generated via:
  cat ../../../system/bpf/bpfloader/bpfloader.rc > netbpfload/netbpfload.rc

(plus changing Android.bp to use it)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4bcdd57b0b5abcc296a4c56273d6aac632560345
2023-10-24 02:18:02 -07:00
Maciej Żenczykowski
1b36d2e2a3 Merge "execute platform bpfloader after netbpfload is done" into main 2023-10-21 16:06:44 +00:00
Maciej Żenczykowski
58c182291d execute platform bpfloader after netbpfload is done
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I447880763bbc506f08b578f862f09be91ab3d14d
2023-10-21 09:20:03 +00:00
Maciej Żenczykowski
ef63fd1fa0 Merge "move the bpf.progs_loaded = 1 setting back to bpfloader" into main 2023-10-21 02:18:05 +00:00
Maciej Żenczykowski
7db65c6d38 Revert "netbpfload: remove netbpfload.rc"
This mostly reverts commit 1d2c93d568.

Test: N/A
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0d7fdaeae508c0250114f7af8700d0fc40b0f27a
2023-10-21 00:15:00 +00:00
Maciej Żenczykowski
3f25b4ba8a move the bpf.progs_loaded = 1 setting back to bpfloader
change of design: we'll call netbpfload before bpfloader

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2d7a04a1bf1aa1d163f2b3936e2cde61308c4aa4
2023-10-20 15:18:50 -07:00
Maciej Żenczykowski
a2a3d754a6 build netbpfload into the tethering apex
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id68aece26115808c2b1b795b9395208f5066f87c
2023-10-10 16:51:01 -07:00
Maciej Żenczykowski
1d2c93d568 netbpfload: remove netbpfload.rc
I think it's better to just put this in bpfloader.rc,
where we can guarantee the correct ordering.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie2c5ab1cb1de015397ac54867ae6bb0c4321d207
2023-10-10 03:46:06 -07:00
Maciej Żenczykowski
af07d6db1f netbpfload: remove support for limiting selinux contexts
No need for this, as we simply only support those selinux
contexts (and directories) which are available to networking.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I35b134c57411f82514b9f7148411f83d3aee1927
2023-10-10 03:46:06 -07:00
Maciej Żenczykowski
857399114e netbpfload: do not create /sys/fs/bpf/loader subdir
(it's already created by the platform bpfloader)

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie22f585cab17fd2bded3d97a9cfe1019b792b69d
2023-10-10 03:37:14 -07:00
Elliott Hughes
497e3e05a5 Use libbase properties for a slight simplification.
Test: treehugger
Change-Id: If699230d0bf71ce521d7175da707e42b78ae4886
2023-10-09 23:57:48 +00:00
Maciej Żenczykowski
fcea70f840 netbpfload: remove support for limiting program types
No need for this, as we simply only support network
program types in the first place.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I163e21fd4d4089882cf37fc68bc4299003b514d7
2023-10-09 00:32:36 -07:00
Maciej Żenczykowski
02519f86ad netbpfload: remove non-network program types
We are unlikely to ever be willing to load these
program types from mainline, as it is simply too dangerous.

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1b0943d39b8131699f4606e8d165f3c944d453ed
2023-10-09 00:32:31 -07:00
Maciej Żenczykowski
40dfe53313 netbpfload: add Android.bp file
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3af8e7f14de8dd5dd65c40705195332bef114b88
2023-10-09 00:32:26 -07:00