log_buf[0] = '\0'; if (exp_msg)
bpf_program__set_log_buf(prog, log_buf, sizeof(log_buf)); if (env.verbosity > VERBOSE_NONE)
bpf_program__set_log_level(prog, 2);
/* It should fail to load the program */
err = bpf_object__load(obj); if (env.verbosity > VERBOSE_NONE && exp_msg) /* we overtook log */
printf("VERIFIER LOG:\n================\n%s\n================\n", log_buf); if (CHECK(!err, "bpf_obj_load should fail", "err %d\n", err)) goto close_prog;
if (exp_msg)
ASSERT_HAS_SUBSTR(log_buf, exp_msg, "fail_msg");
close_prog:
bpf_object__close(obj);
bpf_object__close(pkt_obj);
}
staticvoid test_func_replace_return_code(void)
{ /* test invalid return code in the replaced program */
test_obj_load_failure_common("./freplace_connect_v4_prog.bpf.o", "./connect4_prog.bpf.o", NULL);
}
staticvoid test_func_map_prog_compatibility(void)
{ /* test with spin lock map value in the replaced program */
test_obj_load_failure_common("./freplace_attach_probe.bpf.o", "./test_attach_probe.bpf.o", NULL);
}
staticvoid test_func_replace_unreliable(void)
{ /* freplace'ing unreliable main prog should fail with error * "Cannot replace static functions"
*/
test_obj_load_failure_common("freplace_unreliable_prog.bpf.o", "./verifier_btf_unreliable_prog.bpf.o", "Cannot replace static functions");
}
skel = freplace_progmap__open(); if (!ASSERT_OK_PTR(skel, "prog_open")) return;
tgt_skel = xdp_dummy__open_and_load(); if (!ASSERT_OK_PTR(tgt_skel, "tgt_prog_load")) goto out;
err = bpf_program__set_attach_target(skel->progs.xdp_cpumap_prog,
bpf_program__fd(tgt_skel->progs.xdp_dummy_prog), "xdp_dummy_prog"); if (!ASSERT_OK(err, "set_attach_target")) goto out;
err = freplace_progmap__load(skel); if (!ASSERT_OK(err, "obj_load")) goto out;
/* Prior to fixing the kernel, loading the PROG_TYPE_EXT 'redirect' * program above will cause the map owner type of 'cpumap' to be set to * PROG_TYPE_EXT. This in turn will cause the bpf_map_update_elem() * below to fail, because the program we are inserting into the map is * of PROG_TYPE_XDP. After fixing the kernel, the initial ownership will * be correctly resolved to the *target* of the PROG_TYPE_EXT program * (i.e., PROG_TYPE_XDP) and the map update will succeed.
*/
value.bpf_prog.fd = bpf_program__fd(skel->progs.xdp_drop_prog);
err = bpf_map_update_elem(bpf_map__fd(skel->maps.cpu_map),
&key, &value, 0);
ASSERT_OK(err, "map_update");
/* NOTE: affect other tests, must run in serial mode */ void serial_test_fexit_bpf2bpf(void)
{ if (test__start_subtest("target_no_callees"))
test_target_no_callees(); if (test__start_subtest("target_yes_callees"))
test_target_yes_callees(); if (test__start_subtest("func_replace"))
test_func_replace(); if (test__start_subtest("func_replace_verify"))
test_func_replace_verify(); if (test__start_subtest("func_sockmap_update"))
test_func_sockmap_update(); if (test__start_subtest("func_replace_return_code"))
test_func_replace_return_code(); if (test__start_subtest("func_map_prog_compatibility"))
test_func_map_prog_compatibility(); if (test__start_subtest("func_replace_unreliable"))
test_func_replace_unreliable(); if (test__start_subtest("func_replace_multi"))
test_func_replace_multi(); if (test__start_subtest("fmod_ret_freplace"))
test_fmod_ret_freplace(); if (test__start_subtest("func_replace_global_func"))
test_func_replace_global_func(); if (test__start_subtest("fentry_to_cgroup_bpf"))
test_fentry_to_cgroup_bpf(); if (test__start_subtest("func_replace_progmap"))
test_func_replace_progmap();
}
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.23Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.