Commit 4e874b11 authored by Alexei Starovoitov's avatar Alexei Starovoitov

Merge branch 'libbpf: stricter BPF program section name handling'

Andrii Nakryiko says:

====================

Implement opt-in stricter BPF program section name (SEC()) handling logic. For
a lot of supported ELF section names, enforce exact section name match with no
arbitrary characters added at the end. See patch #9 for more details.

To allow this, patches #2 through #4 clean up and preventively fix selftests,
normalizing existing SEC() usage across multiple selftests. While at it, those
patches also reduce the amount of remaining bpf_object__find_program_by_title()
uses, which should be completely removed soon, given it's an API with
ambiguous semantics and will be deprecated and eventually removed in libbpf 1.0.

Patch #1 also introduces SEC("tc") as an alias for SEC("classifier"). "tc" is
a better and less misleading name, so patch #3 replaces all classifier* uses
with nice and short SEC("tc").

Last patch is also fixing "sk_lookup/" definition to not require and not allow
extra "/blah" parts after it, which serve no meaning.

All the other patches are gradual internal libbpf changes to:
  - allow this optional strict logic for ELF section name handling;
  - allow new use case (for now for "struct_ops", but that could be extended
    to, say, freplace definitions), in which it can be used stand-alone to
    specify just type (SEC("struct_ops")), or also accept extra parameters
    which can be utilized by libbpf to either get more data or double-check
    valid use (e.g., SEC("struct_ops/dctcp_init") to specify desired
    struct_ops operation that is supposed to be implemented);
  - get libbpf's internal logic ready to allow other libraries and
    applications to specify their custom handlers for ELF section name for BPF
    programs. All the pieces are in place, the only thing preventing making
    this as public libbpf API is reliance on internal type for specifying BPF
    program load attributes. The work is planned to revamp related low-level
    libbpf APIs, at which point it will be possible to just re-use such new
    types for coordination between libbpf and custom handlers.

These changes are a part of libbpf 1.0 effort ([0]). They are also intended to
be applied on top of the previous preparatory series [1], so currently CI will
be failing to apply them to bpf-next until that patch set is landed. Once it
is landed, kernel-patches daemon will automatically retest this patch set.

  [0] https://github.com/libbpf/libbpf/wiki/Libbpf:-the-road-to-v1.0#stricter-and-more-uniform-bpf-program-section-name-sec-handling
  [1] https://patchwork.kernel.org/project/netdevbpf/list/?series=547675&state=*

v3->v4:
  - replace SEC("classifier*") with SEC("tc") (Daniel);
v2->v3:
  - applied acks, addressed most feedback, added comments to new flags (Dave);
v1->v2:
  - rebase onto latest bpf-next and resolve merge conflicts w/ Dave's changes.
