bpf loader - finish support for kernel version conditional loading

bpf program section names must be unique to prevent programs from
appending to each other, so instead the bpf loader will strip
everything past the final $ symbol when actually pinning
the program into the filesystem.

While at it add a little bit more logging.

Example on aosp cuttlefish 5.4.30 virtual device:
  D LibBpfLoader: bpf_prog_load lib call for /system/etc/bpf/offload.o (schedcls_ingress_tether_ether) returned fd: 8 (no error)
  D LibBpfLoader: cs[1].name:schedcls_ingress_tether_rawip$stub min_kver:0 .max_kver:40e00 (kvers:5041e)
  D LibBpfLoader: cs[2].name:schedcls_ingress_tether_rawip$4_14 min_kver:40e00 .max_kver:ffffffff (kvers:5041e)
  D LibBpfLoader: bpf_prog_load lib call for /system/etc/bpf/offload.o (schedcls_ingress_tether_rawip$4_14) returned fd: 9 (no error)
  I bpfloader: Attempted load object: /system/etc/bpf/offload.o, ret: Success

  $ adb shell ls -l /sys/fs/bpf | egrep offload
  -rw-rw---- 1 root network_stack 0 2020-04-22 01:27 map_offload_tether_ingress_map
  -rw-rw---- 1 root network_stack 0 2020-04-22 01:27 map_offload_tether_stats_map
  -r--r----- 1 root root          0 2020-04-22 01:27 prog_offload_schedcls_ingress_tether_ether
  -r--r----- 1 root root          0 2020-04-22 01:27 prog_offload_schedcls_ingress_tether_rawip

Test: builds, atest, proper program loaded on 5.4.30 aosp cuttlefish
Bug: 149434314
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Id3fcb8e2a6b0087f704e77726e9961efc6145739
Merged-In: Id3fcb8e2a6b0087f704e77726e9961efc6145739
1 file changed
tree: 5905137f146fe6619ddbcb28b7f7dc4e6cef7a79
  1. bpfloader/
  2. libbpf_android/
  3. progs/
  4. Android.bp
  5. MODULE_LICENSE_APACHE2
  6. NOTICE
  7. OWNERS
  8. PREUPLOAD.cfg