Blob Blame History Raw
From 5c940644dfc632f1270f39ee909e1abb877ff081 Mon Sep 17 00:00:00 2001
From: Andrea Claudi <aclaudi@redhat.com>
Date: Thu, 13 Jun 2019 14:37:57 +0200
Subject: [PATCH] bpf: add btf func and func_proto kind support

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1716361
Upstream Status: iproute2.git commit 3da6d055d93fe

commit 3da6d055d93fefe40bf88a9bc37b4ce3433696ee
Author: Yonghong Song <yhs@fb.com>
Date:   Thu Jan 24 16:41:07 2019 -0800

    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]

    Signed-off-by: Yonghong Song <yhs@fb.com>
    Acked-by: Daniel Borkmann <daniel@iogearbox.net>
    Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/bpf.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/bpf.c b/lib/bpf.c
index 5e85cfc0bdd5b..762f8857453ff 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -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);
-- 
2.20.1