selftests/bpf: Let libbpf determine program type from section name
Now that libbpf can recognize SK_REUSEPORT programs, we no longer have to pass a prog_type hint before loading the object file. Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20191212102259.418536-3-jakub@cloudflare.com
This commit is contained in:
parent
67d69ccdf3
commit
1fbcef929d
@ -62,7 +62,7 @@ struct {
|
|||||||
goto done; \
|
goto done; \
|
||||||
})
|
})
|
||||||
|
|
||||||
SEC("select_by_skb_data")
|
SEC("sk_reuseport")
|
||||||
int _select_by_skb_data(struct sk_reuseport_md *reuse_md)
|
int _select_by_skb_data(struct sk_reuseport_md *reuse_md)
|
||||||
{
|
{
|
||||||
__u32 linum, index = 0, flags = 0, index_zero = 0;
|
__u32 linum, index = 0, flags = 0, index_zero = 0;
|
||||||
|
@ -87,19 +87,11 @@ static void prepare_bpf_obj(void)
|
|||||||
struct bpf_program *prog;
|
struct bpf_program *prog;
|
||||||
struct bpf_map *map;
|
struct bpf_map *map;
|
||||||
int err;
|
int err;
|
||||||
struct bpf_object_open_attr attr = {
|
|
||||||
.file = "test_select_reuseport_kern.o",
|
|
||||||
.prog_type = BPF_PROG_TYPE_SK_REUSEPORT,
|
|
||||||
};
|
|
||||||
|
|
||||||
obj = bpf_object__open_xattr(&attr);
|
obj = bpf_object__open("test_select_reuseport_kern.o");
|
||||||
CHECK(IS_ERR_OR_NULL(obj), "open test_select_reuseport_kern.o",
|
CHECK(IS_ERR_OR_NULL(obj), "open test_select_reuseport_kern.o",
|
||||||
"obj:%p PTR_ERR(obj):%ld\n", obj, PTR_ERR(obj));
|
"obj:%p PTR_ERR(obj):%ld\n", obj, PTR_ERR(obj));
|
||||||
|
|
||||||
prog = bpf_program__next(NULL, obj);
|
|
||||||
CHECK(!prog, "get first bpf_program", "!prog\n");
|
|
||||||
bpf_program__set_type(prog, attr.prog_type);
|
|
||||||
|
|
||||||
map = bpf_object__find_map_by_name(obj, "outer_map");
|
map = bpf_object__find_map_by_name(obj, "outer_map");
|
||||||
CHECK(!map, "find outer_map", "!map\n");
|
CHECK(!map, "find outer_map", "!map\n");
|
||||||
err = bpf_map__reuse_fd(map, outer_map);
|
err = bpf_map__reuse_fd(map, outer_map);
|
||||||
@ -108,6 +100,8 @@ static void prepare_bpf_obj(void)
|
|||||||
err = bpf_object__load(obj);
|
err = bpf_object__load(obj);
|
||||||
CHECK(err, "load bpf_object", "err:%d\n", err);
|
CHECK(err, "load bpf_object", "err:%d\n", err);
|
||||||
|
|
||||||
|
prog = bpf_program__next(NULL, obj);
|
||||||
|
CHECK(!prog, "get first bpf_program", "!prog\n");
|
||||||
select_by_skb_data_prog = bpf_program__fd(prog);
|
select_by_skb_data_prog = bpf_program__fd(prog);
|
||||||
CHECK(select_by_skb_data_prog == -1, "get prog fd",
|
CHECK(select_by_skb_data_prog == -1, "get prog fd",
|
||||||
"select_by_skb_data_prog:%d\n", select_by_skb_data_prog);
|
"select_by_skb_data_prog:%d\n", select_by_skb_data_prog);
|
||||||
|
Loading…
Reference in New Issue
Block a user