====================
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parents 29eef85b 7c80c87a
...@@ -220,17 +220,40 @@ struct reloc_desc { ...@@ -220,17 +220,40 @@ struct reloc_desc {
struct bpf_sec_def; struct bpf_sec_def;
typedef struct bpf_link *(*attach_fn_t)(const struct bpf_program *prog); typedef int (*init_fn_t)(struct bpf_program *prog, long cookie);
typedef int (*preload_fn_t)(struct bpf_program *prog, struct bpf_prog_load_params *attr, long cookie);
typedef struct bpf_link *(*attach_fn_t)(const struct bpf_program *prog, long cookie);
/* stored as sec_def->cookie for all libbpf-supported SEC()s */
enum sec_def_flags {
SEC_NONE = 0,
/* expected_attach_type is optional, if kernel doesn't support that */
SEC_EXP_ATTACH_OPT = 1,
/* legacy, only used by libbpf_get_type_names() and
* libbpf_attach_type_by_name(), not used by libbpf itself at all.
* This used to be associated with cgroup (and few other) BPF programs
* that were attachable through BPF_PROG_ATTACH command. Pretty
* meaningless nowadays, though.
*/
SEC_ATTACHABLE = 2,
SEC_ATTACHABLE_OPT = SEC_ATTACHABLE | SEC_EXP_ATTACH_OPT,
/* attachment target is specified through BTF ID in either kernel or
* other BPF program's BTF object */
SEC_ATTACH_BTF = 4,
/* BPF program type allows sleeping/blocking in kernel */
SEC_SLEEPABLE = 8,
/* allow non-strict prefix matching */
SEC_SLOPPY_PFX = 16,
};
struct bpf_sec_def { struct bpf_sec_def {
const char *sec; const char *sec;
size_t len;
enum bpf_prog_type prog_type; enum bpf_prog_type prog_type;
enum bpf_attach_type expected_attach_type; enum bpf_attach_type expected_attach_type;
bool is_exp_attach_type_optional; long cookie;
bool is_attachable;
bool is_attach_btf; init_fn_t init_fn;
bool is_sleepable; preload_fn_t preload_fn;
attach_fn_t attach_fn; attach_fn_t attach_fn;
}; };
...@@ -1665,7 +1688,7 @@ static int bpf_object__process_kconfig_line(struct bpf_object *obj, ...@@ -1665,7 +1688,7 @@ static int bpf_object__process_kconfig_line(struct bpf_object *obj,
void *ext_val; void *ext_val;
__u64 num; __u64 num;
if (strncmp(buf, "CONFIG_", 7)) if (!str_has_pfx(buf, "CONFIG_"))
return 0; return 0;
sep = strchr(buf, '='); sep = strchr(buf, '=');
...@@ -2914,7 +2937,7 @@ static Elf_Data *elf_sec_data(const struct bpf_object *obj, Elf_Scn *scn) ...@@ -2914,7 +2937,7 @@ static Elf_Data *elf_sec_data(const struct bpf_object *obj, Elf_Scn *scn)
static bool is_sec_name_dwarf(const char *name) static bool is_sec_name_dwarf(const char *name)
{ {
/* approximation, but the actual list is too long */ /* approximation, but the actual list is too long */
return strncmp(name, ".debug_", sizeof(".debug_") - 1) == 0; return str_has_pfx(name, ".debug_");
} }
static bool ignore_elf_section(GElf_Shdr *hdr, const char *name) static bool ignore_elf_section(GElf_Shdr *hdr, const char *name)
...@@ -2936,7 +2959,7 @@ static bool ignore_elf_section(GElf_Shdr *hdr, const char *name) ...@@ -2936,7 +2959,7 @@ static bool ignore_elf_section(GElf_Shdr *hdr, const char *name)
if (is_sec_name_dwarf(name)) if (is_sec_name_dwarf(name))
return true; return true;
if (strncmp(name, ".rel", sizeof(".rel") - 1) == 0) { if (str_has_pfx(name, ".rel")) {
name += sizeof(".rel") - 1; name += sizeof(".rel") - 1;
/* DWARF section relocations */ /* DWARF section relocations */
if (is_sec_name_dwarf(name)) if (is_sec_name_dwarf(name))
...@@ -6095,6 +6118,48 @@ static int bpf_object__sanitize_prog(struct bpf_object *obj, struct bpf_program ...@@ -6095,6 +6118,48 @@ static int bpf_object__sanitize_prog(struct bpf_object *obj, struct bpf_program
return 0; return 0;
} }
static int libbpf_find_attach_btf_id(struct bpf_program *prog, const char *attach_name,
int *btf_obj_fd, int *btf_type_id);
/* this is called as prog->sec_def->preload_fn for libbpf-supported sec_defs */
static int libbpf_preload_prog(struct bpf_program *prog,
struct bpf_prog_load_params *attr, long cookie)
{
enum sec_def_flags def = cookie;
/* old kernels might not support specifying expected_attach_type */
if ((def & SEC_EXP_ATTACH_OPT) && !kernel_supports(prog->obj, FEAT_EXP_ATTACH_TYPE))
attr->expected_attach_type = 0;
if (def & SEC_SLEEPABLE)
attr->prog_flags |= BPF_F_SLEEPABLE;
if ((prog->type == BPF_PROG_TYPE_TRACING ||
prog->type == BPF_PROG_TYPE_LSM ||
prog->type == BPF_PROG_TYPE_EXT) && !prog->attach_btf_id) {
int btf_obj_fd = 0, btf_type_id = 0, err;
const char *attach_name;
attach_name = strchr(prog->sec_name, '/') + 1;
err = libbpf_find_attach_btf_id(prog, attach_name, &btf_obj_fd, &btf_type_id);
if (err)
return err;
/* cache resolved BTF FD and BTF type ID in the prog */
prog->attach_btf_obj_fd = btf_obj_fd;
prog->attach_btf_id = btf_type_id;
/* but by now libbpf common logic is not utilizing
* prog->atach_btf_obj_fd/prog->attach_btf_id anymore because
* this callback is called after attrs were populated by
* libbpf, so this callback has to update attr explicitly here
*/
attr->attach_btf_obj_fd = btf_obj_fd;
attr->attach_btf_id = btf_type_id;
}
return 0;
}
static int static int
load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
char *license, __u32 kern_version, int *pfd) char *license, __u32 kern_version, int *pfd)
...@@ -6103,7 +6168,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, ...@@ -6103,7 +6168,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
char *cp, errmsg[STRERR_BUFSIZE]; char *cp, errmsg[STRERR_BUFSIZE];
size_t log_buf_size = 0; size_t log_buf_size = 0;
char *log_buf = NULL; char *log_buf = NULL;
int btf_fd, ret; int btf_fd, ret, err;
if (prog->type == BPF_PROG_TYPE_UNSPEC) { if (prog->type == BPF_PROG_TYPE_UNSPEC) {
/* /*
...@@ -6119,11 +6184,6 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, ...@@ -6119,11 +6184,6 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
return -EINVAL; return -EINVAL;
load_attr.prog_type = prog->type; load_attr.prog_type = prog->type;
/* old kernels might not support specifying expected_attach_type */
if (!kernel_supports(prog->obj, FEAT_EXP_ATTACH_TYPE) && prog->sec_def &&
prog->sec_def->is_exp_attach_type_optional)
load_attr.expected_attach_type = 0;
else
load_attr.expected_attach_type = prog->expected_attach_type; load_attr.expected_attach_type = prog->expected_attach_type;
if (kernel_supports(prog->obj, FEAT_PROG_NAME)) if (kernel_supports(prog->obj, FEAT_PROG_NAME))
load_attr.name = prog->name; load_attr.name = prog->name;
...@@ -6131,9 +6191,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, ...@@ -6131,9 +6191,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
load_attr.insn_cnt = insns_cnt; load_attr.insn_cnt = insns_cnt;
load_attr.license = license; load_attr.license = license;
load_attr.attach_btf_id = prog->attach_btf_id; load_attr.attach_btf_id = prog->attach_btf_id;
if (prog->attach_prog_fd)
load_attr.attach_prog_fd = prog->attach_prog_fd; load_attr.attach_prog_fd = prog->attach_prog_fd;
else
load_attr.attach_btf_obj_fd = prog->attach_btf_obj_fd; load_attr.attach_btf_obj_fd = prog->attach_btf_obj_fd;
load_attr.attach_btf_id = prog->attach_btf_id; load_attr.attach_btf_id = prog->attach_btf_id;
load_attr.kern_version = kern_version; load_attr.kern_version = kern_version;
...@@ -6153,6 +6211,16 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, ...@@ -6153,6 +6211,16 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
load_attr.log_level = prog->log_level; load_attr.log_level = prog->log_level;
load_attr.prog_flags = prog->prog_flags; load_attr.prog_flags = prog->prog_flags;
/* adjust load_attr if sec_def provides custom preload callback */
if (prog->sec_def && prog->sec_def->preload_fn) {
err = prog->sec_def->preload_fn(prog, &load_attr, prog->sec_def->cookie);
if (err < 0) {
pr_warn("prog '%s': failed to prepare load attributes: %d\n",
prog->name, err);
return err;
}
}
if (prog->obj->gen_loader) { if (prog->obj->gen_loader) {
bpf_gen__prog_load(prog->obj->gen_loader, &load_attr, bpf_gen__prog_load(prog->obj->gen_loader, &load_attr,
prog - prog->obj->programs); prog - prog->obj->programs);
...@@ -6268,8 +6336,6 @@ static int bpf_program__record_externs(struct bpf_program *prog) ...@@ -6268,8 +6336,6 @@ static int bpf_program__record_externs(struct bpf_program *prog)
return 0; return 0;
} }
static int libbpf_find_attach_btf_id(struct bpf_program *prog, int *btf_obj_fd, int *btf_type_id);
int bpf_program__load(struct bpf_program *prog, char *license, __u32 kern_ver) int bpf_program__load(struct bpf_program *prog, char *license, __u32 kern_ver)
{ {
int err = 0, fd, i; int err = 0, fd, i;
...@@ -6279,19 +6345,6 @@ int bpf_program__load(struct bpf_program *prog, char *license, __u32 kern_ver) ...@@ -6279,19 +6345,6 @@ int bpf_program__load(struct bpf_program *prog, char *license, __u32 kern_ver)
return libbpf_err(-EINVAL); return libbpf_err(-EINVAL);
} }
if ((prog->type == BPF_PROG_TYPE_TRACING ||
prog->type == BPF_PROG_TYPE_LSM ||
prog->type == BPF_PROG_TYPE_EXT) && !prog->attach_btf_id) {
int btf_obj_fd = 0, btf_type_id = 0;
err = libbpf_find_attach_btf_id(prog, &btf_obj_fd, &btf_type_id);
if (err)
return libbpf_err(err);
prog->attach_btf_obj_fd = btf_obj_fd;
prog->attach_btf_id = btf_type_id;
}
if (prog->instances.nr < 0 || !prog->instances.fds) { if (prog->instances.nr < 0 || !prog->instances.fds) {
if (prog->preprocessor) { if (prog->preprocessor) {
pr_warn("Internal error: can't load program '%s'\n", pr_warn("Internal error: can't load program '%s'\n",
...@@ -6401,6 +6454,7 @@ static const struct bpf_sec_def *find_sec_def(const char *sec_name); ...@@ -6401,6 +6454,7 @@ static const struct bpf_sec_def *find_sec_def(const char *sec_name);
static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object_open_opts *opts) static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object_open_opts *opts)
{ {
struct bpf_program *prog; struct bpf_program *prog;
int err;
bpf_object__for_each_program(prog, obj) { bpf_object__for_each_program(prog, obj) {
prog->sec_def = find_sec_def(prog->sec_name); prog->sec_def = find_sec_def(prog->sec_name);
...@@ -6411,8 +6465,6 @@ static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object ...@@ -6411,8 +6465,6 @@ static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object
continue; continue;
} }
if (prog->sec_def->is_sleepable)
prog->prog_flags |= BPF_F_SLEEPABLE;
bpf_program__set_type(prog, prog->sec_def->prog_type); bpf_program__set_type(prog, prog->sec_def->prog_type);
bpf_program__set_expected_attach_type(prog, prog->sec_def->expected_attach_type); bpf_program__set_expected_attach_type(prog, prog->sec_def->expected_attach_type);
...@@ -6422,6 +6474,18 @@ static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object ...@@ -6422,6 +6474,18 @@ static int bpf_object_init_progs(struct bpf_object *obj, const struct bpf_object
prog->sec_def->prog_type == BPF_PROG_TYPE_EXT) prog->sec_def->prog_type == BPF_PROG_TYPE_EXT)
prog->attach_prog_fd = OPTS_GET(opts, attach_prog_fd, 0); prog->attach_prog_fd = OPTS_GET(opts, attach_prog_fd, 0);
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
/* sec_def can have custom callback which should be called
* after bpf_program is initialized to adjust its properties
*/
if (prog->sec_def->init_fn) {
err = prog->sec_def->init_fn(prog, prog->sec_def->cookie);
if (err < 0) {
pr_warn("prog '%s': failed to initialize: %d\n",
prog->name, err);
return err;
}
}
} }
return 0; return 0;
...@@ -6848,8 +6912,7 @@ static int bpf_object__resolve_externs(struct bpf_object *obj, ...@@ -6848,8 +6912,7 @@ static int bpf_object__resolve_externs(struct bpf_object *obj,
if (err) if (err)
return err; return err;
pr_debug("extern (kcfg) %s=0x%x\n", ext->name, kver); pr_debug("extern (kcfg) %s=0x%x\n", ext->name, kver);
} else if (ext->type == EXT_KCFG && } else if (ext->type == EXT_KCFG && str_has_pfx(ext->name, "CONFIG_")) {
strncmp(ext->name, "CONFIG_", 7) == 0) {
need_config = true; need_config = true;
} else if (ext->type == EXT_KSYM) { } else if (ext->type == EXT_KSYM) {
if (ext->ksym.type_id) if (ext->ksym.type_id)
...@@ -7909,217 +7972,143 @@ void bpf_program__set_expected_attach_type(struct bpf_program *prog, ...@@ -7909,217 +7972,143 @@ void bpf_program__set_expected_attach_type(struct bpf_program *prog,
prog->expected_attach_type = type; prog->expected_attach_type = type;
} }
#define BPF_PROG_SEC_IMPL(string, ptype, eatype, eatype_optional, \ #define SEC_DEF(sec_pfx, ptype, atype, flags, ...) { \
attachable, attach_btf) \
{ \
.sec = string, \
.len = sizeof(string) - 1, \
.prog_type = ptype, \
.expected_attach_type = eatype, \
.is_exp_attach_type_optional = eatype_optional, \
.is_attachable = attachable, \
.is_attach_btf = attach_btf, \
}
/* Programs that can NOT be attached. */
#define BPF_PROG_SEC(string, ptype) BPF_PROG_SEC_IMPL(string, ptype, 0, 0, 0, 0)
/* Programs that can be attached. */
#define BPF_APROG_SEC(string, ptype, atype) \
BPF_PROG_SEC_IMPL(string, ptype, atype, true, 1, 0)
/* Programs that must specify expected attach type at load time. */
#define BPF_EAPROG_SEC(string, ptype, eatype) \
BPF_PROG_SEC_IMPL(string, ptype, eatype, false, 1, 0)
/* Programs that use BTF to identify attach point */
#define BPF_PROG_BTF(string, ptype, eatype) \
BPF_PROG_SEC_IMPL(string, ptype, eatype, false, 0, 1)
/* Programs that can be attached but attach type can't be identified by section
* name. Kept for backward compatibility.
*/
#define BPF_APROG_COMPAT(string, ptype) BPF_PROG_SEC(string, ptype)
#define SEC_DEF(sec_pfx, ptype, ...) { \
.sec = sec_pfx, \ .sec = sec_pfx, \
.len = sizeof(sec_pfx) - 1, \
.prog_type = BPF_PROG_TYPE_##ptype, \ .prog_type = BPF_PROG_TYPE_##ptype, \
.expected_attach_type = atype, \
.cookie = (long)(flags), \
.preload_fn = libbpf_preload_prog, \
__VA_ARGS__ \ __VA_ARGS__ \
} }
static struct bpf_link *attach_kprobe(const struct bpf_program *prog); static struct bpf_link *attach_kprobe(const struct bpf_program *prog, long cookie);
static struct bpf_link *attach_tp(const struct bpf_program *prog); static struct bpf_link *attach_tp(const struct bpf_program *prog, long cookie);
static struct bpf_link *attach_raw_tp(const struct bpf_program *prog); static struct bpf_link *attach_raw_tp(const struct bpf_program *prog, long cookie);
static struct bpf_link *attach_trace(const struct bpf_program *prog); static struct bpf_link *attach_trace(const struct bpf_program *prog, long cookie);
static struct bpf_link *attach_lsm(const struct bpf_program *prog); static struct bpf_link *attach_lsm(const struct bpf_program *prog, long cookie);
static struct bpf_link *attach_iter(const struct bpf_program *prog); static struct bpf_link *attach_iter(const struct bpf_program *prog, long cookie);
static const struct bpf_sec_def section_defs[] = { static const struct bpf_sec_def section_defs[] = {
BPF_PROG_SEC("socket", BPF_PROG_TYPE_SOCKET_FILTER), SEC_DEF("socket", SOCKET_FILTER, 0, SEC_NONE | SEC_SLOPPY_PFX),
BPF_EAPROG_SEC("sk_reuseport/migrate", BPF_PROG_TYPE_SK_REUSEPORT, SEC_DEF("sk_reuseport/migrate", SK_REUSEPORT, BPF_SK_REUSEPORT_SELECT_OR_MIGRATE, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
BPF_SK_REUSEPORT_SELECT_OR_MIGRATE), SEC_DEF("sk_reuseport", SK_REUSEPORT, BPF_SK_REUSEPORT_SELECT, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
BPF_EAPROG_SEC("sk_reuseport", BPF_PROG_TYPE_SK_REUSEPORT, SEC_DEF("kprobe/", KPROBE, 0, SEC_NONE, attach_kprobe),
BPF_SK_REUSEPORT_SELECT), SEC_DEF("uprobe/", KPROBE, 0, SEC_NONE),
SEC_DEF("kprobe/", KPROBE, SEC_DEF("kretprobe/", KPROBE, 0, SEC_NONE, attach_kprobe),
.attach_fn = attach_kprobe), SEC_DEF("uretprobe/", KPROBE, 0, SEC_NONE),
BPF_PROG_SEC("uprobe/", BPF_PROG_TYPE_KPROBE), SEC_DEF("tc", SCHED_CLS, 0, SEC_NONE),
SEC_DEF("kretprobe/", KPROBE, SEC_DEF("classifier", SCHED_CLS, 0, SEC_NONE | SEC_SLOPPY_PFX),
.attach_fn = attach_kprobe), SEC_DEF("action", SCHED_ACT, 0, SEC_NONE | SEC_SLOPPY_PFX),
BPF_PROG_SEC("uretprobe/", BPF_PROG_TYPE_KPROBE), SEC_DEF("tracepoint/", TRACEPOINT, 0, SEC_NONE, attach_tp),
BPF_PROG_SEC("classifier", BPF_PROG_TYPE_SCHED_CLS), SEC_DEF("tp/", TRACEPOINT, 0, SEC_NONE, attach_tp),
BPF_PROG_SEC("action", BPF_PROG_TYPE_SCHED_ACT), SEC_DEF("raw_tracepoint/", RAW_TRACEPOINT, 0, SEC_NONE, attach_raw_tp),
SEC_DEF("tracepoint/", TRACEPOINT, SEC_DEF("raw_tp/", RAW_TRACEPOINT, 0, SEC_NONE, attach_raw_tp),
.attach_fn = attach_tp), SEC_DEF("tp_btf/", TRACING, BPF_TRACE_RAW_TP, SEC_ATTACH_BTF, attach_trace),
SEC_DEF("tp/", TRACEPOINT, SEC_DEF("fentry/", TRACING, BPF_TRACE_FENTRY, SEC_ATTACH_BTF, attach_trace),
.attach_fn = attach_tp), SEC_DEF("fmod_ret/", TRACING, BPF_MODIFY_RETURN, SEC_ATTACH_BTF, attach_trace),
SEC_DEF("raw_tracepoint/", RAW_TRACEPOINT, SEC_DEF("fexit/", TRACING, BPF_TRACE_FEXIT, SEC_ATTACH_BTF, attach_trace),
.attach_fn = attach_raw_tp), SEC_DEF("fentry.s/", TRACING, BPF_TRACE_FENTRY, SEC_ATTACH_BTF | SEC_SLEEPABLE, attach_trace),
SEC_DEF("raw_tp/", RAW_TRACEPOINT, SEC_DEF("fmod_ret.s/", TRACING, BPF_MODIFY_RETURN, SEC_ATTACH_BTF | SEC_SLEEPABLE, attach_trace),
.attach_fn = attach_raw_tp), SEC_DEF("fexit.s/", TRACING, BPF_TRACE_FEXIT, SEC_ATTACH_BTF | SEC_SLEEPABLE, attach_trace),
SEC_DEF("tp_btf/", TRACING, SEC_DEF("freplace/", EXT, 0, SEC_ATTACH_BTF, attach_trace),
.expected_attach_type = BPF_TRACE_RAW_TP, SEC_DEF("lsm/", LSM, BPF_LSM_MAC, SEC_ATTACH_BTF, attach_lsm),
.is_attach_btf = true, SEC_DEF("lsm.s/", LSM, BPF_LSM_MAC, SEC_ATTACH_BTF | SEC_SLEEPABLE, attach_lsm),
.attach_fn = attach_trace), SEC_DEF("iter/", TRACING, BPF_TRACE_ITER, SEC_ATTACH_BTF, attach_iter),
SEC_DEF("fentry/", TRACING, SEC_DEF("syscall", SYSCALL, 0, SEC_SLEEPABLE),
.expected_attach_type = BPF_TRACE_FENTRY, SEC_DEF("xdp_devmap/", XDP, BPF_XDP_DEVMAP, SEC_ATTACHABLE),
.is_attach_btf = true, SEC_DEF("xdp_cpumap/", XDP, BPF_XDP_CPUMAP, SEC_ATTACHABLE),
.attach_fn = attach_trace), SEC_DEF("xdp", XDP, BPF_XDP, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
SEC_DEF("fmod_ret/", TRACING, SEC_DEF("perf_event", PERF_EVENT, 0, SEC_NONE | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_MODIFY_RETURN, SEC_DEF("lwt_in", LWT_IN, 0, SEC_NONE | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("lwt_out", LWT_OUT, 0, SEC_NONE | SEC_SLOPPY_PFX),
.attach_fn = attach_trace), SEC_DEF("lwt_xmit", LWT_XMIT, 0, SEC_NONE | SEC_SLOPPY_PFX),
SEC_DEF("fexit/", TRACING, SEC_DEF("lwt_seg6local", LWT_SEG6LOCAL, 0, SEC_NONE | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_TRACE_FEXIT, SEC_DEF("cgroup_skb/ingress", CGROUP_SKB, BPF_CGROUP_INET_INGRESS, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("cgroup_skb/egress", CGROUP_SKB, BPF_CGROUP_INET_EGRESS, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.attach_fn = attach_trace), SEC_DEF("cgroup/skb", CGROUP_SKB, 0, SEC_NONE | SEC_SLOPPY_PFX),
SEC_DEF("fentry.s/", TRACING, SEC_DEF("cgroup/sock_create", CGROUP_SOCK, BPF_CGROUP_INET_SOCK_CREATE, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_TRACE_FENTRY, SEC_DEF("cgroup/sock_release", CGROUP_SOCK, BPF_CGROUP_INET_SOCK_RELEASE, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("cgroup/sock", CGROUP_SOCK, BPF_CGROUP_INET_SOCK_CREATE, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.is_sleepable = true, SEC_DEF("cgroup/post_bind4", CGROUP_SOCK, BPF_CGROUP_INET4_POST_BIND, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.attach_fn = attach_trace), SEC_DEF("cgroup/post_bind6", CGROUP_SOCK, BPF_CGROUP_INET6_POST_BIND, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
SEC_DEF("fmod_ret.s/", TRACING, SEC_DEF("cgroup/dev", CGROUP_DEVICE, BPF_CGROUP_DEVICE, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_MODIFY_RETURN, SEC_DEF("sockops", SOCK_OPS, BPF_CGROUP_SOCK_OPS, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("sk_skb/stream_parser", SK_SKB, BPF_SK_SKB_STREAM_PARSER, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.is_sleepable = true, SEC_DEF("sk_skb/stream_verdict",SK_SKB, BPF_SK_SKB_STREAM_VERDICT, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.attach_fn = attach_trace), SEC_DEF("sk_skb", SK_SKB, 0, SEC_NONE | SEC_SLOPPY_PFX),
SEC_DEF("fexit.s/", TRACING, SEC_DEF("sk_msg", SK_MSG, BPF_SK_MSG_VERDICT, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_TRACE_FEXIT, SEC_DEF("lirc_mode2", LIRC_MODE2, BPF_LIRC_MODE2, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("flow_dissector", FLOW_DISSECTOR, BPF_FLOW_DISSECTOR, SEC_ATTACHABLE_OPT | SEC_SLOPPY_PFX),
.is_sleepable = true, SEC_DEF("cgroup/bind4", CGROUP_SOCK_ADDR, BPF_CGROUP_INET4_BIND, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.attach_fn = attach_trace), SEC_DEF("cgroup/bind6", CGROUP_SOCK_ADDR, BPF_CGROUP_INET6_BIND, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
SEC_DEF("freplace/", EXT, SEC_DEF("cgroup/connect4", CGROUP_SOCK_ADDR, BPF_CGROUP_INET4_CONNECT, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("cgroup/connect6", CGROUP_SOCK_ADDR, BPF_CGROUP_INET6_CONNECT, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.attach_fn = attach_trace), SEC_DEF("cgroup/sendmsg4", CGROUP_SOCK_ADDR, BPF_CGROUP_UDP4_SENDMSG, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
SEC_DEF("lsm/", LSM, SEC_DEF("cgroup/sendmsg6", CGROUP_SOCK_ADDR, BPF_CGROUP_UDP6_SENDMSG, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("cgroup/recvmsg4", CGROUP_SOCK_ADDR, BPF_CGROUP_UDP4_RECVMSG, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_LSM_MAC, SEC_DEF("cgroup/recvmsg6", CGROUP_SOCK_ADDR, BPF_CGROUP_UDP6_RECVMSG, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.attach_fn = attach_lsm), SEC_DEF("cgroup/getpeername4", CGROUP_SOCK_ADDR, BPF_CGROUP_INET4_GETPEERNAME, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
SEC_DEF("lsm.s/", LSM, SEC_DEF("cgroup/getpeername6", CGROUP_SOCK_ADDR, BPF_CGROUP_INET6_GETPEERNAME, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.is_attach_btf = true, SEC_DEF("cgroup/getsockname4", CGROUP_SOCK_ADDR, BPF_CGROUP_INET4_GETSOCKNAME, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.is_sleepable = true, SEC_DEF("cgroup/getsockname6", CGROUP_SOCK_ADDR, BPF_CGROUP_INET6_GETSOCKNAME, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_LSM_MAC, SEC_DEF("cgroup/sysctl", CGROUP_SYSCTL, BPF_CGROUP_SYSCTL, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.attach_fn = attach_lsm), SEC_DEF("cgroup/getsockopt", CGROUP_SOCKOPT, BPF_CGROUP_GETSOCKOPT, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
SEC_DEF("iter/", TRACING, SEC_DEF("cgroup/setsockopt", CGROUP_SOCKOPT, BPF_CGROUP_SETSOCKOPT, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.expected_attach_type = BPF_TRACE_ITER, SEC_DEF("struct_ops+", STRUCT_OPS, 0, SEC_NONE),
.is_attach_btf = true, SEC_DEF("sk_lookup", SK_LOOKUP, BPF_SK_LOOKUP, SEC_ATTACHABLE | SEC_SLOPPY_PFX),
.attach_fn = attach_iter),
SEC_DEF("syscall", SYSCALL,
.is_sleepable = true),
BPF_EAPROG_SEC("xdp_devmap/", BPF_PROG_TYPE_XDP,
BPF_XDP_DEVMAP),
BPF_EAPROG_SEC("xdp_cpumap/", BPF_PROG_TYPE_XDP,
BPF_XDP_CPUMAP),
BPF_APROG_SEC("xdp", BPF_PROG_TYPE_XDP,
BPF_XDP),
BPF_PROG_SEC("perf_event", BPF_PROG_TYPE_PERF_EVENT),
BPF_PROG_SEC("lwt_in", BPF_PROG_TYPE_LWT_IN),
BPF_PROG_SEC("lwt_out", BPF_PROG_TYPE_LWT_OUT),
BPF_PROG_SEC("lwt_xmit", BPF_PROG_TYPE_LWT_XMIT),
BPF_PROG_SEC("lwt_seg6local", BPF_PROG_TYPE_LWT_SEG6LOCAL),
BPF_APROG_SEC("cgroup_skb/ingress", BPF_PROG_TYPE_CGROUP_SKB,
BPF_CGROUP_INET_INGRESS),
BPF_APROG_SEC("cgroup_skb/egress", BPF_PROG_TYPE_CGROUP_SKB,
BPF_CGROUP_INET_EGRESS),
BPF_APROG_COMPAT("cgroup/skb", BPF_PROG_TYPE_CGROUP_SKB),
BPF_EAPROG_SEC("cgroup/sock_create", BPF_PROG_TYPE_CGROUP_SOCK,
BPF_CGROUP_INET_SOCK_CREATE),
BPF_EAPROG_SEC("cgroup/sock_release", BPF_PROG_TYPE_CGROUP_SOCK,
BPF_CGROUP_INET_SOCK_RELEASE),
BPF_APROG_SEC("cgroup/sock", BPF_PROG_TYPE_CGROUP_SOCK,
BPF_CGROUP_INET_SOCK_CREATE),
BPF_EAPROG_SEC("cgroup/post_bind4", BPF_PROG_TYPE_CGROUP_SOCK,
BPF_CGROUP_INET4_POST_BIND),
BPF_EAPROG_SEC("cgroup/post_bind6", BPF_PROG_TYPE_CGROUP_SOCK,
BPF_CGROUP_INET6_POST_BIND),
BPF_APROG_SEC("cgroup/dev", BPF_PROG_TYPE_CGROUP_DEVICE,
BPF_CGROUP_DEVICE),
BPF_APROG_SEC("sockops", BPF_PROG_TYPE_SOCK_OPS,
BPF_CGROUP_SOCK_OPS),
BPF_APROG_SEC("sk_skb/stream_parser", BPF_PROG_TYPE_SK_SKB,
BPF_SK_SKB_STREAM_PARSER),
BPF_APROG_SEC("sk_skb/stream_verdict", BPF_PROG_TYPE_SK_SKB,
BPF_SK_SKB_STREAM_VERDICT),
BPF_APROG_COMPAT("sk_skb", BPF_PROG_TYPE_SK_SKB),
BPF_APROG_SEC("sk_msg", BPF_PROG_TYPE_SK_MSG,
BPF_SK_MSG_VERDICT),
BPF_APROG_SEC("lirc_mode2", BPF_PROG_TYPE_LIRC_MODE2,
BPF_LIRC_MODE2),
BPF_APROG_SEC("flow_dissector", BPF_PROG_TYPE_FLOW_DISSECTOR,
BPF_FLOW_DISSECTOR),
BPF_EAPROG_SEC("cgroup/bind4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET4_BIND),
BPF_EAPROG_SEC("cgroup/bind6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET6_BIND),
BPF_EAPROG_SEC("cgroup/connect4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET4_CONNECT),
BPF_EAPROG_SEC("cgroup/connect6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET6_CONNECT),
BPF_EAPROG_SEC("cgroup/sendmsg4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_UDP4_SENDMSG),
BPF_EAPROG_SEC("cgroup/sendmsg6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_UDP6_SENDMSG),
BPF_EAPROG_SEC("cgroup/recvmsg4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_UDP4_RECVMSG),
BPF_EAPROG_SEC("cgroup/recvmsg6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_UDP6_RECVMSG),
BPF_EAPROG_SEC("cgroup/getpeername4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET4_GETPEERNAME),
BPF_EAPROG_SEC("cgroup/getpeername6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET6_GETPEERNAME),
BPF_EAPROG_SEC("cgroup/getsockname4", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET4_GETSOCKNAME),
BPF_EAPROG_SEC("cgroup/getsockname6", BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
BPF_CGROUP_INET6_GETSOCKNAME),
BPF_EAPROG_SEC("cgroup/sysctl", BPF_PROG_TYPE_CGROUP_SYSCTL,
BPF_CGROUP_SYSCTL),
BPF_EAPROG_SEC("cgroup/getsockopt", BPF_PROG_TYPE_CGROUP_SOCKOPT,
BPF_CGROUP_GETSOCKOPT),
BPF_EAPROG_SEC("cgroup/setsockopt", BPF_PROG_TYPE_CGROUP_SOCKOPT,
BPF_CGROUP_SETSOCKOPT),
BPF_PROG_SEC("struct_ops", BPF_PROG_TYPE_STRUCT_OPS),
BPF_EAPROG_SEC("sk_lookup/", BPF_PROG_TYPE_SK_LOOKUP,
BPF_SK_LOOKUP),
}; };
#undef BPF_PROG_SEC_IMPL
#undef BPF_PROG_SEC
#undef BPF_APROG_SEC
#undef BPF_EAPROG_SEC
#undef BPF_APROG_COMPAT
#undef SEC_DEF
#define MAX_TYPE_NAME_SIZE 32 #define MAX_TYPE_NAME_SIZE 32
static const struct bpf_sec_def *find_sec_def(const char *sec_name) static const struct bpf_sec_def *find_sec_def(const char *sec_name)
{ {
int i, n = ARRAY_SIZE(section_defs); const struct bpf_sec_def *sec_def;
enum sec_def_flags sec_flags;
int i, n = ARRAY_SIZE(section_defs), len;
bool strict = libbpf_mode & LIBBPF_STRICT_SEC_NAME;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
if (strncmp(sec_name, sec_def = &section_defs[i];
section_defs[i].sec, section_defs[i].len)) sec_flags = sec_def->cookie;
len = strlen(sec_def->sec);
/* "type/" always has to have proper SEC("type/extras") form */
if (sec_def->sec[len - 1] == '/') {
if (str_has_pfx(sec_name, sec_def->sec))
return sec_def;
continue;
}
/* "type+" means it can be either exact SEC("type") or
* well-formed SEC("type/extras") with proper '/' separator
*/
if (sec_def->sec[len - 1] == '+') {
len--;
/* not even a prefix */
if (strncmp(sec_name, sec_def->sec, len) != 0)
continue;
/* exact match or has '/' separator */
if (sec_name[len] == '\0' || sec_name[len] == '/')
return sec_def;
continue;
}
/* SEC_SLOPPY_PFX definitions are allowed to be just prefix
* matches, unless strict section name mode
* (LIBBPF_STRICT_SEC_NAME) is enabled, in which case the
* match has to be exact.
*/
if ((sec_flags & SEC_SLOPPY_PFX) && !strict) {
if (str_has_pfx(sec_name, sec_def->sec))
return sec_def;
continue; continue;
return &section_defs[i]; }
/* Definitions not marked SEC_SLOPPY_PFX (e.g.,
* SEC("syscall")) are exact matches in both modes.
*/
if (strcmp(sec_name, sec_def->sec) == 0)
return sec_def;
} }
return NULL; return NULL;
} }
...@@ -8136,9 +8125,16 @@ static char *libbpf_get_type_names(bool attach_type) ...@@ -8136,9 +8125,16 @@ static char *libbpf_get_type_names(bool attach_type)
buf[0] = '\0'; buf[0] = '\0';
/* Forge string buf with all available names */ /* Forge string buf with all available names */
for (i = 0; i < ARRAY_SIZE(section_defs); i++) { for (i = 0; i < ARRAY_SIZE(section_defs); i++) {
if (attach_type && !section_defs[i].is_attachable) const struct bpf_sec_def *sec_def = &section_defs[i];
if (attach_type) {
if (sec_def->preload_fn != libbpf_preload_prog)
continue; continue;
if (!(sec_def->cookie & SEC_ATTACHABLE))
continue;
}
if (strlen(buf) + strlen(section_defs[i].sec) + 2 > len) { if (strlen(buf) + strlen(section_defs[i].sec) + 2 > len) {
free(buf); free(buf);
return NULL; return NULL;
...@@ -8461,20 +8457,13 @@ static int find_kernel_btf_id(struct bpf_object *obj, const char *attach_name, ...@@ -8461,20 +8457,13 @@ static int find_kernel_btf_id(struct bpf_object *obj, const char *attach_name,
return -ESRCH; return -ESRCH;
} }
static int libbpf_find_attach_btf_id(struct bpf_program *prog, int *btf_obj_fd, int *btf_type_id) static int libbpf_find_attach_btf_id(struct bpf_program *prog, const char *attach_name,
int *btf_obj_fd, int *btf_type_id)
{ {
enum bpf_attach_type attach_type = prog->expected_attach_type; enum bpf_attach_type attach_type = prog->expected_attach_type;
__u32 attach_prog_fd = prog->attach_prog_fd; __u32 attach_prog_fd = prog->attach_prog_fd;
const char *attach_name;
int err = 0; int err = 0;
if (!prog->sec_def || !prog->sec_def->is_attach_btf) {
pr_warn("failed to identify BTF ID based on ELF section name '%s'\n",
prog->sec_name);
return -ESRCH;
}
attach_name = prog->sec_name + prog->sec_def->len;
/* BPF program's BTF ID */ /* BPF program's BTF ID */
if (attach_prog_fd) { if (attach_prog_fd) {
err = libbpf_find_prog_btf_id(attach_name, attach_prog_fd); err = libbpf_find_prog_btf_id(attach_name, attach_prog_fd);
...@@ -8524,7 +8513,9 @@ int libbpf_attach_type_by_name(const char *name, ...@@ -8524,7 +8513,9 @@ int libbpf_attach_type_by_name(const char *name,
return libbpf_err(-EINVAL); return libbpf_err(-EINVAL);
} }
if (!sec_def->is_attachable) if (sec_def->preload_fn != libbpf_preload_prog)
return libbpf_err(-EINVAL);
if (!(sec_def->cookie & SEC_ATTACHABLE))
return libbpf_err(-EINVAL); return libbpf_err(-EINVAL);
*attach_type = sec_def->expected_attach_type; *attach_type = sec_def->expected_attach_type;
...@@ -9424,7 +9415,7 @@ struct bpf_link *bpf_program__attach_kprobe(const struct bpf_program *prog, ...@@ -9424,7 +9415,7 @@ struct bpf_link *bpf_program__attach_kprobe(const struct bpf_program *prog,
return bpf_program__attach_kprobe_opts(prog, func_name, &opts); return bpf_program__attach_kprobe_opts(prog, func_name, &opts);
} }
static struct bpf_link *attach_kprobe(const struct bpf_program *prog) static struct bpf_link *attach_kprobe(const struct bpf_program *prog, long cookie)
{ {
DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, opts); DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, opts);
unsigned long offset = 0; unsigned long offset = 0;
...@@ -9433,8 +9424,11 @@ static struct bpf_link *attach_kprobe(const struct bpf_program *prog) ...@@ -9433,8 +9424,11 @@ static struct bpf_link *attach_kprobe(const struct bpf_program *prog)
char *func; char *func;
int n, err; int n, err;
func_name = prog->sec_name + prog->sec_def->len; opts.retprobe = str_has_pfx(prog->sec_name, "kretprobe/");
opts.retprobe = strcmp(prog->sec_def->sec, "kretprobe/") == 0; if (opts.retprobe)
func_name = prog->sec_name + sizeof("kretprobe/") - 1;
else
func_name = prog->sec_name + sizeof("kprobe/") - 1;
n = sscanf(func_name, "%m[a-zA-Z0-9_.]+%li", &func, &offset); n = sscanf(func_name, "%m[a-zA-Z0-9_.]+%li", &func, &offset);
if (n < 1) { if (n < 1) {
...@@ -9707,7 +9701,7 @@ struct bpf_link *bpf_program__attach_tracepoint(const struct bpf_program *prog, ...@@ -9707,7 +9701,7 @@ struct bpf_link *bpf_program__attach_tracepoint(const struct bpf_program *prog,
return bpf_program__attach_tracepoint_opts(prog, tp_category, tp_name, NULL); return bpf_program__attach_tracepoint_opts(prog, tp_category, tp_name, NULL);
} }
static struct bpf_link *attach_tp(const struct bpf_program *prog) static struct bpf_link *attach_tp(const struct bpf_program *prog, long cookie)
{ {
char *sec_name, *tp_cat, *tp_name; char *sec_name, *tp_cat, *tp_name;
struct bpf_link *link; struct bpf_link *link;
...@@ -9716,8 +9710,11 @@ static struct bpf_link *attach_tp(const struct bpf_program *prog) ...@@ -9716,8 +9710,11 @@ static struct bpf_link *attach_tp(const struct bpf_program *prog)
if (!sec_name) if (!sec_name)
return libbpf_err_ptr(-ENOMEM); return libbpf_err_ptr(-ENOMEM);
/* extract "tp/<category>/<name>" */ /* extract "tp/<category>/<name>" or "tracepoint/<category>/<name>" */
tp_cat = sec_name + prog->sec_def->len; if (str_has_pfx(prog->sec_name, "tp/"))
tp_cat = sec_name + sizeof("tp/") - 1;
else
tp_cat = sec_name + sizeof("tracepoint/") - 1;
tp_name = strchr(tp_cat, '/'); tp_name = strchr(tp_cat, '/');
if (!tp_name) { if (!tp_name) {
free(sec_name); free(sec_name);
...@@ -9761,9 +9758,14 @@ struct bpf_link *bpf_program__attach_raw_tracepoint(const struct bpf_program *pr ...@@ -9761,9 +9758,14 @@ struct bpf_link *bpf_program__attach_raw_tracepoint(const struct bpf_program *pr
return link; return link;
} }
static struct bpf_link *attach_raw_tp(const struct bpf_program *prog) static struct bpf_link *attach_raw_tp(const struct bpf_program *prog, long cookie)
{ {
const char *tp_name = prog->sec_name + prog->sec_def->len; const char *tp_name;
if (str_has_pfx(prog->sec_name, "raw_tp/"))
tp_name = prog->sec_name + sizeof("raw_tp/") - 1;
else
tp_name = prog->sec_name + sizeof("raw_tracepoint/") - 1;
return bpf_program__attach_raw_tracepoint(prog, tp_name); return bpf_program__attach_raw_tracepoint(prog, tp_name);
} }
...@@ -9808,12 +9810,12 @@ struct bpf_link *bpf_program__attach_lsm(const struct bpf_program *prog) ...@@ -9808,12 +9810,12 @@ struct bpf_link *bpf_program__attach_lsm(const struct bpf_program *prog)
return bpf_program__attach_btf_id(prog); return bpf_program__attach_btf_id(prog);
} }
static struct bpf_link *attach_trace(const struct bpf_program *prog) static struct bpf_link *attach_trace(const struct bpf_program *prog, long cookie)
{ {
return bpf_program__attach_trace(prog); return bpf_program__attach_trace(prog);
} }
static struct bpf_link *attach_lsm(const struct bpf_program *prog) static struct bpf_link *attach_lsm(const struct bpf_program *prog, long cookie)
{ {
return bpf_program__attach_lsm(prog); return bpf_program__attach_lsm(prog);
} }
...@@ -9944,7 +9946,7 @@ bpf_program__attach_iter(const struct bpf_program *prog, ...@@ -9944,7 +9946,7 @@ bpf_program__attach_iter(const struct bpf_program *prog,
return link; return link;
} }
static struct bpf_link *attach_iter(const struct bpf_program *prog) static struct bpf_link *attach_iter(const struct bpf_program *prog, long cookie)
{ {
return bpf_program__attach_iter(prog, NULL); return bpf_program__attach_iter(prog, NULL);
} }
...@@ -9954,7 +9956,7 @@ struct bpf_link *bpf_program__attach(const struct bpf_program *prog) ...@@ -9954,7 +9956,7 @@ struct bpf_link *bpf_program__attach(const struct bpf_program *prog)
if (!prog->sec_def || !prog->sec_def->attach_fn) if (!prog->sec_def || !prog->sec_def->attach_fn)
return libbpf_err_ptr(-ESRCH); return libbpf_err_ptr(-ESRCH);
return prog->sec_def->attach_fn(prog); return prog->sec_def->attach_fn(prog, prog->sec_def->cookie);
} }
static int bpf_link__detach_struct_ops(struct bpf_link *link) static int bpf_link__detach_struct_ops(struct bpf_link *link)
......
...@@ -89,6 +89,13 @@ ...@@ -89,6 +89,13 @@
(offsetof(TYPE, FIELD) + sizeof(((TYPE *)0)->FIELD)) (offsetof(TYPE, FIELD) + sizeof(((TYPE *)0)->FIELD))
#endif #endif
/* Check whether a string `str` has prefix `pfx`, regardless if `pfx` is
* a string literal known at compilation time or char * pointer known only at
* runtime.
*/
#define str_has_pfx(str, pfx) \
(strncmp(str, pfx, __builtin_constant_p(pfx) ? sizeof(pfx) - 1 : strlen(pfx)) == 0)
/* Symbol versioning is different between static and shared library. /* Symbol versioning is different between static and shared library.
* Properly versioned symbols are needed for shared library, but * Properly versioned symbols are needed for shared library, but
* only the symbol of the new version is needed for static library. * only the symbol of the new version is needed for static library.
......
...@@ -46,6 +46,15 @@ enum libbpf_strict_mode { ...@@ -46,6 +46,15 @@ enum libbpf_strict_mode {
*/ */
LIBBPF_STRICT_DIRECT_ERRS = 0x02, LIBBPF_STRICT_DIRECT_ERRS = 0x02,
/*
* Enforce strict BPF program section (SEC()) names.
* E.g., while prefiously SEC("xdp_whatever") or SEC("perf_event_blah") were
* allowed, with LIBBPF_STRICT_SEC_PREFIX this will become
* unrecognized by libbpf and would have to be just SEC("xdp") and
* SEC("xdp") and SEC("perf_event").
*/
LIBBPF_STRICT_SEC_NAME = 0x04,
__LIBBPF_STRICT_LAST, __LIBBPF_STRICT_LAST,
}; };
......
...@@ -458,9 +458,9 @@ static int init_prog_array(struct bpf_object *obj, struct bpf_map *prog_array) ...@@ -458,9 +458,9 @@ static int init_prog_array(struct bpf_object *obj, struct bpf_map *prog_array)
return -1; return -1;
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "flow_dissector/%i", i); snprintf(prog_name, sizeof(prog_name), "flow_dissector_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (!prog) if (!prog)
return -1; return -1;
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
#include <test_progs.h> #include <test_progs.h>
static void toggle_object_autoload_progs(const struct bpf_object *obj, static void toggle_object_autoload_progs(const struct bpf_object *obj,
const char *title_load) const char *name_load)
{ {
struct bpf_program *prog; struct bpf_program *prog;
bpf_object__for_each_program(prog, obj) { bpf_object__for_each_program(prog, obj) {
const char *title = bpf_program__section_name(prog); const char *name = bpf_program__name(prog);
if (!strcmp(title_load, title)) if (!strcmp(name_load, name))
bpf_program__set_autoload(prog, true); bpf_program__set_autoload(prog, true);
else else
bpf_program__set_autoload(prog, false); bpf_program__set_autoload(prog, false);
...@@ -39,23 +39,19 @@ void test_reference_tracking(void) ...@@ -39,23 +39,19 @@ void test_reference_tracking(void)
goto cleanup; goto cleanup;
bpf_object__for_each_program(prog, obj_iter) { bpf_object__for_each_program(prog, obj_iter) {
const char *title; const char *name;
/* Ignore .text sections */ name = bpf_program__name(prog);
title = bpf_program__section_name(prog); if (!test__start_subtest(name))
if (strstr(title, ".text") != NULL)
continue;
if (!test__start_subtest(title))
continue; continue;
obj = bpf_object__open_file(file, &open_opts); obj = bpf_object__open_file(file, &open_opts);
if (!ASSERT_OK_PTR(obj, "obj_open_file")) if (!ASSERT_OK_PTR(obj, "obj_open_file"))
goto cleanup; goto cleanup;
toggle_object_autoload_progs(obj, title); toggle_object_autoload_progs(obj, name);
/* Expect verifier failure if test name has 'err' */ /* Expect verifier failure if test name has 'err' */
if (strstr(title, "err_") != NULL) { if (strncmp(name, "err_", sizeof("err_") - 1) == 0) {
libbpf_print_fn_t old_print_fn; libbpf_print_fn_t old_print_fn;
old_print_fn = libbpf_set_print(NULL); old_print_fn = libbpf_set_print(NULL);
...@@ -64,7 +60,8 @@ void test_reference_tracking(void) ...@@ -64,7 +60,8 @@ void test_reference_tracking(void)
} else { } else {
err = bpf_object__load(obj); err = bpf_object__load(obj);
} }
CHECK(err, title, "\n"); ASSERT_OK(err, name);
bpf_object__close(obj); bpf_object__close(obj);
obj = NULL; obj = NULL;
} }
......
...@@ -48,7 +48,7 @@ configure_stack(void) ...@@ -48,7 +48,7 @@ configure_stack(void)
return false; return false;
sprintf(tc_cmd, "%s %s %s %s", "tc filter add dev lo ingress bpf", sprintf(tc_cmd, "%s %s %s %s", "tc filter add dev lo ingress bpf",
"direct-action object-file ./test_sk_assign.o", "direct-action object-file ./test_sk_assign.o",
"section classifier/sk_assign_test", "section tc",
(env.verbosity < VERBOSE_VERY) ? " 2>/dev/null" : "verbose"); (env.verbosity < VERBOSE_VERY) ? " 2>/dev/null" : "verbose");
if (CHECK(system(tc_cmd), "BPF load failed;", if (CHECK(system(tc_cmd), "BPF load failed;",
"run with -vv for more info\n")) "run with -vv for more info\n"))
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <test_progs.h> #include <test_progs.h>
#include "cgroup_helpers.h" #include "cgroup_helpers.h"
static int prog_attach(struct bpf_object *obj, int cgroup_fd, const char *title) static int prog_attach(struct bpf_object *obj, int cgroup_fd, const char *title, const char *name)
{ {
enum bpf_attach_type attach_type; enum bpf_attach_type attach_type;
enum bpf_prog_type prog_type; enum bpf_prog_type prog_type;
...@@ -15,23 +15,23 @@ static int prog_attach(struct bpf_object *obj, int cgroup_fd, const char *title) ...@@ -15,23 +15,23 @@ static int prog_attach(struct bpf_object *obj, int cgroup_fd, const char *title)
return -1; return -1;
} }
prog = bpf_object__find_program_by_title(obj, title); prog = bpf_object__find_program_by_name(obj, name);
if (!prog) { if (!prog) {
log_err("Failed to find %s BPF program", title); log_err("Failed to find %s BPF program", name);
return -1; return -1;
} }
err = bpf_prog_attach(bpf_program__fd(prog), cgroup_fd, err = bpf_prog_attach(bpf_program__fd(prog), cgroup_fd,
attach_type, BPF_F_ALLOW_MULTI); attach_type, BPF_F_ALLOW_MULTI);
if (err) { if (err) {
log_err("Failed to attach %s BPF program", title); log_err("Failed to attach %s BPF program", name);
return -1; return -1;
} }
return 0; return 0;
} }
static int prog_detach(struct bpf_object *obj, int cgroup_fd, const char *title) static int prog_detach(struct bpf_object *obj, int cgroup_fd, const char *title, const char *name)
{ {
enum bpf_attach_type attach_type; enum bpf_attach_type attach_type;
enum bpf_prog_type prog_type; enum bpf_prog_type prog_type;
...@@ -42,7 +42,7 @@ static int prog_detach(struct bpf_object *obj, int cgroup_fd, const char *title) ...@@ -42,7 +42,7 @@ static int prog_detach(struct bpf_object *obj, int cgroup_fd, const char *title)
if (err) if (err)
return -1; return -1;
prog = bpf_object__find_program_by_title(obj, title); prog = bpf_object__find_program_by_name(obj, name);
if (!prog) if (!prog)
return -1; return -1;
...@@ -89,7 +89,7 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent, ...@@ -89,7 +89,7 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent,
* - child: 0x80 -> 0x90 * - child: 0x80 -> 0x90
*/ */
err = prog_attach(obj, cg_child, "cgroup/getsockopt/child"); err = prog_attach(obj, cg_child, "cgroup/getsockopt", "_getsockopt_child");
if (err) if (err)
goto detach; goto detach;
...@@ -113,7 +113,7 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent, ...@@ -113,7 +113,7 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent,
* - parent: 0x90 -> 0xA0 * - parent: 0x90 -> 0xA0
*/ */
err = prog_attach(obj, cg_parent, "cgroup/getsockopt/parent"); err = prog_attach(obj, cg_parent, "cgroup/getsockopt", "_getsockopt_parent");
if (err) if (err)
goto detach; goto detach;
...@@ -157,7 +157,7 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent, ...@@ -157,7 +157,7 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent,
* - parent: unexpected 0x40, EPERM * - parent: unexpected 0x40, EPERM
*/ */
err = prog_detach(obj, cg_child, "cgroup/getsockopt/child"); err = prog_detach(obj, cg_child, "cgroup/getsockopt", "_getsockopt_child");
if (err) { if (err) {
log_err("Failed to detach child program"); log_err("Failed to detach child program");
goto detach; goto detach;
...@@ -198,8 +198,8 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent, ...@@ -198,8 +198,8 @@ static int run_getsockopt_test(struct bpf_object *obj, int cg_parent,
} }
detach: detach:
prog_detach(obj, cg_child, "cgroup/getsockopt/child"); prog_detach(obj, cg_child, "cgroup/getsockopt", "_getsockopt_child");
prog_detach(obj, cg_parent, "cgroup/getsockopt/parent"); prog_detach(obj, cg_parent, "cgroup/getsockopt", "_getsockopt_parent");
return err; return err;
} }
...@@ -236,7 +236,7 @@ static int run_setsockopt_test(struct bpf_object *obj, int cg_parent, ...@@ -236,7 +236,7 @@ static int run_setsockopt_test(struct bpf_object *obj, int cg_parent,
/* Attach child program and make sure it adds 0x10. */ /* Attach child program and make sure it adds 0x10. */
err = prog_attach(obj, cg_child, "cgroup/setsockopt"); err = prog_attach(obj, cg_child, "cgroup/setsockopt", "_setsockopt");
if (err) if (err)
goto detach; goto detach;
...@@ -263,7 +263,7 @@ static int run_setsockopt_test(struct bpf_object *obj, int cg_parent, ...@@ -263,7 +263,7 @@ static int run_setsockopt_test(struct bpf_object *obj, int cg_parent,
/* Attach parent program and make sure it adds another 0x10. */ /* Attach parent program and make sure it adds another 0x10. */
err = prog_attach(obj, cg_parent, "cgroup/setsockopt"); err = prog_attach(obj, cg_parent, "cgroup/setsockopt", "_setsockopt");
if (err) if (err)
goto detach; goto detach;
...@@ -289,8 +289,8 @@ static int run_setsockopt_test(struct bpf_object *obj, int cg_parent, ...@@ -289,8 +289,8 @@ static int run_setsockopt_test(struct bpf_object *obj, int cg_parent,
} }
detach: detach:
prog_detach(obj, cg_child, "cgroup/setsockopt"); prog_detach(obj, cg_child, "cgroup/setsockopt", "_setsockopt");
prog_detach(obj, cg_parent, "cgroup/setsockopt"); prog_detach(obj, cg_parent, "cgroup/setsockopt", "_setsockopt");
return err; return err;
} }
......
...@@ -21,7 +21,7 @@ static void test_tailcall_1(void) ...@@ -21,7 +21,7 @@ static void test_tailcall_1(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -38,9 +38,9 @@ static void test_tailcall_1(void) ...@@ -38,9 +38,9 @@ static void test_tailcall_1(void)
goto out; goto out;
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -70,9 +70,9 @@ static void test_tailcall_1(void) ...@@ -70,9 +70,9 @@ static void test_tailcall_1(void)
err, errno, retval); err, errno, retval);
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -92,9 +92,9 @@ static void test_tailcall_1(void) ...@@ -92,9 +92,9 @@ static void test_tailcall_1(void)
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
j = bpf_map__def(prog_array)->max_entries - 1 - i; j = bpf_map__def(prog_array)->max_entries - 1 - i;
snprintf(prog_name, sizeof(prog_name), "classifier/%i", j); snprintf(prog_name, sizeof(prog_name), "classifier_%d", j);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -159,7 +159,7 @@ static void test_tailcall_2(void) ...@@ -159,7 +159,7 @@ static void test_tailcall_2(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -176,9 +176,9 @@ static void test_tailcall_2(void) ...@@ -176,9 +176,9 @@ static void test_tailcall_2(void)
goto out; goto out;
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -233,7 +233,7 @@ static void test_tailcall_count(const char *which) ...@@ -233,7 +233,7 @@ static void test_tailcall_count(const char *which)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -249,7 +249,7 @@ static void test_tailcall_count(const char *which) ...@@ -249,7 +249,7 @@ static void test_tailcall_count(const char *which)
if (CHECK_FAIL(map_fd < 0)) if (CHECK_FAIL(map_fd < 0))
goto out; goto out;
prog = bpf_object__find_program_by_title(obj, "classifier/0"); prog = bpf_object__find_program_by_name(obj, "classifier_0");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -329,7 +329,7 @@ static void test_tailcall_4(void) ...@@ -329,7 +329,7 @@ static void test_tailcall_4(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -354,9 +354,9 @@ static void test_tailcall_4(void) ...@@ -354,9 +354,9 @@ static void test_tailcall_4(void)
return; return;
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -417,7 +417,7 @@ static void test_tailcall_5(void) ...@@ -417,7 +417,7 @@ static void test_tailcall_5(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -442,9 +442,9 @@ static void test_tailcall_5(void) ...@@ -442,9 +442,9 @@ static void test_tailcall_5(void)
return; return;
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -503,7 +503,7 @@ static void test_tailcall_bpf2bpf_1(void) ...@@ -503,7 +503,7 @@ static void test_tailcall_bpf2bpf_1(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -521,9 +521,9 @@ static void test_tailcall_bpf2bpf_1(void) ...@@ -521,9 +521,9 @@ static void test_tailcall_bpf2bpf_1(void)
/* nop -> jmp */ /* nop -> jmp */
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -587,7 +587,7 @@ static void test_tailcall_bpf2bpf_2(void) ...@@ -587,7 +587,7 @@ static void test_tailcall_bpf2bpf_2(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -603,7 +603,7 @@ static void test_tailcall_bpf2bpf_2(void) ...@@ -603,7 +603,7 @@ static void test_tailcall_bpf2bpf_2(void)
if (CHECK_FAIL(map_fd < 0)) if (CHECK_FAIL(map_fd < 0))
goto out; goto out;
prog = bpf_object__find_program_by_title(obj, "classifier/0"); prog = bpf_object__find_program_by_name(obj, "classifier_0");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -665,7 +665,7 @@ static void test_tailcall_bpf2bpf_3(void) ...@@ -665,7 +665,7 @@ static void test_tailcall_bpf2bpf_3(void)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -682,9 +682,9 @@ static void test_tailcall_bpf2bpf_3(void) ...@@ -682,9 +682,9 @@ static void test_tailcall_bpf2bpf_3(void)
goto out; goto out;
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -762,7 +762,7 @@ static void test_tailcall_bpf2bpf_4(bool noise) ...@@ -762,7 +762,7 @@ static void test_tailcall_bpf2bpf_4(bool noise)
if (CHECK_FAIL(err)) if (CHECK_FAIL(err))
return; return;
prog = bpf_object__find_program_by_title(obj, "classifier"); prog = bpf_object__find_program_by_name(obj, "entry");
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
...@@ -779,9 +779,9 @@ static void test_tailcall_bpf2bpf_4(bool noise) ...@@ -779,9 +779,9 @@ static void test_tailcall_bpf2bpf_4(bool noise)
goto out; goto out;
for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) { for (i = 0; i < bpf_map__def(prog_array)->max_entries; i++) {
snprintf(prog_name, sizeof(prog_name), "classifier/%i", i); snprintf(prog_name, sizeof(prog_name), "classifier_%d", i);
prog = bpf_object__find_program_by_title(obj, prog_name); prog = bpf_object__find_program_by_name(obj, prog_name);
if (CHECK_FAIL(!prog)) if (CHECK_FAIL(!prog))
goto out; goto out;
......
...@@ -19,9 +19,8 @@ ...@@ -19,9 +19,8 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
int _version SEC("version") = 1;
#define PROG(F) PROG_(F, _##F) #define PROG(F) PROG_(F, _##F)
#define PROG_(NUM, NAME) SEC("flow_dissector/"#NUM) int bpf_func##NAME #define PROG_(NUM, NAME) SEC("flow_dissector") int flow_dissector_##NUM
/* These are the identifiers of the BPF programs that will be used in tail /* These are the identifiers of the BPF programs that will be used in tail
* calls. Name is limited to 16 characters, with the terminating character and * calls. Name is limited to 16 characters, with the terminating character and
......
...@@ -20,7 +20,7 @@ struct { ...@@ -20,7 +20,7 @@ struct {
__u32 invocations = 0; __u32 invocations = 0;
SEC("cgroup_skb/egress/1") SEC("cgroup_skb/egress")
int egress1(struct __sk_buff *skb) int egress1(struct __sk_buff *skb)
{ {
struct cgroup_value *ptr_cg_storage = struct cgroup_value *ptr_cg_storage =
...@@ -32,7 +32,7 @@ int egress1(struct __sk_buff *skb) ...@@ -32,7 +32,7 @@ int egress1(struct __sk_buff *skb)
return 1; return 1;
} }
SEC("cgroup_skb/egress/2") SEC("cgroup_skb/egress")
int egress2(struct __sk_buff *skb) int egress2(struct __sk_buff *skb)
{ {
struct cgroup_value *ptr_cg_storage = struct cgroup_value *ptr_cg_storage =
......
...@@ -20,7 +20,7 @@ struct { ...@@ -20,7 +20,7 @@ struct {
__u32 invocations = 0; __u32 invocations = 0;
SEC("cgroup_skb/egress/1") SEC("cgroup_skb/egress")
int egress1(struct __sk_buff *skb) int egress1(struct __sk_buff *skb)
{ {
struct cgroup_value *ptr_cg_storage = struct cgroup_value *ptr_cg_storage =
...@@ -32,7 +32,7 @@ int egress1(struct __sk_buff *skb) ...@@ -32,7 +32,7 @@ int egress1(struct __sk_buff *skb)
return 1; return 1;
} }
SEC("cgroup_skb/egress/2") SEC("cgroup_skb/egress")
int egress2(struct __sk_buff *skb) int egress2(struct __sk_buff *skb)
{ {
struct cgroup_value *ptr_cg_storage = struct cgroup_value *ptr_cg_storage =
......
...@@ -47,7 +47,7 @@ check_percpu_elem(struct bpf_map *map, __u32 *key, __u64 *val, ...@@ -47,7 +47,7 @@ check_percpu_elem(struct bpf_map *map, __u32 *key, __u64 *val,
u32 arraymap_output = 0; u32 arraymap_output = 0;
SEC("classifier") SEC("tc")
int test_pkt_access(struct __sk_buff *skb) int test_pkt_access(struct __sk_buff *skb)
{ {
struct callback_ctx data; struct callback_ctx data;
......
...@@ -78,7 +78,7 @@ int hashmap_output = 0; ...@@ -78,7 +78,7 @@ int hashmap_output = 0;
int hashmap_elems = 0; int hashmap_elems = 0;
int percpu_map_elems = 0; int percpu_map_elems = 0;
SEC("classifier") SEC("tc")
int test_pkt_access(struct __sk_buff *skb) int test_pkt_access(struct __sk_buff *skb)
{ {
struct callback_ctx data; struct callback_ctx data;
......
...@@ -8,7 +8,7 @@ extern int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym; ...@@ -8,7 +8,7 @@ extern int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym;
extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b, extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b,
__u32 c, __u64 d) __ksym; __u32 c, __u64 d) __ksym;
SEC("classifier") SEC("tc")
int kfunc_call_test2(struct __sk_buff *skb) int kfunc_call_test2(struct __sk_buff *skb)
{ {
struct bpf_sock *sk = skb->sk; struct bpf_sock *sk = skb->sk;
...@@ -23,7 +23,7 @@ int kfunc_call_test2(struct __sk_buff *skb) ...@@ -23,7 +23,7 @@ int kfunc_call_test2(struct __sk_buff *skb)
return bpf_kfunc_call_test2((struct sock *)sk, 1, 2); return bpf_kfunc_call_test2((struct sock *)sk, 1, 2);
} }
SEC("classifier") SEC("tc")
int kfunc_call_test1(struct __sk_buff *skb) int kfunc_call_test1(struct __sk_buff *skb)
{ {
struct bpf_sock *sk = skb->sk; struct bpf_sock *sk = skb->sk;
......
...@@ -33,7 +33,7 @@ int __noinline f1(struct __sk_buff *skb) ...@@ -33,7 +33,7 @@ int __noinline f1(struct __sk_buff *skb)
return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4); return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4);
} }
SEC("classifier") SEC("tc")
int kfunc_call_test1(struct __sk_buff *skb) int kfunc_call_test1(struct __sk_buff *skb)
{ {
return f1(skb); return f1(skb);
......
...@@ -25,7 +25,7 @@ static INLINE struct iphdr *get_iphdr(struct __sk_buff *skb) ...@@ -25,7 +25,7 @@ static INLINE struct iphdr *get_iphdr(struct __sk_buff *skb)
return ip; return ip;
} }
SEC("classifier/cls") SEC("tc")
int main_prog(struct __sk_buff *skb) int main_prog(struct __sk_buff *skb)
{ {
struct iphdr *ip = NULL; struct iphdr *ip = NULL;
......
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
__u32 _version SEC("version") = 1;
SEC("cgroup/getsockopt/child") SEC("cgroup/getsockopt")
int _getsockopt_child(struct bpf_sockopt *ctx) int _getsockopt_child(struct bpf_sockopt *ctx)
{ {
__u8 *optval_end = ctx->optval_end; __u8 *optval_end = ctx->optval_end;
...@@ -29,7 +28,7 @@ int _getsockopt_child(struct bpf_sockopt *ctx) ...@@ -29,7 +28,7 @@ int _getsockopt_child(struct bpf_sockopt *ctx)
return 1; return 1;
} }
SEC("cgroup/getsockopt/parent") SEC("cgroup/getsockopt")
int _getsockopt_parent(struct bpf_sockopt *ctx) int _getsockopt_parent(struct bpf_sockopt *ctx)
{ {
__u8 *optval_end = ctx->optval_end; __u8 *optval_end = ctx->optval_end;
......
...@@ -11,8 +11,8 @@ struct { ...@@ -11,8 +11,8 @@ struct {
} jmp_table SEC(".maps"); } jmp_table SEC(".maps");
#define TAIL_FUNC(x) \ #define TAIL_FUNC(x) \
SEC("classifier/" #x) \ SEC("tc") \
int bpf_func_##x(struct __sk_buff *skb) \ int classifier_##x(struct __sk_buff *skb) \
{ \ { \
return x; \ return x; \
} }
...@@ -20,7 +20,7 @@ TAIL_FUNC(0) ...@@ -20,7 +20,7 @@ TAIL_FUNC(0)
TAIL_FUNC(1) TAIL_FUNC(1)
TAIL_FUNC(2) TAIL_FUNC(2)
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
/* Multiple locations to make sure we patch /* Multiple locations to make sure we patch
...@@ -45,4 +45,3 @@ int entry(struct __sk_buff *skb) ...@@ -45,4 +45,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -10,41 +10,41 @@ struct { ...@@ -10,41 +10,41 @@ struct {
__uint(value_size, sizeof(__u32)); __uint(value_size, sizeof(__u32));
} jmp_table SEC(".maps"); } jmp_table SEC(".maps");
SEC("classifier/0") SEC("tc")
int bpf_func_0(struct __sk_buff *skb) int classifier_0(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 1); bpf_tail_call_static(skb, &jmp_table, 1);
return 0; return 0;
} }
SEC("classifier/1") SEC("tc")
int bpf_func_1(struct __sk_buff *skb) int classifier_1(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 2); bpf_tail_call_static(skb, &jmp_table, 2);
return 1; return 1;
} }
SEC("classifier/2") SEC("tc")
int bpf_func_2(struct __sk_buff *skb) int classifier_2(struct __sk_buff *skb)
{ {
return 2; return 2;
} }
SEC("classifier/3") SEC("tc")
int bpf_func_3(struct __sk_buff *skb) int classifier_3(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 4); bpf_tail_call_static(skb, &jmp_table, 4);
return 3; return 3;
} }
SEC("classifier/4") SEC("tc")
int bpf_func_4(struct __sk_buff *skb) int classifier_4(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 3); bpf_tail_call_static(skb, &jmp_table, 3);
return 4; return 4;
} }
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 0); bpf_tail_call_static(skb, &jmp_table, 0);
...@@ -56,4 +56,3 @@ int entry(struct __sk_buff *skb) ...@@ -56,4 +56,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -12,15 +12,15 @@ struct { ...@@ -12,15 +12,15 @@ struct {
int count = 0; int count = 0;
SEC("classifier/0") SEC("tc")
int bpf_func_0(struct __sk_buff *skb) int classifier_0(struct __sk_buff *skb)
{ {
count++; count++;
bpf_tail_call_static(skb, &jmp_table, 0); bpf_tail_call_static(skb, &jmp_table, 0);
return 1; return 1;
} }
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 0); bpf_tail_call_static(skb, &jmp_table, 0);
...@@ -28,4 +28,3 @@ int entry(struct __sk_buff *skb) ...@@ -28,4 +28,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -13,8 +13,8 @@ struct { ...@@ -13,8 +13,8 @@ struct {
int selector = 0; int selector = 0;
#define TAIL_FUNC(x) \ #define TAIL_FUNC(x) \
SEC("classifier/" #x) \ SEC("tc") \
int bpf_func_##x(struct __sk_buff *skb) \ int classifier_##x(struct __sk_buff *skb) \
{ \ { \
return x; \ return x; \
} }
...@@ -22,7 +22,7 @@ TAIL_FUNC(0) ...@@ -22,7 +22,7 @@ TAIL_FUNC(0)
TAIL_FUNC(1) TAIL_FUNC(1)
TAIL_FUNC(2) TAIL_FUNC(2)
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
bpf_tail_call(skb, &jmp_table, selector); bpf_tail_call(skb, &jmp_table, selector);
...@@ -30,4 +30,3 @@ int entry(struct __sk_buff *skb) ...@@ -30,4 +30,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -13,8 +13,8 @@ struct { ...@@ -13,8 +13,8 @@ struct {
int selector = 0; int selector = 0;
#define TAIL_FUNC(x) \ #define TAIL_FUNC(x) \
SEC("classifier/" #x) \ SEC("tc") \
int bpf_func_##x(struct __sk_buff *skb) \ int classifier_##x(struct __sk_buff *skb) \
{ \ { \
return x; \ return x; \
} }
...@@ -22,7 +22,7 @@ TAIL_FUNC(0) ...@@ -22,7 +22,7 @@ TAIL_FUNC(0)
TAIL_FUNC(1) TAIL_FUNC(1)
TAIL_FUNC(2) TAIL_FUNC(2)
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
int idx = 0; int idx = 0;
...@@ -37,4 +37,3 @@ int entry(struct __sk_buff *skb) ...@@ -37,4 +37,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -12,8 +12,8 @@ struct { ...@@ -12,8 +12,8 @@ struct {
int count, which; int count, which;
SEC("classifier/0") SEC("tc")
int bpf_func_0(struct __sk_buff *skb) int classifier_0(struct __sk_buff *skb)
{ {
count++; count++;
if (__builtin_constant_p(which)) if (__builtin_constant_p(which))
...@@ -22,7 +22,7 @@ int bpf_func_0(struct __sk_buff *skb) ...@@ -22,7 +22,7 @@ int bpf_func_0(struct __sk_buff *skb)
return 1; return 1;
} }
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
if (__builtin_constant_p(which)) if (__builtin_constant_p(which))
......
...@@ -10,8 +10,8 @@ struct { ...@@ -10,8 +10,8 @@ struct {
} jmp_table SEC(".maps"); } jmp_table SEC(".maps");
#define TAIL_FUNC(x) \ #define TAIL_FUNC(x) \
SEC("classifier/" #x) \ SEC("tc") \
int bpf_func_##x(struct __sk_buff *skb) \ int classifier_##x(struct __sk_buff *skb) \
{ \ { \
return x; \ return x; \
} }
...@@ -26,7 +26,7 @@ int subprog_tail(struct __sk_buff *skb) ...@@ -26,7 +26,7 @@ int subprog_tail(struct __sk_buff *skb)
return skb->len * 2; return skb->len * 2;
} }
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 1); bpf_tail_call_static(skb, &jmp_table, 1);
...@@ -35,4 +35,3 @@ int entry(struct __sk_buff *skb) ...@@ -35,4 +35,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -22,14 +22,14 @@ int subprog_tail(struct __sk_buff *skb) ...@@ -22,14 +22,14 @@ int subprog_tail(struct __sk_buff *skb)
int count = 0; int count = 0;
SEC("classifier/0") SEC("tc")
int bpf_func_0(struct __sk_buff *skb) int classifier_0(struct __sk_buff *skb)
{ {
count++; count++;
return subprog_tail(skb); return subprog_tail(skb);
} }
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
bpf_tail_call_static(skb, &jmp_table, 0); bpf_tail_call_static(skb, &jmp_table, 0);
...@@ -38,4 +38,3 @@ int entry(struct __sk_buff *skb) ...@@ -38,4 +38,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -33,23 +33,23 @@ int subprog_tail(struct __sk_buff *skb) ...@@ -33,23 +33,23 @@ int subprog_tail(struct __sk_buff *skb)
return skb->len * 2; return skb->len * 2;
} }
SEC("classifier/0") SEC("tc")
int bpf_func_0(struct __sk_buff *skb) int classifier_0(struct __sk_buff *skb)
{ {
volatile char arr[128] = {}; volatile char arr[128] = {};
return subprog_tail2(skb); return subprog_tail2(skb);
} }
SEC("classifier/1") SEC("tc")
int bpf_func_1(struct __sk_buff *skb) int classifier_1(struct __sk_buff *skb)
{ {
volatile char arr[128] = {}; volatile char arr[128] = {};
return skb->len * 3; return skb->len * 3;
} }
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
volatile char arr[128] = {}; volatile char arr[128] = {};
...@@ -58,4 +58,3 @@ int entry(struct __sk_buff *skb) ...@@ -58,4 +58,3 @@ int entry(struct __sk_buff *skb)
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -50,30 +50,29 @@ int subprog_tail(struct __sk_buff *skb) ...@@ -50,30 +50,29 @@ int subprog_tail(struct __sk_buff *skb)
return skb->len; return skb->len;
} }
SEC("classifier/1") SEC("tc")
int bpf_func_1(struct __sk_buff *skb) int classifier_1(struct __sk_buff *skb)
{ {
return subprog_tail_2(skb); return subprog_tail_2(skb);
} }
SEC("classifier/2") SEC("tc")
int bpf_func_2(struct __sk_buff *skb) int classifier_2(struct __sk_buff *skb)
{ {
count++; count++;
return subprog_tail_2(skb); return subprog_tail_2(skb);
} }
SEC("classifier/0") SEC("tc")
int bpf_func_0(struct __sk_buff *skb) int classifier_0(struct __sk_buff *skb)
{ {
return subprog_tail_1(skb); return subprog_tail_1(skb);
} }
SEC("classifier") SEC("tc")
int entry(struct __sk_buff *skb) int entry(struct __sk_buff *skb)
{ {
return subprog_tail(skb); return subprog_tail(skb);
} }
char __license[] SEC("license") = "GPL"; char __license[] SEC("license") = "GPL";
int _version SEC("version") = 1;
...@@ -145,7 +145,7 @@ static int handle_ip6_tcp(struct ipv6hdr *ip6h, struct __sk_buff *skb) ...@@ -145,7 +145,7 @@ static int handle_ip6_tcp(struct ipv6hdr *ip6h, struct __sk_buff *skb)
return TC_ACT_OK; return TC_ACT_OK;
} }
SEC("classifier/ingress") SEC("tc")
int cls_ingress(struct __sk_buff *skb) int cls_ingress(struct __sk_buff *skb)
{ {
struct ipv6hdr *ip6h; struct ipv6hdr *ip6h;
......
...@@ -6,14 +6,14 @@ ...@@ -6,14 +6,14 @@
int calls = 0; int calls = 0;
int alt_calls = 0; int alt_calls = 0;
SEC("cgroup_skb/egress1") SEC("cgroup_skb/egress")
int egress(struct __sk_buff *skb) int egress(struct __sk_buff *skb)
{ {
__sync_fetch_and_add(&calls, 1); __sync_fetch_and_add(&calls, 1);
return 1; return 1;
} }
SEC("cgroup_skb/egress2") SEC("cgroup_skb/egress")
int egress_alt(struct __sk_buff *skb) int egress_alt(struct __sk_buff *skb)
{ {
__sync_fetch_and_add(&alt_calls, 1); __sync_fetch_and_add(&alt_calls, 1);
......
...@@ -153,7 +153,7 @@ int xdp_input_len_exceed(struct xdp_md *ctx) ...@@ -153,7 +153,7 @@ int xdp_input_len_exceed(struct xdp_md *ctx)
return retval; return retval;
} }
SEC("classifier") SEC("tc")
int tc_use_helper(struct __sk_buff *ctx) int tc_use_helper(struct __sk_buff *ctx)
{ {
int retval = BPF_OK; /* Expected retval on successful test */ int retval = BPF_OK; /* Expected retval on successful test */
...@@ -172,7 +172,7 @@ int tc_use_helper(struct __sk_buff *ctx) ...@@ -172,7 +172,7 @@ int tc_use_helper(struct __sk_buff *ctx)
return retval; return retval;
} }
SEC("classifier") SEC("tc")
int tc_exceed_mtu(struct __sk_buff *ctx) int tc_exceed_mtu(struct __sk_buff *ctx)
{ {
__u32 ifindex = GLOBAL_USER_IFINDEX; __u32 ifindex = GLOBAL_USER_IFINDEX;
...@@ -196,7 +196,7 @@ int tc_exceed_mtu(struct __sk_buff *ctx) ...@@ -196,7 +196,7 @@ int tc_exceed_mtu(struct __sk_buff *ctx)
return retval; return retval;
} }
SEC("classifier") SEC("tc")
int tc_exceed_mtu_da(struct __sk_buff *ctx) int tc_exceed_mtu_da(struct __sk_buff *ctx)
{ {
/* SKB Direct-Access variant */ /* SKB Direct-Access variant */
...@@ -223,7 +223,7 @@ int tc_exceed_mtu_da(struct __sk_buff *ctx) ...@@ -223,7 +223,7 @@ int tc_exceed_mtu_da(struct __sk_buff *ctx)
return retval; return retval;
} }
SEC("classifier") SEC("tc")
int tc_minus_delta(struct __sk_buff *ctx) int tc_minus_delta(struct __sk_buff *ctx)
{ {
int retval = BPF_OK; /* Expected retval on successful test */ int retval = BPF_OK; /* Expected retval on successful test */
...@@ -245,7 +245,7 @@ int tc_minus_delta(struct __sk_buff *ctx) ...@@ -245,7 +245,7 @@ int tc_minus_delta(struct __sk_buff *ctx)
return retval; return retval;
} }
SEC("classifier") SEC("tc")
int tc_input_len(struct __sk_buff *ctx) int tc_input_len(struct __sk_buff *ctx)
{ {
int retval = BPF_OK; /* Expected retval on successful test */ int retval = BPF_OK; /* Expected retval on successful test */
...@@ -265,7 +265,7 @@ int tc_input_len(struct __sk_buff *ctx) ...@@ -265,7 +265,7 @@ int tc_input_len(struct __sk_buff *ctx)
return retval; return retval;
} }
SEC("classifier") SEC("tc")
int tc_input_len_exceed(struct __sk_buff *ctx) int tc_input_len_exceed(struct __sk_buff *ctx)
{ {
int retval = BPF_DROP; /* Fail */ int retval = BPF_DROP; /* Fail */
......
...@@ -928,7 +928,7 @@ static INLINING verdict_t process_ipv6(buf_t *pkt, metrics_t *metrics) ...@@ -928,7 +928,7 @@ static INLINING verdict_t process_ipv6(buf_t *pkt, metrics_t *metrics)
} }
} }
SEC("classifier/cls_redirect") SEC("tc")
int cls_redirect(struct __sk_buff *skb) int cls_redirect(struct __sk_buff *skb)
{ {
metrics_t *metrics = get_global_metrics(); metrics_t *metrics = get_global_metrics();
......
...@@ -68,7 +68,7 @@ static struct foo struct3 = { ...@@ -68,7 +68,7 @@ static struct foo struct3 = {
bpf_map_update_elem(&result_##map, &key, var, 0); \ bpf_map_update_elem(&result_##map, &key, var, 0); \
} while (0) } while (0)
SEC("classifier/static_data_load") SEC("tc")
int load_static_data(struct __sk_buff *skb) int load_static_data(struct __sk_buff *skb)
{ {
static const __u64 bar = ~0; static const __u64 bar = ~0;
......
...@@ -38,7 +38,7 @@ int f3(int val, struct __sk_buff *skb, int var) ...@@ -38,7 +38,7 @@ int f3(int val, struct __sk_buff *skb, int var)
return skb->ifindex * val * var; return skb->ifindex * val * var;
} }
SEC("classifier/test") SEC("tc")
int test_cls(struct __sk_buff *skb) int test_cls(struct __sk_buff *skb)
{ {
return f0(1, skb) + f1(skb) + f2(2, skb) + f3(3, skb, 4); return f0(1, skb) + f1(skb) + f2(2, skb) + f3(3, skb, 4);
......
...@@ -54,7 +54,7 @@ int f8(struct __sk_buff *skb) ...@@ -54,7 +54,7 @@ int f8(struct __sk_buff *skb)
} }
#endif #endif
SEC("classifier/test") SEC("tc")
int test_cls(struct __sk_buff *skb) int test_cls(struct __sk_buff *skb)
{ {
#ifndef NO_FN8 #ifndef NO_FN8
......
...@@ -24,7 +24,7 @@ int f3(int val, struct __sk_buff *skb) ...@@ -24,7 +24,7 @@ int f3(int val, struct __sk_buff *skb)
return skb->ifindex * val; return skb->ifindex * val;
} }
SEC("classifier/test") SEC("tc")
int test_cls(struct __sk_buff *skb) int test_cls(struct __sk_buff *skb)
{ {
return f1(skb) + f2(2, skb) + f3(3, skb); return f1(skb) + f2(2, skb) + f3(3, skb);
......
...@@ -24,7 +24,7 @@ int f3(int val, struct __sk_buff *skb) ...@@ -24,7 +24,7 @@ int f3(int val, struct __sk_buff *skb)
return skb->ifindex * val; return skb->ifindex * val;
} }
SEC("classifier/test") SEC("tc")
int test_cls(struct __sk_buff *skb) int test_cls(struct __sk_buff *skb)
{ {
return f1(skb) + f2(2, skb) + f3(3, skb); return f1(skb) + f2(2, skb) + f3(3, skb);
......
...@@ -10,7 +10,7 @@ void foo(struct __sk_buff *skb) ...@@ -10,7 +10,7 @@ void foo(struct __sk_buff *skb)
skb->tc_index = 0; skb->tc_index = 0;
} }
SEC("classifier/test") SEC("tc")
int test_cls(struct __sk_buff *skb) int test_cls(struct __sk_buff *skb)
{ {
foo(skb); foo(skb);
......
...@@ -23,7 +23,7 @@ struct { ...@@ -23,7 +23,7 @@ struct {
__uint(value_size, sizeof(__u32)); __uint(value_size, sizeof(__u32));
} mim_hash SEC(".maps"); } mim_hash SEC(".maps");
SEC("xdp_mimtest") SEC("xdp")
int xdp_mimtest0(struct xdp_md *ctx) int xdp_mimtest0(struct xdp_md *ctx)
{ {
int value = 123; int value = 123;
......
...@@ -293,7 +293,7 @@ static int handle_passive_estab(struct bpf_sock_ops *skops) ...@@ -293,7 +293,7 @@ static int handle_passive_estab(struct bpf_sock_ops *skops)
return check_active_hdr_in(skops); return check_active_hdr_in(skops);
} }
SEC("sockops/misc_estab") SEC("sockops")
int misc_estab(struct bpf_sock_ops *skops) int misc_estab(struct bpf_sock_ops *skops)
{ {
int true_val = 1; int true_val = 1;
......
...@@ -97,7 +97,7 @@ int test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off) ...@@ -97,7 +97,7 @@ int test_pkt_write_access_subprog(struct __sk_buff *skb, __u32 off)
return 0; return 0;
} }
SEC("classifier/test_pkt_access") SEC("tc")
int test_pkt_access(struct __sk_buff *skb) int test_pkt_access(struct __sk_buff *skb)
{ {
void *data_end = (void *)(long)skb->data_end; void *data_end = (void *)(long)skb->data_end;
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
#include <linux/pkt_cls.h> #include <linux/pkt_cls.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1;
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define TEST_FIELD(TYPE, FIELD, MASK) \ #define TEST_FIELD(TYPE, FIELD, MASK) \
{ \ { \
...@@ -27,7 +25,7 @@ int _version SEC("version") = 1; ...@@ -27,7 +25,7 @@ int _version SEC("version") = 1;
} }
#endif #endif
SEC("classifier/test_pkt_md_access") SEC("tc")
int test_pkt_md_access(struct __sk_buff *skb) int test_pkt_md_access(struct __sk_buff *skb)
{ {
TEST_FIELD(__u8, len, 0xFF); TEST_FIELD(__u8, len, 0xFF);
......
...@@ -36,7 +36,6 @@ struct { ...@@ -36,7 +36,6 @@ struct {
.pinning = PIN_GLOBAL_NS, .pinning = PIN_GLOBAL_NS,
}; };
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
/* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */ /* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */
...@@ -159,7 +158,7 @@ handle_tcp(struct __sk_buff *skb, struct bpf_sock_tuple *tuple, bool ipv4) ...@@ -159,7 +158,7 @@ handle_tcp(struct __sk_buff *skb, struct bpf_sock_tuple *tuple, bool ipv4)
return ret; return ret;
} }
SEC("classifier/sk_assign_test") SEC("tc")
int bpf_sk_assign_test(struct __sk_buff *skb) int bpf_sk_assign_test(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple *tuple, ln = {0}; struct bpf_sock_tuple *tuple, ln = {0};
......
...@@ -72,32 +72,32 @@ static const __u16 DST_PORT = 7007; /* Host byte order */ ...@@ -72,32 +72,32 @@ static const __u16 DST_PORT = 7007; /* Host byte order */
static const __u32 DST_IP4 = IP4(127, 0, 0, 1); static const __u32 DST_IP4 = IP4(127, 0, 0, 1);
static const __u32 DST_IP6[] = IP6(0xfd000000, 0x0, 0x0, 0x00000001); static const __u32 DST_IP6[] = IP6(0xfd000000, 0x0, 0x0, 0x00000001);
SEC("sk_lookup/lookup_pass") SEC("sk_lookup")
int lookup_pass(struct bpf_sk_lookup *ctx) int lookup_pass(struct bpf_sk_lookup *ctx)
{ {
return SK_PASS; return SK_PASS;
} }
SEC("sk_lookup/lookup_drop") SEC("sk_lookup")
int lookup_drop(struct bpf_sk_lookup *ctx) int lookup_drop(struct bpf_sk_lookup *ctx)
{ {
return SK_DROP; return SK_DROP;
} }
SEC("sk_reuseport/reuse_pass") SEC("sk_reuseport")
int reuseport_pass(struct sk_reuseport_md *ctx) int reuseport_pass(struct sk_reuseport_md *ctx)
{ {
return SK_PASS; return SK_PASS;
} }
SEC("sk_reuseport/reuse_drop") SEC("sk_reuseport")
int reuseport_drop(struct sk_reuseport_md *ctx) int reuseport_drop(struct sk_reuseport_md *ctx)
{ {
return SK_DROP; return SK_DROP;
} }
/* Redirect packets destined for port DST_PORT to socket at redir_map[0]. */ /* Redirect packets destined for port DST_PORT to socket at redir_map[0]. */
SEC("sk_lookup/redir_port") SEC("sk_lookup")
int redir_port(struct bpf_sk_lookup *ctx) int redir_port(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -116,7 +116,7 @@ int redir_port(struct bpf_sk_lookup *ctx) ...@@ -116,7 +116,7 @@ int redir_port(struct bpf_sk_lookup *ctx)
} }
/* Redirect packets destined for DST_IP4 address to socket at redir_map[0]. */ /* Redirect packets destined for DST_IP4 address to socket at redir_map[0]. */
SEC("sk_lookup/redir_ip4") SEC("sk_lookup")
int redir_ip4(struct bpf_sk_lookup *ctx) int redir_ip4(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -139,7 +139,7 @@ int redir_ip4(struct bpf_sk_lookup *ctx) ...@@ -139,7 +139,7 @@ int redir_ip4(struct bpf_sk_lookup *ctx)
} }
/* Redirect packets destined for DST_IP6 address to socket at redir_map[0]. */ /* Redirect packets destined for DST_IP6 address to socket at redir_map[0]. */
SEC("sk_lookup/redir_ip6") SEC("sk_lookup")
int redir_ip6(struct bpf_sk_lookup *ctx) int redir_ip6(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -164,7 +164,7 @@ int redir_ip6(struct bpf_sk_lookup *ctx) ...@@ -164,7 +164,7 @@ int redir_ip6(struct bpf_sk_lookup *ctx)
return err ? SK_DROP : SK_PASS; return err ? SK_DROP : SK_PASS;
} }
SEC("sk_lookup/select_sock_a") SEC("sk_lookup")
int select_sock_a(struct bpf_sk_lookup *ctx) int select_sock_a(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -179,7 +179,7 @@ int select_sock_a(struct bpf_sk_lookup *ctx) ...@@ -179,7 +179,7 @@ int select_sock_a(struct bpf_sk_lookup *ctx)
return err ? SK_DROP : SK_PASS; return err ? SK_DROP : SK_PASS;
} }
SEC("sk_lookup/select_sock_a_no_reuseport") SEC("sk_lookup")
int select_sock_a_no_reuseport(struct bpf_sk_lookup *ctx) int select_sock_a_no_reuseport(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -194,7 +194,7 @@ int select_sock_a_no_reuseport(struct bpf_sk_lookup *ctx) ...@@ -194,7 +194,7 @@ int select_sock_a_no_reuseport(struct bpf_sk_lookup *ctx)
return err ? SK_DROP : SK_PASS; return err ? SK_DROP : SK_PASS;
} }
SEC("sk_reuseport/select_sock_b") SEC("sk_reuseport")
int select_sock_b(struct sk_reuseport_md *ctx) int select_sock_b(struct sk_reuseport_md *ctx)
{ {
__u32 key = KEY_SERVER_B; __u32 key = KEY_SERVER_B;
...@@ -205,7 +205,7 @@ int select_sock_b(struct sk_reuseport_md *ctx) ...@@ -205,7 +205,7 @@ int select_sock_b(struct sk_reuseport_md *ctx)
} }
/* Check that bpf_sk_assign() returns -EEXIST if socket already selected. */ /* Check that bpf_sk_assign() returns -EEXIST if socket already selected. */
SEC("sk_lookup/sk_assign_eexist") SEC("sk_lookup")
int sk_assign_eexist(struct bpf_sk_lookup *ctx) int sk_assign_eexist(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -238,7 +238,7 @@ int sk_assign_eexist(struct bpf_sk_lookup *ctx) ...@@ -238,7 +238,7 @@ int sk_assign_eexist(struct bpf_sk_lookup *ctx)
} }
/* Check that bpf_sk_assign(BPF_SK_LOOKUP_F_REPLACE) can override selection. */ /* Check that bpf_sk_assign(BPF_SK_LOOKUP_F_REPLACE) can override selection. */
SEC("sk_lookup/sk_assign_replace_flag") SEC("sk_lookup")
int sk_assign_replace_flag(struct bpf_sk_lookup *ctx) int sk_assign_replace_flag(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -270,7 +270,7 @@ int sk_assign_replace_flag(struct bpf_sk_lookup *ctx) ...@@ -270,7 +270,7 @@ int sk_assign_replace_flag(struct bpf_sk_lookup *ctx)
} }
/* Check that bpf_sk_assign(sk=NULL) is accepted. */ /* Check that bpf_sk_assign(sk=NULL) is accepted. */
SEC("sk_lookup/sk_assign_null") SEC("sk_lookup")
int sk_assign_null(struct bpf_sk_lookup *ctx) int sk_assign_null(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk = NULL; struct bpf_sock *sk = NULL;
...@@ -313,7 +313,7 @@ int sk_assign_null(struct bpf_sk_lookup *ctx) ...@@ -313,7 +313,7 @@ int sk_assign_null(struct bpf_sk_lookup *ctx)
} }
/* Check that selected sk is accessible through context. */ /* Check that selected sk is accessible through context. */
SEC("sk_lookup/access_ctx_sk") SEC("sk_lookup")
int access_ctx_sk(struct bpf_sk_lookup *ctx) int access_ctx_sk(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk1 = NULL, *sk2 = NULL; struct bpf_sock *sk1 = NULL, *sk2 = NULL;
...@@ -379,7 +379,7 @@ int access_ctx_sk(struct bpf_sk_lookup *ctx) ...@@ -379,7 +379,7 @@ int access_ctx_sk(struct bpf_sk_lookup *ctx)
* are not covered because they give bogus results, that is the * are not covered because they give bogus results, that is the
* verifier ignores the offset. * verifier ignores the offset.
*/ */
SEC("sk_lookup/ctx_narrow_access") SEC("sk_lookup")
int ctx_narrow_access(struct bpf_sk_lookup *ctx) int ctx_narrow_access(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -553,7 +553,7 @@ int ctx_narrow_access(struct bpf_sk_lookup *ctx) ...@@ -553,7 +553,7 @@ int ctx_narrow_access(struct bpf_sk_lookup *ctx)
} }
/* Check that sk_assign rejects SERVER_A socket with -ESOCKNOSUPPORT */ /* Check that sk_assign rejects SERVER_A socket with -ESOCKNOSUPPORT */
SEC("sk_lookup/sk_assign_esocknosupport") SEC("sk_lookup")
int sk_assign_esocknosupport(struct bpf_sk_lookup *ctx) int sk_assign_esocknosupport(struct bpf_sk_lookup *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -578,28 +578,28 @@ int sk_assign_esocknosupport(struct bpf_sk_lookup *ctx) ...@@ -578,28 +578,28 @@ int sk_assign_esocknosupport(struct bpf_sk_lookup *ctx)
return ret; return ret;
} }
SEC("sk_lookup/multi_prog_pass1") SEC("sk_lookup")
int multi_prog_pass1(struct bpf_sk_lookup *ctx) int multi_prog_pass1(struct bpf_sk_lookup *ctx)
{ {
bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY); bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY);
return SK_PASS; return SK_PASS;
} }
SEC("sk_lookup/multi_prog_pass2") SEC("sk_lookup")
int multi_prog_pass2(struct bpf_sk_lookup *ctx) int multi_prog_pass2(struct bpf_sk_lookup *ctx)
{ {
bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY); bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY);
return SK_PASS; return SK_PASS;
} }
SEC("sk_lookup/multi_prog_drop1") SEC("sk_lookup")
int multi_prog_drop1(struct bpf_sk_lookup *ctx) int multi_prog_drop1(struct bpf_sk_lookup *ctx)
{ {
bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY); bpf_map_update_elem(&run_map, &KEY_PROG1, &PROG_DONE, BPF_ANY);
return SK_DROP; return SK_DROP;
} }
SEC("sk_lookup/multi_prog_drop2") SEC("sk_lookup")
int multi_prog_drop2(struct bpf_sk_lookup *ctx) int multi_prog_drop2(struct bpf_sk_lookup *ctx)
{ {
bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY); bpf_map_update_elem(&run_map, &KEY_PROG2, &PROG_DONE, BPF_ANY);
...@@ -623,7 +623,7 @@ static __always_inline int select_server_a(struct bpf_sk_lookup *ctx) ...@@ -623,7 +623,7 @@ static __always_inline int select_server_a(struct bpf_sk_lookup *ctx)
return SK_PASS; return SK_PASS;
} }
SEC("sk_lookup/multi_prog_redir1") SEC("sk_lookup")
int multi_prog_redir1(struct bpf_sk_lookup *ctx) int multi_prog_redir1(struct bpf_sk_lookup *ctx)
{ {
int ret; int ret;
...@@ -633,7 +633,7 @@ int multi_prog_redir1(struct bpf_sk_lookup *ctx) ...@@ -633,7 +633,7 @@ int multi_prog_redir1(struct bpf_sk_lookup *ctx)
return SK_PASS; return SK_PASS;
} }
SEC("sk_lookup/multi_prog_redir2") SEC("sk_lookup")
int multi_prog_redir2(struct bpf_sk_lookup *ctx) int multi_prog_redir2(struct bpf_sk_lookup *ctx)
{ {
int ret; int ret;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
#include <bpf/bpf_endian.h> #include <bpf/bpf_endian.h>
int _version SEC("version") = 1;
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
/* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */ /* Fill 'tuple' with L3 info, and attempt to find L4. On fail, return NULL. */
...@@ -53,8 +52,8 @@ static struct bpf_sock_tuple *get_tuple(void *data, __u64 nh_off, ...@@ -53,8 +52,8 @@ static struct bpf_sock_tuple *get_tuple(void *data, __u64 nh_off,
return result; return result;
} }
SEC("classifier/sk_lookup_success") SEC("tc")
int bpf_sk_lookup_test0(struct __sk_buff *skb) int sk_lookup_success(struct __sk_buff *skb)
{ {
void *data_end = (void *)(long)skb->data_end; void *data_end = (void *)(long)skb->data_end;
void *data = (void *)(long)skb->data; void *data = (void *)(long)skb->data;
...@@ -79,8 +78,8 @@ int bpf_sk_lookup_test0(struct __sk_buff *skb) ...@@ -79,8 +78,8 @@ int bpf_sk_lookup_test0(struct __sk_buff *skb)
return sk ? TC_ACT_OK : TC_ACT_UNSPEC; return sk ? TC_ACT_OK : TC_ACT_UNSPEC;
} }
SEC("classifier/sk_lookup_success_simple") SEC("tc")
int bpf_sk_lookup_test1(struct __sk_buff *skb) int sk_lookup_success_simple(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple tuple = {}; struct bpf_sock_tuple tuple = {};
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -91,8 +90,8 @@ int bpf_sk_lookup_test1(struct __sk_buff *skb) ...@@ -91,8 +90,8 @@ int bpf_sk_lookup_test1(struct __sk_buff *skb)
return 0; return 0;
} }
SEC("classifier/err_use_after_free") SEC("tc")
int bpf_sk_lookup_uaf(struct __sk_buff *skb) int err_use_after_free(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple tuple = {}; struct bpf_sock_tuple tuple = {};
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -106,8 +105,8 @@ int bpf_sk_lookup_uaf(struct __sk_buff *skb) ...@@ -106,8 +105,8 @@ int bpf_sk_lookup_uaf(struct __sk_buff *skb)
return family; return family;
} }
SEC("classifier/err_modify_sk_pointer") SEC("tc")
int bpf_sk_lookup_modptr(struct __sk_buff *skb) int err_modify_sk_pointer(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple tuple = {}; struct bpf_sock_tuple tuple = {};
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -121,8 +120,8 @@ int bpf_sk_lookup_modptr(struct __sk_buff *skb) ...@@ -121,8 +120,8 @@ int bpf_sk_lookup_modptr(struct __sk_buff *skb)
return 0; return 0;
} }
SEC("classifier/err_modify_sk_or_null_pointer") SEC("tc")
int bpf_sk_lookup_modptr_or_null(struct __sk_buff *skb) int err_modify_sk_or_null_pointer(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple tuple = {}; struct bpf_sock_tuple tuple = {};
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -135,8 +134,8 @@ int bpf_sk_lookup_modptr_or_null(struct __sk_buff *skb) ...@@ -135,8 +134,8 @@ int bpf_sk_lookup_modptr_or_null(struct __sk_buff *skb)
return 0; return 0;
} }
SEC("classifier/err_no_release") SEC("tc")
int bpf_sk_lookup_test2(struct __sk_buff *skb) int err_no_release(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple tuple = {}; struct bpf_sock_tuple tuple = {};
...@@ -144,8 +143,8 @@ int bpf_sk_lookup_test2(struct __sk_buff *skb) ...@@ -144,8 +143,8 @@ int bpf_sk_lookup_test2(struct __sk_buff *skb)
return 0; return 0;
} }
SEC("classifier/err_release_twice") SEC("tc")
int bpf_sk_lookup_test3(struct __sk_buff *skb) int err_release_twice(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple tuple = {}; struct bpf_sock_tuple tuple = {};
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -156,8 +155,8 @@ int bpf_sk_lookup_test3(struct __sk_buff *skb) ...@@ -156,8 +155,8 @@ int bpf_sk_lookup_test3(struct __sk_buff *skb)
return 0; return 0;
} }
SEC("classifier/err_release_unchecked") SEC("tc")
int bpf_sk_lookup_test4(struct __sk_buff *skb) int err_release_unchecked(struct __sk_buff *skb)
{ {
struct bpf_sock_tuple tuple = {}; struct bpf_sock_tuple tuple = {};
struct bpf_sock *sk; struct bpf_sock *sk;
...@@ -173,8 +172,8 @@ void lookup_no_release(struct __sk_buff *skb) ...@@ -173,8 +172,8 @@ void lookup_no_release(struct __sk_buff *skb)
bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0); bpf_sk_lookup_tcp(skb, &tuple, sizeof(tuple), BPF_F_CURRENT_NETNS, 0);
} }
SEC("classifier/err_no_release_subcall") SEC("tc")
int bpf_sk_lookup_test5(struct __sk_buff *skb) int err_no_release_subcall(struct __sk_buff *skb)
{ {
lookup_no_release(skb); lookup_no_release(skb);
return 0; return 0;
......
...@@ -14,7 +14,7 @@ struct { ...@@ -14,7 +14,7 @@ struct {
char _license[] SEC("license") = "GPL"; char _license[] SEC("license") = "GPL";
SEC("classifier/test_skb_helpers") SEC("tc")
int test_skb_helpers(struct __sk_buff *skb) int test_skb_helpers(struct __sk_buff *skb)
{ {
struct task_struct *task; struct task_struct *task;
......
...@@ -56,7 +56,7 @@ int prog_stream_verdict(struct __sk_buff *skb) ...@@ -56,7 +56,7 @@ int prog_stream_verdict(struct __sk_buff *skb)
return verdict; return verdict;
} }
SEC("sk_skb/skb_verdict") SEC("sk_skb")
int prog_skb_verdict(struct __sk_buff *skb) int prog_skb_verdict(struct __sk_buff *skb)
{ {
unsigned int *count; unsigned int *count;
......
...@@ -9,7 +9,7 @@ struct { ...@@ -9,7 +9,7 @@ struct {
__type(value, __u64); __type(value, __u64);
} sock_map SEC(".maps"); } sock_map SEC(".maps");
SEC("sk_skb/skb_verdict") SEC("sk_skb")
int prog_skb_verdict(struct __sk_buff *skb) int prog_skb_verdict(struct __sk_buff *skb)
{ {
return SK_DROP; return SK_DROP;
......
...@@ -24,7 +24,7 @@ struct { ...@@ -24,7 +24,7 @@ struct {
__type(value, __u64); __type(value, __u64);
} dst_sock_hash SEC(".maps"); } dst_sock_hash SEC(".maps");
SEC("classifier/copy_sock_map") SEC("tc")
int copy_sock_map(void *ctx) int copy_sock_map(void *ctx)
{ {
struct bpf_sock *sk; struct bpf_sock *sk;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
/* Dummy prog to test TC-BPF API */ /* Dummy prog to test TC-BPF API */
SEC("classifier") SEC("tc")
int cls(struct __sk_buff *skb) int cls(struct __sk_buff *skb)
{ {
return 0; return 0;
......
...@@ -70,7 +70,7 @@ static __always_inline bool is_remote_ep_v6(struct __sk_buff *skb, ...@@ -70,7 +70,7 @@ static __always_inline bool is_remote_ep_v6(struct __sk_buff *skb,
return v6_equal(ip6h->daddr, addr); return v6_equal(ip6h->daddr, addr);
} }
SEC("classifier/chk_egress") SEC("tc")
int tc_chk(struct __sk_buff *skb) int tc_chk(struct __sk_buff *skb)
{ {
void *data_end = ctx_ptr(skb->data_end); void *data_end = ctx_ptr(skb->data_end);
...@@ -83,7 +83,7 @@ int tc_chk(struct __sk_buff *skb) ...@@ -83,7 +83,7 @@ int tc_chk(struct __sk_buff *skb)
return !raw[0] && !raw[1] && !raw[2] ? TC_ACT_SHOT : TC_ACT_OK; return !raw[0] && !raw[1] && !raw[2] ? TC_ACT_SHOT : TC_ACT_OK;
} }
SEC("classifier/dst_ingress") SEC("tc")
int tc_dst(struct __sk_buff *skb) int tc_dst(struct __sk_buff *skb)
{ {
__u8 zero[ETH_ALEN * 2]; __u8 zero[ETH_ALEN * 2];
...@@ -108,7 +108,7 @@ int tc_dst(struct __sk_buff *skb) ...@@ -108,7 +108,7 @@ int tc_dst(struct __sk_buff *skb)
return bpf_redirect_neigh(IFINDEX_SRC, NULL, 0, 0); return bpf_redirect_neigh(IFINDEX_SRC, NULL, 0, 0);
} }
SEC("classifier/src_ingress") SEC("tc")
int tc_src(struct __sk_buff *skb) int tc_src(struct __sk_buff *skb)
{ {
__u8 zero[ETH_ALEN * 2]; __u8 zero[ETH_ALEN * 2];
......
...@@ -75,7 +75,7 @@ static __always_inline int fill_fib_params_v6(struct __sk_buff *skb, ...@@ -75,7 +75,7 @@ static __always_inline int fill_fib_params_v6(struct __sk_buff *skb,
return 0; return 0;
} }
SEC("classifier/chk_egress") SEC("tc")
int tc_chk(struct __sk_buff *skb) int tc_chk(struct __sk_buff *skb)
{ {
void *data_end = ctx_ptr(skb->data_end); void *data_end = ctx_ptr(skb->data_end);
...@@ -143,13 +143,13 @@ static __always_inline int tc_redir(struct __sk_buff *skb) ...@@ -143,13 +143,13 @@ static __always_inline int tc_redir(struct __sk_buff *skb)
/* these are identical, but keep them separate for compatibility with the /* these are identical, but keep them separate for compatibility with the
* section names expected by test_tc_redirect.sh * section names expected by test_tc_redirect.sh
*/ */
SEC("classifier/dst_ingress") SEC("tc")
int tc_dst(struct __sk_buff *skb) int tc_dst(struct __sk_buff *skb)
{ {
return tc_redir(skb); return tc_redir(skb);
} }
SEC("classifier/src_ingress") SEC("tc")
int tc_src(struct __sk_buff *skb) int tc_src(struct __sk_buff *skb)
{ {
return tc_redir(skb); return tc_redir(skb);
......
...@@ -16,31 +16,31 @@ volatile const __u32 IFINDEX_DST; ...@@ -16,31 +16,31 @@ volatile const __u32 IFINDEX_DST;
static const __u8 src_mac[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55}; static const __u8 src_mac[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};
static const __u8 dst_mac[] = {0x00, 0x22, 0x33, 0x44, 0x55, 0x66}; static const __u8 dst_mac[] = {0x00, 0x22, 0x33, 0x44, 0x55, 0x66};
SEC("classifier/chk_egress") SEC("tc")
int tc_chk(struct __sk_buff *skb) int tc_chk(struct __sk_buff *skb)
{ {
return TC_ACT_SHOT; return TC_ACT_SHOT;
} }
SEC("classifier/dst_ingress") SEC("tc")
int tc_dst(struct __sk_buff *skb) int tc_dst(struct __sk_buff *skb)
{ {
return bpf_redirect_peer(IFINDEX_SRC, 0); return bpf_redirect_peer(IFINDEX_SRC, 0);
} }
SEC("classifier/src_ingress") SEC("tc")
int tc_src(struct __sk_buff *skb) int tc_src(struct __sk_buff *skb)
{ {
return bpf_redirect_peer(IFINDEX_DST, 0); return bpf_redirect_peer(IFINDEX_DST, 0);
} }
SEC("classifier/dst_ingress_l3") SEC("tc")
int tc_dst_l3(struct __sk_buff *skb) int tc_dst_l3(struct __sk_buff *skb)
{ {
return bpf_redirect(IFINDEX_SRC, 0); return bpf_redirect(IFINDEX_SRC, 0);
} }
SEC("classifier/src_ingress_l3") SEC("tc")
int tc_src_l3(struct __sk_buff *skb) int tc_src_l3(struct __sk_buff *skb)
{ {
__u16 proto = skb->protocol; __u16 proto = skb->protocol;
......
...@@ -148,7 +148,7 @@ static __always_inline void check_syncookie(void *ctx, void *data, ...@@ -148,7 +148,7 @@ static __always_inline void check_syncookie(void *ctx, void *data,
bpf_sk_release(sk); bpf_sk_release(sk);
} }
SEC("clsact/check_syncookie") SEC("tc")
int check_syncookie_clsact(struct __sk_buff *skb) int check_syncookie_clsact(struct __sk_buff *skb)
{ {
check_syncookie(skb, (void *)(long)skb->data, check_syncookie(skb, (void *)(long)skb->data,
...@@ -156,7 +156,7 @@ int check_syncookie_clsact(struct __sk_buff *skb) ...@@ -156,7 +156,7 @@ int check_syncookie_clsact(struct __sk_buff *skb)
return TC_ACT_OK; return TC_ACT_OK;
} }
SEC("xdp/check_syncookie") SEC("xdp")
int check_syncookie_xdp(struct xdp_md *ctx) int check_syncookie_xdp(struct xdp_md *ctx)
{ {
check_syncookie(ctx, (void *)(long)ctx->data, check_syncookie(ctx, (void *)(long)ctx->data,
......
...@@ -594,7 +594,7 @@ static int handle_parse_hdr(struct bpf_sock_ops *skops) ...@@ -594,7 +594,7 @@ static int handle_parse_hdr(struct bpf_sock_ops *skops)
return CG_OK; return CG_OK;
} }
SEC("sockops/estab") SEC("sockops")
int estab(struct bpf_sock_ops *skops) int estab(struct bpf_sock_ops *skops)
{ {
int true_val = 1; int true_val = 1;
......
...@@ -210,7 +210,7 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) ...@@ -210,7 +210,7 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp)
return XDP_TX; return XDP_TX;
} }
SEC("xdp_tx_iptunnel") SEC("xdp")
int _xdp_tx_iptunnel(struct xdp_md *xdp) int _xdp_tx_iptunnel(struct xdp_md *xdp)
{ {
void *data_end = (void *)(long)xdp->data_end; void *data_end = (void *)(long)xdp->data_end;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
SEC("xdp_adjust_tail_grow") SEC("xdp")
int _xdp_adjust_tail_grow(struct xdp_md *xdp) int _xdp_adjust_tail_grow(struct xdp_md *xdp)
{ {
void *data_end = (void *)(long)xdp->data_end; void *data_end = (void *)(long)xdp->data_end;
......
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
int _version SEC("version") = 1; SEC("xdp")
SEC("xdp_adjust_tail_shrink")
int _xdp_adjust_tail_shrink(struct xdp_md *xdp) int _xdp_adjust_tail_shrink(struct xdp_md *xdp)
{ {
void *data_end = (void *)(long)xdp->data_end; void *data_end = (void *)(long)xdp->data_end;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
SEC("xdp_dm_log") SEC("xdp")
int xdpdm_devlog(struct xdp_md *ctx) int xdpdm_devlog(struct xdp_md *ctx)
{ {
char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n"; char fmt[] = "devmap redirect: dev %u -> dev %u len %u\n";
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
char LICENSE[] SEC("license") = "GPL"; char LICENSE[] SEC("license") = "GPL";
SEC("xdp/handler") SEC("xdp")
int xdp_handler(struct xdp_md *xdp) int xdp_handler(struct xdp_md *xdp)
{ {
return 0; return 0;
......
...@@ -206,7 +206,7 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp) ...@@ -206,7 +206,7 @@ static __always_inline int handle_ipv6(struct xdp_md *xdp)
return XDP_TX; return XDP_TX;
} }
SEC("xdp_tx_iptunnel") SEC("xdp")
int _xdp_tx_iptunnel(struct xdp_md *xdp) int _xdp_tx_iptunnel(struct xdp_md *xdp)
{ {
void *data_end = (void *)(long)xdp->data_end; void *data_end = (void *)(long)xdp->data_end;
......
...@@ -797,7 +797,7 @@ static int process_packet(void *data, __u64 off, void *data_end, ...@@ -797,7 +797,7 @@ static int process_packet(void *data, __u64 off, void *data_end,
return XDP_DROP; return XDP_DROP;
} }
SEC("xdp-test-v4") SEC("xdp")
int balancer_ingress_v4(struct xdp_md *ctx) int balancer_ingress_v4(struct xdp_md *ctx)
{ {
void *data = (void *)(long)ctx->data; void *data = (void *)(long)ctx->data;
...@@ -816,7 +816,7 @@ int balancer_ingress_v4(struct xdp_md *ctx) ...@@ -816,7 +816,7 @@ int balancer_ingress_v4(struct xdp_md *ctx)
return XDP_DROP; return XDP_DROP;
} }
SEC("xdp-test-v6") SEC("xdp")
int balancer_ingress_v6(struct xdp_md *ctx) int balancer_ingress_v6(struct xdp_md *ctx)
{ {
void *data = (void *)(long)ctx->data; void *data = (void *)(long)ctx->data;
......
...@@ -12,13 +12,13 @@ struct { ...@@ -12,13 +12,13 @@ struct {
__uint(max_entries, 4); __uint(max_entries, 4);
} cpu_map SEC(".maps"); } cpu_map SEC(".maps");
SEC("xdp_redir") SEC("xdp")
int xdp_redir_prog(struct xdp_md *ctx) int xdp_redir_prog(struct xdp_md *ctx)
{ {
return bpf_redirect_map(&cpu_map, 1, 0); return bpf_redirect_map(&cpu_map, 1, 0);
} }
SEC("xdp_dummy") SEC("xdp")
int xdp_dummy_prog(struct xdp_md *ctx) int xdp_dummy_prog(struct xdp_md *ctx)
{ {
return XDP_PASS; return XDP_PASS;
......
...@@ -9,7 +9,7 @@ struct { ...@@ -9,7 +9,7 @@ struct {
__uint(max_entries, 4); __uint(max_entries, 4);
} dm_ports SEC(".maps"); } dm_ports SEC(".maps");
SEC("xdp_redir") SEC("xdp")
int xdp_redir_prog(struct xdp_md *ctx) int xdp_redir_prog(struct xdp_md *ctx)
{ {
return bpf_redirect_map(&dm_ports, 1, 0); return bpf_redirect_map(&dm_ports, 1, 0);
...@@ -18,7 +18,7 @@ int xdp_redir_prog(struct xdp_md *ctx) ...@@ -18,7 +18,7 @@ int xdp_redir_prog(struct xdp_md *ctx)
/* invalid program on DEVMAP entry; /* invalid program on DEVMAP entry;
* SEC name means expected attach type not set * SEC name means expected attach type not set
*/ */
SEC("xdp_dummy") SEC("xdp")
int xdp_dummy_prog(struct xdp_md *ctx) int xdp_dummy_prog(struct xdp_md *ctx)
{ {
return XDP_PASS; return XDP_PASS;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include <linux/bpf.h> #include <linux/bpf.h>
#include <bpf/bpf_helpers.h> #include <bpf/bpf_helpers.h>
SEC("xdp_dummy") SEC("xdp")
int xdp_dummy_prog(struct xdp_md *ctx) int xdp_dummy_prog(struct xdp_md *ctx)
{ {
return XDP_PASS; return XDP_PASS;
......
...@@ -34,7 +34,7 @@ struct { ...@@ -34,7 +34,7 @@ struct {
__uint(max_entries, 128); __uint(max_entries, 128);
} mac_map SEC(".maps"); } mac_map SEC(".maps");
SEC("xdp_redirect_map_multi") SEC("xdp")
int xdp_redirect_map_multi_prog(struct xdp_md *ctx) int xdp_redirect_map_multi_prog(struct xdp_md *ctx)
{ {
void *data_end = (void *)(long)ctx->data_end; void *data_end = (void *)(long)ctx->data_end;
...@@ -63,7 +63,7 @@ int xdp_redirect_map_multi_prog(struct xdp_md *ctx) ...@@ -63,7 +63,7 @@ int xdp_redirect_map_multi_prog(struct xdp_md *ctx)
} }
/* The following 2 progs are for 2nd devmap prog testing */ /* The following 2 progs are for 2nd devmap prog testing */
SEC("xdp_redirect_map_ingress") SEC("xdp")
int xdp_redirect_map_all_prog(struct xdp_md *ctx) int xdp_redirect_map_all_prog(struct xdp_md *ctx)
{ {
return bpf_redirect_map(&map_egress, 0, return bpf_redirect_map(&map_egress, 0,
......
...@@ -86,7 +86,7 @@ static __always_inline int icmp_check(struct xdp_md *ctx, int type) ...@@ -86,7 +86,7 @@ static __always_inline int icmp_check(struct xdp_md *ctx, int type)
return XDP_TX; return XDP_TX;
} }
SEC("xdpclient") SEC("xdp")
int xdping_client(struct xdp_md *ctx) int xdping_client(struct xdp_md *ctx)
{ {
void *data_end = (void *)(long)ctx->data_end; void *data_end = (void *)(long)ctx->data_end;
...@@ -150,7 +150,7 @@ int xdping_client(struct xdp_md *ctx) ...@@ -150,7 +150,7 @@ int xdping_client(struct xdp_md *ctx)
return XDP_TX; return XDP_TX;
} }
SEC("xdpserver") SEC("xdp")
int xdping_server(struct xdp_md *ctx) int xdping_server(struct xdp_md *ctx)
{ {
void *data_end = (void *)(long)ctx->data_end; void *data_end = (void *)(long)ctx->data_end;
......
...@@ -76,8 +76,8 @@ DIR=$(dirname $0) ...@@ -76,8 +76,8 @@ DIR=$(dirname $0)
TEST_IF=lo TEST_IF=lo
MAX_PING_TRIES=5 MAX_PING_TRIES=5
BPF_PROG_OBJ="${DIR}/test_tcp_check_syncookie_kern.o" BPF_PROG_OBJ="${DIR}/test_tcp_check_syncookie_kern.o"
CLSACT_SECTION="clsact/check_syncookie" CLSACT_SECTION="tc"
XDP_SECTION="xdp/check_syncookie" XDP_SECTION="xdp"
BPF_PROG_ID=0 BPF_PROG_ID=0
PROG="${DIR}/test_tcp_check_syncookie_user" PROG="${DIR}/test_tcp_check_syncookie_user"
......
...@@ -52,8 +52,8 @@ test_xdp_redirect() ...@@ -52,8 +52,8 @@ test_xdp_redirect()
return 0 return 0
fi fi
ip -n ns1 link set veth11 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null ip -n ns1 link set veth11 $xdpmode obj xdp_dummy.o sec xdp &> /dev/null
ip -n ns2 link set veth22 $xdpmode obj xdp_dummy.o sec xdp_dummy &> /dev/null ip -n ns2 link set veth22 $xdpmode obj xdp_dummy.o sec xdp &> /dev/null
ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null
ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null
......
...@@ -88,7 +88,7 @@ setup_ns() ...@@ -88,7 +88,7 @@ setup_ns()
# Add a neigh entry for IPv4 ping test # Add a neigh entry for IPv4 ping test
ip -n ns$i neigh add 192.0.2.253 lladdr 00:00:00:00:00:01 dev veth0 ip -n ns$i neigh add 192.0.2.253 lladdr 00:00:00:00:00:01 dev veth0
ip -n ns$i link set veth0 $mode obj \ ip -n ns$i link set veth0 $mode obj \
xdp_dummy.o sec xdp_dummy &> /dev/null || \ xdp_dummy.o sec xdp &> /dev/null || \
{ test_fail "Unable to load dummy xdp" && exit 1; } { test_fail "Unable to load dummy xdp" && exit 1; }
IFACES="$IFACES veth$i" IFACES="$IFACES veth$i"
veth_mac[$i]=$(ip link show veth$i | awk '/link\/ether/ {print $2}') veth_mac[$i]=$(ip link show veth$i | awk '/link\/ether/ {print $2}')
......
...@@ -107,9 +107,9 @@ ip link set dev veth1 xdp pinned $BPF_DIR/progs/redirect_map_0 ...@@ -107,9 +107,9 @@ ip link set dev veth1 xdp pinned $BPF_DIR/progs/redirect_map_0
ip link set dev veth2 xdp pinned $BPF_DIR/progs/redirect_map_1 ip link set dev veth2 xdp pinned $BPF_DIR/progs/redirect_map_1
ip link set dev veth3 xdp pinned $BPF_DIR/progs/redirect_map_2 ip link set dev veth3 xdp pinned $BPF_DIR/progs/redirect_map_2
ip -n ns1 link set dev veth11 xdp obj xdp_dummy.o sec xdp_dummy ip -n ns1 link set dev veth11 xdp obj xdp_dummy.o sec xdp
ip -n ns2 link set dev veth22 xdp obj xdp_tx.o sec xdp ip -n ns2 link set dev veth22 xdp obj xdp_tx.o sec xdp
ip -n ns3 link set dev veth33 xdp obj xdp_dummy.o sec xdp_dummy ip -n ns3 link set dev veth33 xdp obj xdp_dummy.o sec xdp
trap cleanup EXIT trap cleanup EXIT
......
...@@ -178,9 +178,8 @@ int main(int argc, char **argv) ...@@ -178,9 +178,8 @@ int main(int argc, char **argv)
return 1; return 1;
} }
main_prog = bpf_object__find_program_by_title(obj, main_prog = bpf_object__find_program_by_name(obj,
server ? "xdpserver" : server ? "xdping_server" : "xdping_client");
"xdpclient");
if (main_prog) if (main_prog)
prog_fd = bpf_program__fd(main_prog); prog_fd = bpf_program__fd(main_prog);
if (!main_prog || prog_fd < 0) { if (!main_prog || prog_fd < 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