From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrey Ignatov Subject: [PATCH bpf-next 0/5] Introduce libbpf_attach_type_by_name Date: Wed, 26 Sep 2018 15:24:52 -0700 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Cc: Andrey Ignatov , , , To: Return-path: Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:59040 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbeI0EkU (ORCPT ); Thu, 27 Sep 2018 00:40:20 -0400 Received: from pps.filterd (m0148461.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8QMMhrK016277 for ; Wed, 26 Sep 2018 15:25:13 -0700 Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2mrjbm834g-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Wed, 26 Sep 2018 15:25:13 -0700 Sender: netdev-owner@vger.kernel.org List-ID: This patch set introduces libbpf_attach_type_by_name function in libbpf to identify attach type by section name. This is useful to avoid writing same logic over and over again in user space applications that leverage libbpf. Patch 1 has more details on the new function and problem being solved. Patches 2 and 3 add support for new section names. Patch 4 uses new function in a selftest. Patch 5 adds selftest for libbpf_{prog,attach}_type_by_name. As a side note there are a lot of inconsistencies now between names used by libbpf and bpftool (e.g. cgroup/skb vs cgroup_skb, cgroup_device and device vs cgroup/dev, sockops vs sock_ops, etc). This patch set does not address it but it tries not to make it harder to address it in the future. Andrey Ignatov (5): libbpf: Introduce libbpf_attach_type_by_name libbpf: Support cgroup_skb/{e,in}gress section names libbpf: Support sk_skb/stream_{parser,verdict} section names selftests/bpf: Use libbpf_attach_type_by_name in test_socket_cookie selftests/bpf: Test libbpf_{prog,attach}_type_by_name tools/lib/bpf/libbpf.c | 129 +++++++---- tools/lib/bpf/libbpf.h | 2 + tools/testing/selftests/bpf/Makefile | 2 +- .../selftests/bpf/test_section_names.c | 208 ++++++++++++++++++ .../selftests/bpf/test_socket_cookie.c | 6 +- 5 files changed, 302 insertions(+), 45 deletions(-) create mode 100644 tools/testing/selftests/bpf/test_section_names.c -- 2.17.1