Skip to contentSkip to conversation

bpf: add btf func and func_proto kind support

PATCH In review Yonghong Song 3 participants 3 messages Jan 25, 2019 – Feb 5, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bpf: add btf func and func_proto kind support

The issue is discovered for bpf selftest test_skb_cgroup.sh. Currently we have,

  $ ./test_skb_cgroup_id.sh
  Wait for testing link-local IP to become available ... OK
  Object has unknown BTF type: 13!
  [PASS]

In the above the BTF type 13 refers to BTF kind BTF_KIND_FUNC_PROTO.
This patch added support of BTF_KIND_FUNC_PROTO and BTF_KIND_FUNC during type parsing.
With this patch, I got

  $ ./test_skb_cgroup_id.sh
  Wait for testing link-local IP to become available ... OK
  [PASS]
---
 lib/bpf.c | 4 ++++
 1 file changed, 4 insertions(+)
lib/bpf.c +4 -0
index 5e85cfc0..762f8857 100644
@@ -2193,12 +2193,16 @@ static int bpf_btf_prep_type_data(struct bpf_elf_ctx *ctx)
 		case BTF_KIND_ENUM:
 			type_cur += var_len * sizeof(struct btf_enum);
 			break;
+		case BTF_KIND_FUNC_PROTO:
+			type_cur += var_len * sizeof(struct btf_param);
+			break;
 		case BTF_KIND_TYPEDEF:
 		case BTF_KIND_PTR:
 		case BTF_KIND_FWD:
 		case BTF_KIND_VOLATILE:
 		case BTF_KIND_CONST:
 		case BTF_KIND_RESTRICT:
+		case BTF_KIND_FUNC:
 			break;
 		default:
 			fprintf(stderr, "Object has unknown BTF type: %u!\n", kind);
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Yonghong Song

The issue is discovered for bpf selftest test_skb_cgroup.sh. Currently we have,

  $ ./test_skb_cgroup_id.sh
  Wait for testing link-local IP to become available ... OK
  Object has unknown BTF type: 13!
  [PASS]

In the above the BTF type 13 refers to BTF kind BTF_KIND_FUNC_PROTO.
This patch added support of BTF_KIND_FUNC_PROTO and BTF_KIND_FUNC during type parsing.
With this patch, I got

Quoted 5 lines
  $ ./test_skb_cgroup_id.sh
  Wait for testing link-local IP to become available ... OK
  [PASS]

Thanks!

#2 lore raw
In reply to Yonghong Song
Quoted 12 lines · On Thu, 24 Jan 2019 16:41:07 -0800 Yonghong Song <[email protected]> wrote:

The issue is discovered for bpf selftest test_skb_cgroup.sh. Currently we have,

  $ ./test_skb_cgroup_id.sh
  Wait for testing link-local IP to become available ... OK
  Object has unknown BTF type: 13!
  [PASS]

In the above the BTF type 13 refers to BTF kind BTF_KIND_FUNC_PROTO.
This patch added support of BTF_KIND_FUNC_PROTO and BTF_KIND_FUNC during type parsing.
With this patch, I got

Quoted 5 lines
  $ ./test_skb_cgroup_id.sh
  Wait for testing link-local IP to become available ... OK
  [PASS]

Sure applied.