Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753617AbbLRHTD (ORCPT ); Fri, 18 Dec 2015 02:19:03 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:35142 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752430AbbLRHTB (ORCPT ); Fri, 18 Dec 2015 02:19:01 -0500 Message-ID: <5673B16C.8000002@huawei.com> Date: Fri, 18 Dec 2015 15:10:36 +0800 From: "Wangnan (F)" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Alexei Starovoitov CC: , , , , , , , , , , , , , Subject: Re: [PATCH 08/10] bpf samples: Add utils.[ch] for using BPF References: <1450329794-161948-1-git-send-email-wangnan0@huawei.com> <1450329794-161948-9-git-send-email-wangnan0@huawei.com> <20151217231138.GA34078@ast-mbp.thefacebook.com> <5673659F.9090004@huawei.com> <20151218061929.GA59584@ast-mbp.thefacebook.com> <5673AFE0.1000006@huawei.com> In-Reply-To: <5673AFE0.1000006@huawei.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.111.66.109] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.5673B17E.00C9,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 94f38520f41c1ba30f739596fe66d66f Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2283 Lines: 64 On 2015/12/18 15:04, Wangnan (F) wrote: > > > On 2015/12/18 14:19, Alexei Starovoitov wrote: >> On Fri, Dec 18, 2015 at 09:47:11AM +0800, Wangnan (F) wrote: >>> This is a limitation in tools/lib/bpf/libbpf.h, which has a #include >>> >>> in its header. >>> >>> libbpf.h requires this include because its API uses ERR_PTR() to encode >>> error code. >>> For example, when calling bpf_object__open(), caller should use >>> IS_ERR() to >>> check its >>> return value instead of compare with NULL, and use PTR_ERR() to retrive >>> error number. >>> >>> However, linux/err.h is not a part of uapi. To make libbpf work, one >>> has to >>> create its >>> own err.h. >> [SNIP] >>> What about moving them into include/uapi/linux/filter.h ? Then >>> normal user programs like those in samples/bpf can access >>> them easier. >> we don't want to add these macros to uapi. >> Why not to add it to >> tools/include/linux/filter.h >> instead? > > What I want to do in this patchset is not only removing original libbpf.c > and bpf_load.c. In fact I want libbpf in tools/lib/bpf becomes a public > available library for other userspace tools (tc for example). Switching > samples/bpf into libbpf is the first step of this goal. From doing this > I found and fixed some limitation, like those missed BPF map operations. > Making libbpf.h and bpf.h available for normal userspace programs is also > important. > > Having the above goal, I think you can understand why improving > tools/include > is not a good idea. You don't want to force a normal userspace program > setup > a similar header environment for using libbpf. It is relatively a small > library. So it would be good if bpf.h and libbpf.h only depend on what > can > be found in uapi. > I suddenly realized that only linux/err.h causes problem. Those macros from filter.h are never accessed by libbpf. So we can drop those filter.h by making samples/bpf include from tools/include. However we still need a wrapper in libbpf to avoid including linux/err.h. Thank you. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/