From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A379EEEDE for ; Sat, 22 Feb 2025 03:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740193285; cv=none; b=ZJh4KPzfpyH9hx4tlkXDgqctfL63OUAQXgUXR+e4xBDIR6ShNqJGTv8nn7CY5pbHVgIMJkNaAu1Rk6rELNLUAIiYSawcwdwB9yUcaOToNmlg2EhqJluwP4jG/nZ1EFnDHIB7zVt1gbeok2NuAcJEwO0cmVeVmYiQM3KXG3InJXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740193285; c=relaxed/simple; bh=ZOJUc7908s6v3aPgIOk+AQRLD1psJvVNRZf7IPLFPW4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gVEiHWj3F8Sr5kxSx7n1OBJkbVZw0HfAsXCK9YgaDnY1GPk8yhuRWfHS5Uej1cuXNkGndNueZcutop66T+xW9oMr6Gpa645STtaMBfhTp1oAdarOYGcFRESwao45kaieuONDLE6v5dxZcwCNrdkJCYfHfgJKtqAt00k4I0C78ks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ZhDcaJjW; arc=none smtp.client-ip=91.218.175.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="ZhDcaJjW" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1740193271; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uiWFpDdL4A7YTKLURfXRoHywJpFk36w4rMNGrCCt670=; b=ZhDcaJjWeduO/PhQg5tpAbsdib+drANcBvhH3m0pHBNWFbgMJdqIxHAysdJghyl2s4L8DV eQM28eVBm5VSClElS0vW5ak0M73+CB7zNwAzTm56nybp92G3e9TJzlgKvXp5tHRN1Lpqjw 2R5Xjny16/j7liC4SOSv4T48Zwu/1Oc= Date: Sat, 22 Feb 2025 11:00:58 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v8 4/4] selftests/bpf: Add libbpf_probe_bpf_kfunc API selftests To: Eduard Zingerman , ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, haoluo@google.com, jolsa@kernel.org, qmo@kernel.org Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, chen.dylane@gmail.com, Tao Chen References: <20250221163335.262143-1-chen.dylane@linux.dev> <20250221163335.262143-5-chen.dylane@linux.dev> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Tao Chen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 在 2025/2/22 02:19, Eduard Zingerman 写道: > On Sat, 2025-02-22 at 00:33 +0800, Tao Chen wrote: > > [...] > >> +static const struct { >> + const char *name; >> + int code; >> +} program_types[] = { >> +#define _T(n) { #n, BPF_PROG_TYPE_##n } >> + _T(KPROBE), >> + _T(XDP), >> + _T(SYSCALL), >> + _T(SCHED_CLS), >> + _T(SCHED_ACT), >> + _T(SK_SKB), >> + _T(SOCKET_FILTER), >> + _T(CGROUP_SKB), >> + _T(LWT_OUT), >> + _T(LWT_IN), >> + _T(LWT_XMIT), >> + _T(LWT_SEG6LOCAL), >> + _T(NETFILTER), >> + _T(CGROUP_SOCK_ADDR), >> + _T(SCHED_ACT) >> +#undef _T >> +}; >> + >> +void test_libbpf_probe_kfuncs_many(void) >> +{ > > Hi Tao, > > Sorry, probably some miscommunication from my side. > I did not mean this test for inclusion, it was meant as a one time > manual inspection of libbpf_probe_bpf_kfunc results. > Just as a sanity check before series is merged. > As an automated test it does not provide much meaningful signal. > Ok, i will resend v8 without this case, and check all the prog types later with your program. Thanks. >> + int i, kfunc_id, ret, id; >> + const struct btf_type *t; >> + struct btf *btf = NULL; >> + const char *kfunc; >> + const char *tag; >> + >> + btf = btf__parse("/sys/kernel/btf/vmlinux", NULL); >> + if (!ASSERT_OK_PTR(btf, "btf_parse")) >> + return; >> + for (id = 0; id < btf__type_cnt(btf); ++id) { >> + t = btf__type_by_id(btf, id); >> + if (!t) >> + continue; >> + if (!btf_is_decl_tag(t)) >> + continue; >> + tag = btf__name_by_offset(btf, t->name_off); >> + if (strcmp(tag, "bpf_kfunc") != 0) >> + continue; >> + kfunc_id = t->type; >> + t = btf__type_by_id(btf, kfunc_id); >> + if (!btf_is_func(t)) >> + continue; >> + kfunc = btf__name_by_offset(btf, t->name_off); >> + for (i = 0; i < ARRAY_SIZE(program_types); ++i) { >> + ret = libbpf_probe_bpf_kfunc(program_types[i].code, >> + kfunc_id, -1, NULL); >> + if (ret < 0) { >> + ASSERT_FAIL("kfunc:%s use prog type:%d", >> + kfunc, program_types[i].code); >> + goto cleanup; >> + } >> + } >> + } >> +cleanup: >> + btf__free(btf); >> +} > > -- Best Regards Tao Chen