Commit graph

125 commits

Author SHA1 Message Date
Stephane Lee
eb61b739ae Increase the log size for larger bpf programs
Test: Build passes, bpf program loads without an out of space error
Bug: 203462310
Change-Id: I5f67021a530223467662f341cdfffc4816781078
2021-10-22 19:07:05 -07:00
Patrick Rohr
b28bf2aa53 bpfloader: add schedact support
This also bumps the bpfloader version to 0.3 to signify support
for loading schedact (ie. tc scheduler action) programs.

Test: load netd.o
Change-Id: Ic3fdc80d3f6ea2b42a4f1d6829b1ff12dd4d52c0
2021-10-13 19:28:53 +00:00
Pirama Arumuga Nainar
e8d6df1231 Cleanup unused dependency to libprocessgroup
Bug: http://b/197965342

Dependence on libprocessgroup was removed in aosp/947297

Test: presubmit
Change-Id: I802efee3500e25006b55e0f35cb8650fd1aa2033
2021-08-31 19:59:20 +00:00
Maciej Żenczykowski
7ed94efeda expose readSectionUint() for testing
Bug: 190519702
Test: atest bpf_module_test, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I772c918d162440de6cc492b2faeafe03340fca11
2021-07-06 01:55:33 -07:00
Maciej Żenczykowski
36c53ba91e bpf - struct bpf_map_def - add min/max kernel version.
This is also bpfloader v0.2.
Some newer map types (for example DEVMAP) are unusable
on older kernel versions.

Bug: 190519702
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I085cc723ff1c19d8acc8972a391f894e16dd1875
2021-07-05 18:02:16 -07:00
Maciej Żenczykowski
a21256dcf1 bpfloader - minor fixups asked for by reviewer
As requested by Bernie on previous commit.

Bug: 190519702
Test: atest, TreeHugger - existing bpf programs load
  examination of bpfloader logs
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4f5181f371d31dcf52768217ffd2b1b5b772103d
2021-07-02 01:17:13 -07:00
Maciej Żenczykowski
9217eee3df bpf loader improvements for better long term compatibility with mainline
This is bpfLoader v0.1, previously we had no version number,
the version immediately preceding this commit we'll call v0.0.

Versions older than that are either pre-S and don't matter, since
loading mainline eBpf code was only added in S, or are from early
during the S development cycle (ie. pre-March 5th 2021 or earlier)
and simply no longer supported (no need to maintain compatibility).

Bug: 190519702
Test: atest, TreeHugger - existing bpf programs load
  examination of bpfloader logs
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I36fa5b917540be7ea3ecfddc5fe7834e9eb18d88
2021-07-02 03:36:49 +00:00
Maciej Żenczykowski
67fa2073ff BpfUtils.h - add back SKIP_IF_BPF_NOT_SUPPORTED macro
Needs to be used by dns mainline module tests on R devices (Pixel 2).

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2974a5368f4a9d744e30be9148aefac117d09acb
2021-03-11 19:52:30 -08:00
Maciej Żenczykowski
cb358de067 bpfloader: auto-demote DEVMAP/DEVMAP_HASH map types on too old kernels
Basically:
  <4.14: DEVMAP -> ARRAY
  <5.4: DEVMAP_HASH -> HASH

See added comments for explanation of why, but basically:
This allows our bpf program .o files to load maps on all kernel versions,
even if those map types are not supported by the kernel.
This avoids the need for code that conditionally creates maps based on
kernel version. Any program that actually attempts to use one of these
maps will fail to load, but programs are already loaded conditionally
based on kernel version so this is not a problem.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1a1d73b68de3606423de078fddb224402621e154
2021-03-05 06:00:59 +00:00
Maciej Żenczykowski
2c37213796 make failure on map creation returns -errno
This slightly improves error logging.

(also fd == 0 is not an error condition)

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I135e7405c508951fba632c634bc4e2d2161fc940
2021-03-02 07:46:32 +00:00
Maciej Żenczykowski
30af4b5487 KVER macro - support 4.9.256+ kernel
Instead of doing 16/8/8 bits for major/minor/subver macro,
switch to 8/8/16 bits, since this gives plenty of space:
  - major versions are bumped every few years, so 256 last forever
  - minor versions are bumped every few months (~5-6 per year),
    so 256 lasts for decades, additionally Linus Torvalds doesn't
    like big numbers, and eventually bumps the major instead
  - sub versions are the problematic ones, because they're bumped
    on every LTS security release, however even at one release per day,
    16 bits lasts for 180 years

