Hi,
On 1/12/2024 9:57 AM, Tiezhu Yang wrote:
If CONFIG_BPF_JIT_ALWAYS_ON is not set and bpf_jit_enable is 0, there
exist 6 failed tests.
+static bool is_jit_enabled(void)
+{
+ const char *jit_sysctl = "/proc/sys/net/core/bpf_jit_enable";
+ bool enabled = false;
+ int sysctl_fd;
+
+ sysctl_fd = open(jit_sysctl, 0, O_RDONLY);
It should be open(jit_sysctl, O_RDONLY).
+ if (sysctl_fd != -1) {
+ char tmpc;
+
+ if (read(sysctl_fd, &tmpc, sizeof(tmpc)) == 1)
+ enabled = (tmpc != '0');
+ close(sysctl_fd);
+ }
+
+ return enabled;
+}
+
static int null_terminated_insn_len(struct bpf_insn *seq, int max_len)
{
int i;
@@ -1662,6 +1691,16 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
goto close_fds;
}
+ if (!is_jit_enabled()) {
Is it necessary to check whether jit is enabled or not each time ? Could
we just check it only once just like unpriv_disabled does ?
+ for (i = 0; i < prog_len; i++, prog++) {
Is it better to only check pseudo_func only when both fd_prog < 0 and
saved_errno == EINVAL are true, so unnecessary check can be skipped ?