Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp798417ybl; Thu, 23 Jan 2020 07:59:02 -0800 (PST) X-Google-Smtp-Source: APXvYqx+0jGsy1TYxYzygebPLId/K2QRAgn6WUwEBnoBYY/4NUqWUtwWSQJu+T4BxiNBwwHSSyuA X-Received: by 2002:a05:6808:3d0:: with SMTP id o16mr11087000oie.79.1579795142369; Thu, 23 Jan 2020 07:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579795142; cv=none; d=google.com; s=arc-20160816; b=bWV+AlH3ErU/DayUnWeDyHsxlqsonpmFl4bUXgb8Du9TeBf8DIgitbalMU4oAVasxK R1xujnxMC+1qDhjAVSO8PBx3O3rZrjqfmLGxSgcB65zVNPi5JNF7XyFF/7zwseegvAui i0DXFIgrQyXxmN/NgAOSAW2jOuKJLiNGyUE1TtW7rklCIwtU0mm69UHHkJsoy6Hyocf3 typZuxEKEonY7E+St9HGIyzJVzZ9g1QUdt4Y2qvyIM1UkBWjUqdJUv+9c3VGRZB9KcEw /td6c9BfBkBp7CUk8kr7sD34XpKLvVy/WDjhaL4x/fCMUM/+LviGFZH9DdnBWA79ar0B vJow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=QbCkjNFXxp+Z54U781aPlhQB8MWijI7Rb9jY+rqocOQ=; b=g2abkDvgjyn5q51EFuh0q8ENvGsY/J6FHSi8Nhgu3MoC0E4L5alS7LJsRGGROLV1OK xnTufAubaBXgxnyYb6XWtG/HBWJTgv2ED6H1zxnV0SAEC86aDpvPfE5L9iFGVBVbevF3 fTwjwTlQh/pbrP7LyLSaTfmTLddKzyN7+dq2PUfiXotWXu1aTTGNOG7d9lMEwQV+V1uF +4EueXoahJqdjzJHttz/hoa25Yc82jbMbVXx1IxtVQQUKGX5TtAP8dOcL9++ZQ2xiu2/ SYLVqj0im5uDUScztUXLDsZLhT2K1BW+7fn7ydDzxvwRu9TQv8r4zYl8USu7n8VBsV0/ EfrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a3si1301595otr.37.2020.01.23.07.58.49; Thu, 23 Jan 2020 07:59:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbgAWP5x (ORCPT + 99 others); Thu, 23 Jan 2020 10:57:53 -0500 Received: from www62.your-server.de ([213.133.104.62]:37536 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726885AbgAWP5x (ORCPT ); Thu, 23 Jan 2020 10:57:53 -0500 Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1iuerU-0002Nx-KQ; Thu, 23 Jan 2020 16:57:40 +0100 Received: from [2001:1620:665:0:5795:5b0a:e5d5:5944] (helo=linux-3.fritz.box) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iuerU-000SOJ-77; Thu, 23 Jan 2020 16:57:40 +0100 Subject: Re: [PATCH] Support for nlattr and nested_nlattr attribute search in EBPF filter To: Kalimuthu Velappan Cc: Alexei Starovoitov , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , "David S. Miller" , Stanislav Fomichev , Quentin Monnet , Andrey Ignatov , "open list:BPF (Safe dynamic programs and tools)" , "open list:BPF (Safe dynamic programs and tools)" , open list References: <20200123130816.24815-1-kalimuthu.velappan@broadcom.com> From: Daniel Borkmann Message-ID: Date: Thu, 23 Jan 2020 16:57:39 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200123130816.24815-1-kalimuthu.velappan@broadcom.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.101.4/25704/Thu Jan 23 12:37:43 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/23/20 2:08 PM, Kalimuthu Velappan wrote: > Added attribute search and nested attribute support in EBPF filter > functionality. Your commit describes what the code does, but not the rationale why it's needed resp. the use-case you're trying to solve with this. Also, why it cannot be resolved in native BPF? > Signed-off-by: Kalimuthu Velappan > --- > include/uapi/linux/bpf.h | 5 ++++- > net/core/filter.c | 22 ++++++++++++++++++++++ > tools/include/uapi/linux/bpf.h | 4 +++- > 3 files changed, 29 insertions(+), 2 deletions(-) > > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > index dbbcf0b..ac9794c 100644 > --- a/include/uapi/linux/bpf.h > +++ b/include/uapi/linux/bpf.h > @@ -2938,7 +2938,10 @@ union bpf_attr { > FN(probe_read_user), \ > FN(probe_read_kernel), \ > FN(probe_read_user_str), \ > - FN(probe_read_kernel_str), > + FN(probe_read_kernel_str), \ > + FN(skb_get_nlattr), \ > + FN(skb_get_nlattr_nest), > + This is not on latest bpf-next tree. > /* integer value in 'imm' field of BPF_CALL instruction selects which helper > * function eBPF program intends to call > diff --git a/net/core/filter.c b/net/core/filter.c > index 538f6a7..56a87e1 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -2699,6 +2699,24 @@ static const struct bpf_func_proto bpf_set_hash_invalid_proto = { > .arg1_type = ARG_PTR_TO_CTX, > }; > > +static const struct bpf_func_proto bpf_skb_get_nlattr_proto = { > + .func = bpf_skb_get_nlattr, > + .gpl_only = false, > + .ret_type = RET_INTEGER, > + .arg1_type = ARG_PTR_TO_CTX, > + .arg2_type = ARG_ANYTHING, > + .arg3_type = ARG_ANYTHING, > +}; > + > +static const struct bpf_func_proto skb_get_nlattr_nest_proto = { > + .func = bpf_skb_get_nlattr_nest, > + .gpl_only = false, > + .ret_type = RET_INTEGER, > + .arg1_type = ARG_PTR_TO_CTX, > + .arg2_type = ARG_ANYTHING, > + .arg3_type = ARG_ANYTHING, > +}; > + > BPF_CALL_2(bpf_set_hash, struct sk_buff *, skb, u32, hash)