Commit f3b9cd84 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

bpf: Add workaround for ubuntu 20.04

parent 8f9744c0
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
*/ */
#include <linux/udp.h> #include <linux/udp.h>
#include <linux/bpf.h> #include <linux/bpf.h>
#include <linux/version.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
...@@ -240,7 +241,16 @@ static void InvSubBytes(state_t *state) { ...@@ -240,7 +241,16 @@ static void InvSubBytes(state_t *state) {
__u8 i, j; __u8 i, j;
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
for (j = 0; j < 4; ++j) { for (j = 0; j < 4; ++j) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0)
/* Ubuntu 20.04 LTS kernel 5.4.0 needs this workaround otherwise
"math between map_value pointer and register with unbounded
min value is not allowed". 5.10.0 is a kernel version that
works but it might not be a minimum version. */
__u8 k = (*state)[j][i];
(*state)[j][i] = k ? getSBoxInvert(k) : getSBoxInvert(0);
#else /* !(LINUX_VERSION_CDOE < KERNEL_VERSION(5, 10, 0)) */
(*state)[j][i] = getSBoxInvert((*state)[j][i]); (*state)[j][i] = getSBoxInvert((*state)[j][i]);
#endif /* !(LINUX_VERSION_CDOE < KERNEL_VERSION(5, 10, 0)) */
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment