From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751107AbbCNPzJ (ORCPT ); Sat, 14 Mar 2015 11:55:09 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:36852 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750767AbbCNPzG (ORCPT ); Sat, 14 Mar 2015 11:55:06 -0400 Message-ID: <550459E4.1050808@plumgrid.com> Date: Sat, 14 Mar 2015 08:55:16 -0700 From: Alexei Starovoitov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Daniel Borkmann , "David S. Miller" CC: Thomas Graf , linux-api@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 net-next 1/2] bpf: allow extended BPF programs access skb fields References: <1426273064-4837-1-git-send-email-ast@plumgrid.com> <1426273064-4837-2-git-send-email-ast@plumgrid.com> <550392F7.9040308@iogearbox.net> <550397B0.5070409@iogearbox.net> <5503981C.6000801@plumgrid.com> <55039A0D.20000@iogearbox.net> <55039C9D.6010602@plumgrid.com> <5503C03F.8020903@plumgrid.com> <550400D8.5060407@iogearbox.net> In-Reply-To: <550400D8.5060407@iogearbox.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/14/15 2:35 AM, Daniel Borkmann wrote: > On 03/14/2015 05:59 AM, Alexei Starovoitov wrote: >> also note that this case and twsk_build_assert are different. >> twsk_build_assert has no other choice then to have one function >> that covers logic in the whole file, whereas in this patch: >> + BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, mark) != 4); >> + *insn++ = BPF_LDX_MEM(BPF_W, dst_reg, src_reg, >> + offsetof(struct sk_buff, mark)); >> >> the build_bug_on protect the line directly below. >> Separating them just doesn't make sense at all. > > I also like the above approach better, I only suggested that as a > possible alternative since you were saying earlier in this thread: > > I thought about it, but didn't add it, since we already have them > in the same file several lines above this spot. I think one build > error per .c file should be enough to attract attention. Though > I'll add a comment to convert_bpf_extensions() that build_bug_on > errors should be addressed in two places. and to that you replied: "My concern would be that in case the code gets changed, this spot could easily be overlooked by someone possibly unfamiliar with the code, since no build error triggers there." so from there I saw two options: either copy paste all build_bug_on and have the same *insn=... and build_bug_on in two places or consolidate them in single helper function. Obviously single helper function is a preferred method. I'm not sure what are you still arguing about.