Note: before this change 4.9.256 was treated as equivalent to 4.10.0.

Luckily all our tests were only ever (by chance) against the LTS release
bases (ie. 4.9.0, 4.14.0, 4.19.0, 5.4.0) and thus we wouldn't have hit
an actually failure until 4.9.(5*256) === 4.14.0 which would have caused
the bpfloader to attempt to load bpf code requiring 4.14 on a 4.9 kernel,
and resulted in failure of device to successfully boot.

Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0535ce081967af092f3342c0abfd05a1e5028eb6
2021-02-11 16:05:21 -08:00
Bob Badour
dcbf8ca070 [LSC] Add LOCAL_LICENSE_KINDS to system/bpf
Added SPDX-license-identifier-Apache-2.0 to:
  Android.bp
  bpfloader/Android.bp
  libbpf_android/Android.bp
  progs/Android.bp

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: Ia881b61da1755797085916aab5325375c82ed76e
2021-02-05 01:28:19 -08:00
Maciej Żenczykowski
8ed7c0f9b9 BpfMap - fix a clang warning: misc-unconventional-assign-operator
//system/bpf/libbpf_android:libbpf_android_test clang-tidy BpfMapTest.cpp
system/bpf/libbpf_android/include/bpf/BpfMap.h:138:5: warning: operator=() should return 'BpfMap&' [misc-unconventional-assign-operator]
    void operator=(BpfMap<Key, Value>&& other) noexcept {
    ^

Test: builds without warnings
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I0bb0d42f58bba58c7b9220f062453d827438e85a
2021-01-23 18:30:07 +00:00
Maciej Żenczykowski
cdf85a3148 move waitForProgsLoaded() to header file
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I2f0035f2622ca2a8c10d29caff912f3f895f2607
2021-01-21 17:39:33 -08:00
Maciej Żenczykowski
f7c0d993dd eliminate LoaderUtils.h
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I662714ee4faa6485d2ba7bbcbc8e34c76e37b091
2021-01-21 17:39:29 -08:00
Maciej Żenczykowski
23c436f957 header file cleanup
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I03920e51bab3cb704f156ea9c62a0a38fd65a3a9
2021-01-21 14:24:25 -08:00
Maciej Żenczykowski
a36bed395f add SKIP_IF_XDP_NOT_SUPPORTED macro
Test: builds, atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia954983565250faff547e81a53ec0df5fc26827e
2021-01-20 16:24:02 -08:00
Maciej Żenczykowski
916d2395cc remove isBpfSupported()
Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifb4b4ced25ac444fe913c6392c0c8d57b2d9c58e
2021-01-19 23:48:01 -08:00
Maciej Żenczykowski
dcb5228f2c remove BpfLevel and getBpfSupportLevel in favour of isAtLeastKernelVersion
Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I50dbed1843a8c2802e1b416281e193ae7d282a99
2021-01-19 23:48:01 -08:00
Maciej Żenczykowski
d8a4578f30 put tethering bpf maps & programs in /sys/fs/bpf/tethering/...
This makes it harder for system and mainline bpf programs to
conflict with each other, thus enabling easier mainline module
updates.

Test: builds and boots, atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic1b69bb1ddc4a10bd4861dadbd6b97e2520c532d
2021-01-20 05:17:14 +00:00
Treehugger Robot
da5d7ec6a7 Merge changes Ic378d0e5,Ib3a8696a
* changes:
  remove unused enum value BpfLevel::NONE
  remove unused function BpfLevelToString()
2021-01-20 03:38:42 +00:00
Treehugger Robot
71e977fb0d Merge "remove unused macros SKIP_IF_BPF{,_NOT}_SUPPORTED" 2021-01-20 03:09:46 +00:00
Maciej Żenczykowski
d6cbd5622e bpf is always supported
Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ifcc6ff2b2293b7585f20108ad849408ed9af4538
2021-01-20 01:37:32 +00:00
Maciej Żenczykowski
2337d47db3 remove unused enum value BpfLevel::NONE
Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic378d0e5a579abf44985a3353a21885796c297bb
2021-01-20 01:36:55 +00:00
Maciej Żenczykowski
5947162cc5 remove unused function BpfLevelToString()
Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ib3a8696a9653e5fbb022c98c26cfff623fadb3b4
2021-01-20 01:36:16 +00:00
Maciej Żenczykowski
b8e9af4b10 remove unused macros SKIP_IF_BPF{,_NOT}_SUPPORTED
Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic740b1102fcf735516123eee2c6a3d5caa0892f9
2021-01-20 01:15:04 +00:00
Maciej Żenczykowski
d56ec05712 libbpf_android/Loader.cpp - fix a clang warning (clang-analyzer-deadcode.DeadStores)
//system/bpf/libbpf_android:libbpf_android clang-tidy Loader.cpp
system/bpf/libbpf_android/Loader.cpp:133:5: warning: Value stored to 'entries' is never read [clang-analyzer-deadcode.DeadStores]
    entries = shTable.size();
    ^
system/bpf/libbpf_android/Loader.cpp:133:5: note: Value stored to 'entries' is never read

Test: builds without warnings
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I548976b59d44a51e992c9520e730fc9dae82fce2
2021-01-19 21:18:20 +00:00
Maciej Żenczykowski
1fddcce3c9 Merge "4.9 kernels must support eBPF (as of Android S)" 2021-01-14 07:36:56 +00:00
Maciej Żenczykowski
6fadbcf91a Merge "Use the module bpf_syscall_wrappers for BPF system calls" 2021-01-14 07:36:50 +00:00
Maciej Żenczykowski
ef6689652c 4.9 kernels must support eBPF (as of Android S)
so there is no longer a need to look at any properties
or api levels.

Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia5479db807f5444e48251dff45fd42fff610d5ca
2021-01-14 03:27:47 +00:00
Hungming Chen
a46f217d73 Use the module bpf_syscall_wrappers for BPF system calls
Use the versioned header library of BPF system calls and remove the
stubs.

Test: atest BpfMapTest
Change-Id: Ib178b02b7cfebaae7681609ae7c40a49cda47eeb
2021-01-13 14:34:41 +08:00
Maciej Żenczykowski
5756f0c937 SKIP_IF_BPF_NOT_SUPPORTED is a no-op
Android S requires devices to support eBPF.

Test: builds, atest, TreeHugger
Bug: 167500195
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I62fb97f79103515f5a2fd531cfa36356d21a4a6f
2021-01-12 02:08:55 +00:00
Treehugger Robot
8e614c2ca2 Merge "Add an sdk_version annotation to libbpf_android_headers." 2021-01-08 05:29:47 +00:00
Lorenzo Colitti
8cc4f91fca Add an sdk_version annotation to libbpf_android_headers.
This will be used by the tethering module when running on S, so
it needs to have an sdk_version. Because this target does not
depend on anything, there is no need to change any other code.

Because this is only needed by the tethering module, which
shipped in R, pick the R SDK version, 30. That ensures we do not
need to support it on releases older than when it is needed.

Test: m
Bug: 173167302
Change-Id: I15c1e943d0c30aceebcb8288e78a5a8135ee7fd1
2021-01-08 13:18:10 +09:00
Maciej Żenczykowski
aa46222706 add support for xdp bpf program type
Tested via:
  packages/modules/Connectivity/Tethering/Tethering/bpf_progs/offload.c:

  +DEFINE_BPF_PROG_KVER("xdp/test", AID_ROOT, AID_ROOT,
  +                      xdp_test, KVER(5, 10, 0))
  +(struct xdp_md *ctx) {
  +    return XDP_PASS;
  +}

  vsoc_x86:/ # ip link show dev lo
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

  vsoc_x86:/ # ip link set dev lo xdp pinned /sys/fs/bpf/prog_offload_xdp_test

  vsoc_x86:/ # ip link show dev lo
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 xdpgeneric qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      prog/xdp id 3 tag 3b185187f1855c4c jited

  vsoc_x86:/ # ip link set dev lo xdp off

  vsoc_x86:/ # ip link show dev lo
  1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

Test: atest, TreeHugger
Bug: 167540099
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7472d6d8120344abde9ea0f44c59a46f30da77f1
2021-01-07 14:51:20 -08:00
Suren Baghdasaryan
6597d87a67 libbpf_android: Add native_bridge_supported to allow usage in libmeminfo
libmeminfo needs to use BPF to read GPU usage reported by kernel
drivers, therefore a new dependency between libmeminfo and
libbpf_android is added. After this addition, native_bridge_supported
is required to successfully build cuttlefish targets.

Bug: 171261987
Test: build libmeminfo accessing BPF map
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I12e0613b13fb1206e204b5e85b4ea9a4d33e0cc9
2020-12-10 10:47:03 -08:00
Maciej Żenczykowski
38fb4300fb rename BPF_FD_TO_INT() macro to BPF_FD_TO_U32()
Cause that's what it actually does...

Bug: 173167302
Test: atest BpfMapTest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I8445cc4fe68f24bb3b26a678b7731b0c518e80f9
2020-11-30 17:06:58 -08:00
markchien
26ca77305d Fix BPF_FD_JUST_USE_INT macro
Bug: 173167302
Test: atest BpfMapTest
Change-Id: I70b58e23cc5b04a187de8d55ddc3f2b367718b88
2020-12-01 01:28:20 +08:00
markchien
90b02a072e Allow to just use integer for bpf fd
Bug: 173167302
Test: bpf_module_test
      clatd_test
      libnetdbpf_test
      netd_integration_test
      netd_unit_test
      netdutils_test

Change-Id: I2643222e1eb2c5686d7f64eac8d9c4666a235c69
2020-11-13 04:21:13 +00:00
Maciej Żenczykowski
21f34cb32c reduce error to warning - happens for valid progs-section-less programs
07-21 01:39:43.946 26835 26835 E LibBpfLoader: No progs section could be found in elf object
07-21 01:39:43.951 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/clatd.o
07-21 01:39:43.955 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/offload.o
07-21 01:39:43.958 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/time_in_state.o
07-21 01:39:43.967 26835 26835 I bpfloader: Loaded object: /system/etc/bpf/netd.o

Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie8413509f76741a66a4b00f0131a58e7ebdbae3f
2020-08-05 03:39:17 +00:00
Maciej Żenczykowski
2090e3449d waitForProgsLoaded() - reduce log spaminess
Logging every 5s isn't actually useful and it just gets the important stuff out
of log buffers.

Test: adb logcat -s 'bpfloader:D' 'BpfUtils:D' 'LibBpfLoader:D'
  ...
  06-17 01:02:34.205   433   433 E bpfloader: --- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---
  06-17 01:02:38.103   335   335 W LibBpfLoader: Waited 5s for bpf.progs_loaded, still waiting...
  06-17 01:02:48.104   335   335 W LibBpfLoader: Waited 10s for bpf.progs_loaded, still waiting...
  06-17 01:03:08.104   335   335 W LibBpfLoader: Waited 20s for bpf.progs_loaded, still waiting...
  06-17 01:04:12.226   335   335 W LibBpfLoader: Waited 60s for bpf.progs_loaded, still waiting...
  06-17 01:04:17.628  1324  1324 W LibBpfLoader: Waited 5s for bpf.progs_loaded, still waiting...
  06-17 01:04:27.629  1324  1324 W LibBpfLoader: Waited 10s for bpf.progs_loaded, still waiting...
  06-17 01:04:47.629  1324  1324 W LibBpfLoader: Waited 20s for bpf.progs_loaded, still waiting...
  06-17 01:05:50.163  1324  1324 W LibBpfLoader: Waited 60s for bpf.progs_loaded, still waiting...
  06-17 01:05:55.551  1741  1741 W LibBpfLoader: Waited 5s for bpf.progs_loaded, still waiting...

Bug: 150040815
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I77b82bf44141df8ffab1d11d01a89c3927fbe827
2020-06-17 21:24:55 +00:00
Maciej Żenczykowski
aa295c8355 implement support for functions which may optionally fail to load
This is useful for critical functions with fallbacks, but
may even be useful for non-critical functions, where a function
in the middle of the file may fail to load, but you still want
other (later) functions to be attempted.

Critical applies to the entire .c file (or to be more correct to
the entire resulting .o).  Optional applies to a specific section
of that .o (ie. a specific individual function).

This new optional attribute is necessary to be able to declare
a .c/.o file critical even if *some* of the individual functions
might fail to load due to missing kernel patches.

(Note: we currently have no way to specify a map as optional)

Critical guarantees that all non-optional programs, and all maps,
have been created, pinned, chowned, and chmoded successfully
(or that they already existed).

For an example of use see:
  system/netd/bpf_progs/offload.c

(while at it also add retrieveProgram() and mapRetrieve{RW,RO,WO}()
 helpers to BpfUtils.h)

Test: builds, atest, see paired netd change for extra details
Bug: 150040815
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I50b292c061b05fc8f4b4b8574f128345c45c78db
2020-06-17 10:44:19 +00:00
Maciej Żenczykowski
89515d979a Warn loudly and do not set bpf.progs_loaded property on critical bpf load failure.
Reasoning: critical load failures for netd bpf programs will just result
in unpredictable behaviour later on.  For example netd/systemserver
crash loops.

Test: builds
Bug: 150040815
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iefa01e60cd0a9a223e96411726a199bfb4857a5a
2020-06-15 08:01:50 +00:00
Maciej Żenczykowski
4ba8c1c1ac allow tagging a bpf .o as critical
This does not yet do anything with this information besides logging it.

Test: builds
  $ adb logcat -s -d LibBpfLoader:D | egrep Loading
  06-14 22:52:48.657   430   430 D LibBpfLoader: Loading critical for netd ELF object /system/etc/bpf/offload.o with license Apache 2.0
  06-14 22:52:48.682   430   430 D LibBpfLoader: Loading optional ELF object /system/etc/bpf/time_in_state.o with license GPL
  06-14 22:52:48.729   430   430 D LibBpfLoader: Loading critical for netd ELF object /system/etc/bpf/clatd.o with license Apache 2.0
  06-14 22:52:48.767   430   430 D LibBpfLoader: Loading critical for netd ELF object /system/etc/bpf/netd.o with license Apache 2.0
  06-14 22:53:26.052  2605  2605 D LibBpfLoader: Loading optional ELF object /data/local/tmp/32/kern.o with license Apache 2.0
  06-14 22:54:26.070  2605  2605 D LibBpfLoader: Loading optional ELF object /data/local/tmp/32/kern.o with license Apache 2.0
Bug: 150040815
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie07549528800d6d7c5ff7f12b859702113d7194e
2020-06-15 06:34:51 +00:00
Maciej Żenczykowski
567dc56b57 only set 'bpf.progs_loaded' property on eBPF capable devices...
... which also means waitForProgsLoaded() has to be a no-op on pre-bpf devices.

This is more consistent: it's weird to have bpf.progs_loaded set on a 4.4 device.

Test: builds, atest
Bug: 150040815
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iddabcf56c187ea518dd2e4d8db451b2f6902aa8e
2020-06-13 22:41:48 -07:00
Maciej Żenczykowski
54a7e769ae BpfMap.h - fix cert-oop54-cpp compiler warning
Fixes:
  system/bpf/libbpf_android/include/bpf/BpfMap.h:132:10: warning: operator=() does not handle self-assignment properly [cert-oop54-cpp]
      void operator=(const BpfMap<Key, Value>& other) {
           ^

Matches the self-assignment check from
  https://clang.llvm.org/extra/clang-tidy/checks/bugprone-unhandled-self-assignment.html

This isn't needed here, since the code was already correct, but
it does prevent a pointless newfd = dup(fd); close(fd); sequence.

Test: builds
Bug: 153035880
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia57f95d4ab180783c97db7e6f8d929f822c8958d
2020-04-24 08:15:00 -07:00
Maciej Żenczykowski
5206746831 Merge "libbpf_android/Loader.cpp - fixes performance-inefficient-string-concatenation warning" 2020-04-24 07:18:59 +00:00
Maciej Żenczykowski
fa1f620449 Merge "change to ro.kernel.ebpf.supported property" 2020-04-24 04:41:34 +00:00
Maciej Żenczykowski
6c7871b8df libbpf_android/Loader.cpp - fixes performance-inefficient-string-concatenation warning
Fixes:
  system/bpf/libbpf_android/Loader.cpp:562:73: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead [performance-inefficient-string-concatenation]
          string progPinLoc = string(BPF_FS_PATH) + "prog_" + fname + "_" + name;
                                                                          ^

Test: builds
Bug: 153035880
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: If56405273b4904e632a4b3a465b79eecae4c1446
2020-04-24 04:18:35 +00:00
Maciej Żenczykowski
428843de55 libbpf_android/Loader - fixes performance-faster-string-find warning
Fixes:
  system/bpf/libbpf_android/Loader.cpp:557:49: warning: 'find_last_of' called with a string literal consisting of a single character; consider using the more effective overload accepting a character [performance-faster-string-find]
          name = name.substr(0, name.find_last_of("$"));
                                                  ^~~
                                                  '$'

Test: builds
Bug: 153035880
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Iea62a59380c155796a7fa2ac4ca3352f9236ba98
2020-04-24 04:18:00 +00:00