Commit 6e43b286 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by Andrii Nakryiko

libbpf: Cleanup the layering between CORE and bpf_program.

CO-RE processing functions don't need to know 'struct bpf_program' details.
Cleanup the layering to eventually be able to move CO-RE logic into a separate file.
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210721000822.40958-2-alexei.starovoitov@gmail.com
parent 2b7e9f25
...@@ -5611,7 +5611,7 @@ static int bpf_core_spec_match(struct bpf_core_spec *local_spec, ...@@ -5611,7 +5611,7 @@ static int bpf_core_spec_match(struct bpf_core_spec *local_spec,
return 1; return 1;
} }
static int bpf_core_calc_field_relo(const struct bpf_program *prog, static int bpf_core_calc_field_relo(const char *prog_name,
const struct bpf_core_relo *relo, const struct bpf_core_relo *relo,
const struct bpf_core_spec *spec, const struct bpf_core_spec *spec,
__u32 *val, __u32 *field_sz, __u32 *type_id, __u32 *val, __u32 *field_sz, __u32 *type_id,
...@@ -5655,7 +5655,7 @@ static int bpf_core_calc_field_relo(const struct bpf_program *prog, ...@@ -5655,7 +5655,7 @@ static int bpf_core_calc_field_relo(const struct bpf_program *prog,
*val = sz; *val = sz;
} else { } else {
pr_warn("prog '%s': relo %d at insn #%d can't be applied to array access\n", pr_warn("prog '%s': relo %d at insn #%d can't be applied to array access\n",
prog->name, relo->kind, relo->insn_off / 8); prog_name, relo->kind, relo->insn_off / 8);
return -EINVAL; return -EINVAL;
} }
if (validate) if (validate)
...@@ -5677,7 +5677,7 @@ static int bpf_core_calc_field_relo(const struct bpf_program *prog, ...@@ -5677,7 +5677,7 @@ static int bpf_core_calc_field_relo(const struct bpf_program *prog,
if (byte_sz >= 8) { if (byte_sz >= 8) {
/* bitfield can't be read with 64-bit read */ /* bitfield can't be read with 64-bit read */
pr_warn("prog '%s': relo %d at insn #%d can't be satisfied for bitfield\n", pr_warn("prog '%s': relo %d at insn #%d can't be satisfied for bitfield\n",
prog->name, relo->kind, relo->insn_off / 8); prog_name, relo->kind, relo->insn_off / 8);
return -E2BIG; return -E2BIG;
} }
byte_sz *= 2; byte_sz *= 2;
...@@ -5827,7 +5827,7 @@ struct bpf_core_relo_res ...@@ -5827,7 +5827,7 @@ struct bpf_core_relo_res
* with each other. Otherwise, libbpf will refuse to proceed due to ambiguity. * with each other. Otherwise, libbpf will refuse to proceed due to ambiguity.
* If instruction has to be poisoned, *poison will be set to true. * If instruction has to be poisoned, *poison will be set to true.
*/ */
static int bpf_core_calc_relo(const struct bpf_program *prog, static int bpf_core_calc_relo(const char *prog_name,
const struct bpf_core_relo *relo, const struct bpf_core_relo *relo,
int relo_idx, int relo_idx,
const struct bpf_core_spec *local_spec, const struct bpf_core_spec *local_spec,
...@@ -5845,10 +5845,10 @@ static int bpf_core_calc_relo(const struct bpf_program *prog, ...@@ -5845,10 +5845,10 @@ static int bpf_core_calc_relo(const struct bpf_program *prog,
res->orig_type_id = res->new_type_id = 0; res->orig_type_id = res->new_type_id = 0;
if (core_relo_is_field_based(relo->kind)) { if (core_relo_is_field_based(relo->kind)) {
err = bpf_core_calc_field_relo(prog, relo, local_spec, err = bpf_core_calc_field_relo(prog_name, relo, local_spec,
&res->orig_val, &res->orig_sz, &res->orig_val, &res->orig_sz,
&res->orig_type_id, &res->validate); &res->orig_type_id, &res->validate);
err = err ?: bpf_core_calc_field_relo(prog, relo, targ_spec, err = err ?: bpf_core_calc_field_relo(prog_name, relo, targ_spec,
&res->new_val, &res->new_sz, &res->new_val, &res->new_sz,
&res->new_type_id, NULL); &res->new_type_id, NULL);
if (err) if (err)
...@@ -5906,7 +5906,7 @@ static int bpf_core_calc_relo(const struct bpf_program *prog, ...@@ -5906,7 +5906,7 @@ static int bpf_core_calc_relo(const struct bpf_program *prog,
} else if (err == -EOPNOTSUPP) { } else if (err == -EOPNOTSUPP) {
/* EOPNOTSUPP means unknown/unsupported relocation */ /* EOPNOTSUPP means unknown/unsupported relocation */
pr_warn("prog '%s': relo #%d: unrecognized CO-RE relocation %s (%d) at insn #%d\n", pr_warn("prog '%s': relo #%d: unrecognized CO-RE relocation %s (%d) at insn #%d\n",
prog->name, relo_idx, core_relo_kind_str(relo->kind), prog_name, relo_idx, core_relo_kind_str(relo->kind),
relo->kind, relo->insn_off / 8); relo->kind, relo->insn_off / 8);
} }
...@@ -5917,11 +5917,11 @@ static int bpf_core_calc_relo(const struct bpf_program *prog, ...@@ -5917,11 +5917,11 @@ static int bpf_core_calc_relo(const struct bpf_program *prog,
* Turn instruction for which CO_RE relocation failed into invalid one with * Turn instruction for which CO_RE relocation failed into invalid one with
* distinct signature. * distinct signature.
*/ */
static void bpf_core_poison_insn(struct bpf_program *prog, int relo_idx, static void bpf_core_poison_insn(const char *prog_name, int relo_idx,
int insn_idx, struct bpf_insn *insn) int insn_idx, struct bpf_insn *insn)
{ {
pr_debug("prog '%s': relo #%d: substituting insn #%d w/ invalid insn\n", pr_debug("prog '%s': relo #%d: substituting insn #%d w/ invalid insn\n",
prog->name, relo_idx, insn_idx); prog_name, relo_idx, insn_idx);
insn->code = BPF_JMP | BPF_CALL; insn->code = BPF_JMP | BPF_CALL;
insn->dst_reg = 0; insn->dst_reg = 0;
insn->src_reg = 0; insn->src_reg = 0;
...@@ -5977,6 +5977,7 @@ static int bpf_core_patch_insn(struct bpf_program *prog, ...@@ -5977,6 +5977,7 @@ static int bpf_core_patch_insn(struct bpf_program *prog,
int relo_idx, int relo_idx,
const struct bpf_core_relo_res *res) const struct bpf_core_relo_res *res)
{ {
const char *prog_name = prog->name;
__u32 orig_val, new_val; __u32 orig_val, new_val;
struct bpf_insn *insn; struct bpf_insn *insn;
int insn_idx; int insn_idx;
...@@ -5999,8 +6000,8 @@ static int bpf_core_patch_insn(struct bpf_program *prog, ...@@ -5999,8 +6000,8 @@ static int bpf_core_patch_insn(struct bpf_program *prog,
* verifier about "unknown opcode 00" * verifier about "unknown opcode 00"
*/ */
if (is_ldimm64_insn(insn)) if (is_ldimm64_insn(insn))
bpf_core_poison_insn(prog, relo_idx, insn_idx + 1, insn + 1); bpf_core_poison_insn(prog_name, relo_idx, insn_idx + 1, insn + 1);
bpf_core_poison_insn(prog, relo_idx, insn_idx, insn); bpf_core_poison_insn(prog_name, relo_idx, insn_idx, insn);
return 0; return 0;
} }
...@@ -6014,14 +6015,14 @@ static int bpf_core_patch_insn(struct bpf_program *prog, ...@@ -6014,14 +6015,14 @@ static int bpf_core_patch_insn(struct bpf_program *prog,
return -EINVAL; return -EINVAL;
if (res->validate && insn->imm != orig_val) { if (res->validate && insn->imm != orig_val) {
pr_warn("prog '%s': relo #%d: unexpected insn #%d (ALU/ALU64) value: got %u, exp %u -> %u\n", pr_warn("prog '%s': relo #%d: unexpected insn #%d (ALU/ALU64) value: got %u, exp %u -> %u\n",
prog->name, relo_idx, prog_name, relo_idx,
insn_idx, insn->imm, orig_val, new_val); insn_idx, insn->imm, orig_val, new_val);
return -EINVAL; return -EINVAL;
} }
orig_val = insn->imm; orig_val = insn->imm;
insn->imm = new_val; insn->imm = new_val;
pr_debug("prog '%s': relo #%d: patched insn #%d (ALU/ALU64) imm %u -> %u\n", pr_debug("prog '%s': relo #%d: patched insn #%d (ALU/ALU64) imm %u -> %u\n",
prog->name, relo_idx, insn_idx, prog_name, relo_idx, insn_idx,
orig_val, new_val); orig_val, new_val);
break; break;
case BPF_LDX: case BPF_LDX:
...@@ -6029,25 +6030,25 @@ static int bpf_core_patch_insn(struct bpf_program *prog, ...@@ -6029,25 +6030,25 @@ static int bpf_core_patch_insn(struct bpf_program *prog,
case BPF_STX: case BPF_STX:
if (res->validate && insn->off != orig_val) { if (res->validate && insn->off != orig_val) {
pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDX/ST/STX) value: got %u, exp %u -> %u\n", pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDX/ST/STX) value: got %u, exp %u -> %u\n",
prog->name, relo_idx, insn_idx, insn->off, orig_val, new_val); prog_name, relo_idx, insn_idx, insn->off, orig_val, new_val);
return -EINVAL; return -EINVAL;
} }
if (new_val > SHRT_MAX) { if (new_val > SHRT_MAX) {
pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) value too big: %u\n", pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) value too big: %u\n",
prog->name, relo_idx, insn_idx, new_val); prog_name, relo_idx, insn_idx, new_val);
return -ERANGE; return -ERANGE;
} }
if (res->fail_memsz_adjust) { if (res->fail_memsz_adjust) {
pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) accesses field incorrectly. " pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) accesses field incorrectly. "
"Make sure you are accessing pointers, unsigned integers, or fields of matching type and size.\n", "Make sure you are accessing pointers, unsigned integers, or fields of matching type and size.\n",
prog->name, relo_idx, insn_idx); prog_name, relo_idx, insn_idx);
goto poison; goto poison;
} }
orig_val = insn->off; orig_val = insn->off;
insn->off = new_val; insn->off = new_val;
pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) off %u -> %u\n", pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) off %u -> %u\n",
prog->name, relo_idx, insn_idx, orig_val, new_val); prog_name, relo_idx, insn_idx, orig_val, new_val);
if (res->new_sz != res->orig_sz) { if (res->new_sz != res->orig_sz) {
int insn_bytes_sz, insn_bpf_sz; int insn_bytes_sz, insn_bpf_sz;
...@@ -6055,20 +6056,20 @@ static int bpf_core_patch_insn(struct bpf_program *prog, ...@@ -6055,20 +6056,20 @@ static int bpf_core_patch_insn(struct bpf_program *prog,
insn_bytes_sz = insn_bpf_size_to_bytes(insn); insn_bytes_sz = insn_bpf_size_to_bytes(insn);
if (insn_bytes_sz != res->orig_sz) { if (insn_bytes_sz != res->orig_sz) {
pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) unexpected mem size: got %d, exp %u\n", pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) unexpected mem size: got %d, exp %u\n",
prog->name, relo_idx, insn_idx, insn_bytes_sz, res->orig_sz); prog_name, relo_idx, insn_idx, insn_bytes_sz, res->orig_sz);
return -EINVAL; return -EINVAL;
} }
insn_bpf_sz = insn_bytes_to_bpf_size(res->new_sz); insn_bpf_sz = insn_bytes_to_bpf_size(res->new_sz);
if (insn_bpf_sz < 0) { if (insn_bpf_sz < 0) {
pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) invalid new mem size: %u\n", pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) invalid new mem size: %u\n",
prog->name, relo_idx, insn_idx, res->new_sz); prog_name, relo_idx, insn_idx, res->new_sz);
return -EINVAL; return -EINVAL;
} }
insn->code = BPF_MODE(insn->code) | insn_bpf_sz | BPF_CLASS(insn->code); insn->code = BPF_MODE(insn->code) | insn_bpf_sz | BPF_CLASS(insn->code);
pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) mem_sz %u -> %u\n", pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) mem_sz %u -> %u\n",
prog->name, relo_idx, insn_idx, res->orig_sz, res->new_sz); prog_name, relo_idx, insn_idx, res->orig_sz, res->new_sz);
} }
break; break;
case BPF_LD: { case BPF_LD: {
...@@ -6080,14 +6081,14 @@ static int bpf_core_patch_insn(struct bpf_program *prog, ...@@ -6080,14 +6081,14 @@ static int bpf_core_patch_insn(struct bpf_program *prog,
insn[1].code != 0 || insn[1].dst_reg != 0 || insn[1].code != 0 || insn[1].dst_reg != 0 ||
insn[1].src_reg != 0 || insn[1].off != 0) { insn[1].src_reg != 0 || insn[1].off != 0) {
pr_warn("prog '%s': relo #%d: insn #%d (LDIMM64) has unexpected form\n", pr_warn("prog '%s': relo #%d: insn #%d (LDIMM64) has unexpected form\n",
prog->name, relo_idx, insn_idx); prog_name, relo_idx, insn_idx);
return -EINVAL; return -EINVAL;
} }
imm = insn[0].imm + ((__u64)insn[1].imm << 32); imm = insn[0].imm + ((__u64)insn[1].imm << 32);
if (res->validate && imm != orig_val) { if (res->validate && imm != orig_val) {
pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDIMM64) value: got %llu, exp %u -> %u\n", pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDIMM64) value: got %llu, exp %u -> %u\n",
prog->name, relo_idx, prog_name, relo_idx,
insn_idx, (unsigned long long)imm, insn_idx, (unsigned long long)imm,
orig_val, new_val); orig_val, new_val);
return -EINVAL; return -EINVAL;
...@@ -6096,13 +6097,13 @@ static int bpf_core_patch_insn(struct bpf_program *prog, ...@@ -6096,13 +6097,13 @@ static int bpf_core_patch_insn(struct bpf_program *prog,
insn[0].imm = new_val; insn[0].imm = new_val;
insn[1].imm = 0; /* currently only 32-bit values are supported */ insn[1].imm = 0; /* currently only 32-bit values are supported */
pr_debug("prog '%s': relo #%d: patched insn #%d (LDIMM64) imm64 %llu -> %u\n", pr_debug("prog '%s': relo #%d: patched insn #%d (LDIMM64) imm64 %llu -> %u\n",
prog->name, relo_idx, insn_idx, prog_name, relo_idx, insn_idx,
(unsigned long long)imm, new_val); (unsigned long long)imm, new_val);
break; break;
} }
default: default:
pr_warn("prog '%s': relo #%d: trying to relocate unrecognized insn #%d, code:0x%x, src:0x%x, dst:0x%x, off:0x%x, imm:0x%x\n", pr_warn("prog '%s': relo #%d: trying to relocate unrecognized insn #%d, code:0x%x, src:0x%x, dst:0x%x, off:0x%x, imm:0x%x\n",
prog->name, relo_idx, insn_idx, insn->code, prog_name, relo_idx, insn_idx, insn->code,
insn->src_reg, insn->dst_reg, insn->off, insn->imm); insn->src_reg, insn->dst_reg, insn->off, insn->imm);
return -EINVAL; return -EINVAL;
} }
...@@ -6238,6 +6239,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6238,6 +6239,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
const struct btf_type *local_type; const struct btf_type *local_type;
const char *local_name; const char *local_name;
struct core_cand_list *cands = NULL; struct core_cand_list *cands = NULL;
const char *prog_name = prog->name;
__u32 local_id; __u32 local_id;
const char *spec_str; const char *spec_str;
int i, j, err; int i, j, err;
...@@ -6264,13 +6266,13 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6264,13 +6266,13 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
err = bpf_core_parse_spec(local_btf, local_id, spec_str, relo->kind, &local_spec); err = bpf_core_parse_spec(local_btf, local_id, spec_str, relo->kind, &local_spec);
if (err) { if (err) {
pr_warn("prog '%s': relo #%d: parsing [%d] %s %s + %s failed: %d\n", pr_warn("prog '%s': relo #%d: parsing [%d] %s %s + %s failed: %d\n",
prog->name, relo_idx, local_id, btf_kind_str(local_type), prog_name, relo_idx, local_id, btf_kind_str(local_type),
str_is_empty(local_name) ? "<anon>" : local_name, str_is_empty(local_name) ? "<anon>" : local_name,
spec_str, err); spec_str, err);
return -EINVAL; return -EINVAL;
} }
pr_debug("prog '%s': relo #%d: kind <%s> (%d), spec is ", prog->name, pr_debug("prog '%s': relo #%d: kind <%s> (%d), spec is ", prog_name,
relo_idx, core_relo_kind_str(relo->kind), relo->kind); relo_idx, core_relo_kind_str(relo->kind), relo->kind);
bpf_core_dump_spec(LIBBPF_DEBUG, &local_spec); bpf_core_dump_spec(LIBBPF_DEBUG, &local_spec);
libbpf_print(LIBBPF_DEBUG, "\n"); libbpf_print(LIBBPF_DEBUG, "\n");
...@@ -6287,7 +6289,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6287,7 +6289,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
/* libbpf doesn't support candidate search for anonymous types */ /* libbpf doesn't support candidate search for anonymous types */
if (str_is_empty(spec_str)) { if (str_is_empty(spec_str)) {
pr_warn("prog '%s': relo #%d: <%s> (%d) relocation doesn't support anonymous types\n", pr_warn("prog '%s': relo #%d: <%s> (%d) relocation doesn't support anonymous types\n",
prog->name, relo_idx, core_relo_kind_str(relo->kind), relo->kind); prog_name, relo_idx, core_relo_kind_str(relo->kind), relo->kind);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
...@@ -6295,7 +6297,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6295,7 +6297,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
cands = bpf_core_find_cands(prog->obj, local_btf, local_id); cands = bpf_core_find_cands(prog->obj, local_btf, local_id);
if (IS_ERR(cands)) { if (IS_ERR(cands)) {
pr_warn("prog '%s': relo #%d: target candidate search failed for [%d] %s %s: %ld\n", pr_warn("prog '%s': relo #%d: target candidate search failed for [%d] %s %s: %ld\n",
prog->name, relo_idx, local_id, btf_kind_str(local_type), prog_name, relo_idx, local_id, btf_kind_str(local_type),
local_name, PTR_ERR(cands)); local_name, PTR_ERR(cands));
return PTR_ERR(cands); return PTR_ERR(cands);
} }
...@@ -6311,13 +6313,13 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6311,13 +6313,13 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
cands->cands[i].id, &cand_spec); cands->cands[i].id, &cand_spec);
if (err < 0) { if (err < 0) {
pr_warn("prog '%s': relo #%d: error matching candidate #%d ", pr_warn("prog '%s': relo #%d: error matching candidate #%d ",
prog->name, relo_idx, i); prog_name, relo_idx, i);
bpf_core_dump_spec(LIBBPF_WARN, &cand_spec); bpf_core_dump_spec(LIBBPF_WARN, &cand_spec);
libbpf_print(LIBBPF_WARN, ": %d\n", err); libbpf_print(LIBBPF_WARN, ": %d\n", err);
return err; return err;
} }
pr_debug("prog '%s': relo #%d: %s candidate #%d ", prog->name, pr_debug("prog '%s': relo #%d: %s candidate #%d ", prog_name,
relo_idx, err == 0 ? "non-matching" : "matching", i); relo_idx, err == 0 ? "non-matching" : "matching", i);
bpf_core_dump_spec(LIBBPF_DEBUG, &cand_spec); bpf_core_dump_spec(LIBBPF_DEBUG, &cand_spec);
libbpf_print(LIBBPF_DEBUG, "\n"); libbpf_print(LIBBPF_DEBUG, "\n");
...@@ -6325,7 +6327,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6325,7 +6327,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
if (err == 0) if (err == 0)
continue; continue;
err = bpf_core_calc_relo(prog, relo, relo_idx, &local_spec, &cand_spec, &cand_res); err = bpf_core_calc_relo(prog_name, relo, relo_idx, &local_spec, &cand_spec, &cand_res);
if (err) if (err)
return err; return err;
...@@ -6337,7 +6339,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6337,7 +6339,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
* should all resolve to the same bit offset * should all resolve to the same bit offset
*/ */
pr_warn("prog '%s': relo #%d: field offset ambiguity: %u != %u\n", pr_warn("prog '%s': relo #%d: field offset ambiguity: %u != %u\n",
prog->name, relo_idx, cand_spec.bit_offset, prog_name, relo_idx, cand_spec.bit_offset,
targ_spec.bit_offset); targ_spec.bit_offset);
return -EINVAL; return -EINVAL;
} else if (cand_res.poison != targ_res.poison || cand_res.new_val != targ_res.new_val) { } else if (cand_res.poison != targ_res.poison || cand_res.new_val != targ_res.new_val) {
...@@ -6346,7 +6348,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6346,7 +6348,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
* proceed due to ambiguity * proceed due to ambiguity
*/ */
pr_warn("prog '%s': relo #%d: relocation decision ambiguity: %s %u != %s %u\n", pr_warn("prog '%s': relo #%d: relocation decision ambiguity: %s %u != %s %u\n",
prog->name, relo_idx, prog_name, relo_idx,
cand_res.poison ? "failure" : "success", cand_res.new_val, cand_res.poison ? "failure" : "success", cand_res.new_val,
targ_res.poison ? "failure" : "success", targ_res.new_val); targ_res.poison ? "failure" : "success", targ_res.new_val);
return -EINVAL; return -EINVAL;
...@@ -6379,10 +6381,10 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6379,10 +6381,10 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
*/ */
if (j == 0) { if (j == 0) {
pr_debug("prog '%s': relo #%d: no matching targets found\n", pr_debug("prog '%s': relo #%d: no matching targets found\n",
prog->name, relo_idx); prog_name, relo_idx);
/* calculate single target relo result explicitly */ /* calculate single target relo result explicitly */
err = bpf_core_calc_relo(prog, relo, relo_idx, &local_spec, NULL, &targ_res); err = bpf_core_calc_relo(prog_name, relo, relo_idx, &local_spec, NULL, &targ_res);
if (err) if (err)
return err; return err;
} }
...@@ -6392,7 +6394,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog, ...@@ -6392,7 +6394,7 @@ static int bpf_core_apply_relo(struct bpf_program *prog,
err = bpf_core_patch_insn(prog, relo, relo_idx, &targ_res); err = bpf_core_patch_insn(prog, relo, relo_idx, &targ_res);
if (err) { if (err) {
pr_warn("prog '%s': relo #%d: failed to patch insn #%zu: %d\n", pr_warn("prog '%s': relo #%d: failed to patch insn #%zu: %d\n",
prog->name, relo_idx, relo->insn_off / BPF_INSN_SZ, err); prog_name, relo_idx, relo->insn_off / BPF_INSN_SZ, err);
return -EINVAL; return -EINVAL;
} }
......
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