summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2021-02-11 15:58:12 -0800
committerMaciej Żenczykowski <maze@google.com>2021-02-11 16:05:21 -0800
commit30af4b5487c53ecc7a32442f371e0cbc47c13bf8 (patch)
tree39e3e9230a126c9ca833e93d7d25e52219306959
parentdcbf8ca070f6f7ddd0004b401750a36dd8429f94 (diff)
downloadplatform_system_bpf-30af4b5487c53ecc7a32442f371e0cbc47c13bf8.tar.gz
platform_system_bpf-30af4b5487c53ecc7a32442f371e0cbc47c13bf8.tar.bz2
platform_system_bpf-30af4b5487c53ecc7a32442f371e0cbc47c13bf8.zip
KVER macro - support 4.9.256+ kernelandroid-s-preview-1
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
-rw-r--r--libbpf_android/include/bpf/BpfUtils.h2
-rw-r--r--progs/include/bpf_helpers.h2
2 files changed, 2 insertions, 2 deletions
diff --git a/libbpf_android/include/bpf/BpfUtils.h b/libbpf_android/include/bpf/BpfUtils.h
index 413d3ff..9671b8a 100644
--- a/libbpf_android/include/bpf/BpfUtils.h
+++ b/libbpf_android/include/bpf/BpfUtils.h
@@ -37,7 +37,7 @@ uint64_t getSocketCookie(int sockFd);
int synchronizeKernelRCU();
int setrlimitForTest();
-#define KVER(a, b, c) ((a)*65536 + (b)*256 + (c))
+#define KVER(a, b, c) (((a) << 24) + ((b) << 16) + (c))
unsigned kernelVersion();
diff --git a/progs/include/bpf_helpers.h b/progs/include/bpf_helpers.h
index a45b6fb..075ea94 100644
--- a/progs/include/bpf_helpers.h
+++ b/progs/include/bpf_helpers.h
@@ -109,7 +109,7 @@ static unsigned long long (*bpf_get_current_uid_gid)(void) = (void*) BPF_FUNC_ge
static unsigned long long (*bpf_get_smp_processor_id)(void) = (void*) BPF_FUNC_get_smp_processor_id;
#define KVER_NONE 0
-#define KVER(a, b, c) ((a)*65536 + (b)*256 + (c))
+#define KVER(a, b, c) (((a) << 24) + ((b) << 16) + (c))
#define KVER_INF 0xFFFFFFFF
#define DEFINE_BPF_PROG_KVER_RANGE_OPT(SECTION_NAME, prog_uid, prog_gid, the_prog, min_kv, max_kv, \