Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3426024ybl; Mon, 27 Jan 2020 03:54:30 -0800 (PST) X-Google-Smtp-Source: APXvYqyVMMr6j1HySnUOZFq/MieXEneHILptOBVZMmdO96eM24vXCilebwbrj2hI5UPabjThKOAM X-Received: by 2002:aca:5582:: with SMTP id j124mr6839823oib.20.1580126070568; Mon, 27 Jan 2020 03:54:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580126070; cv=none; d=google.com; s=arc-20160816; b=SWf0LG8BMRbt7T/KD1XpO/SNrxOtAtWTf+7u3/Cw6v2M/iDbQH3G/SAG3lLbdooB9c b61UiuamLMkk3Pz+vNdo2TX7FH51MiyCF9cU7Mejvnt6vEGLAN/wUAG5vlPhiNBZ7KkW hUaOg8T4ZLZPm0PKfeOTfFMDA7dioUCb+zCt3cQZUuy3UZkLMB2RghouQjkTJs9xO0/h 7DHloN7g5WMAfrG1XacJkSfwGehbLsJ2DARoTEHOqAsPEAreKnuz2Ig9E3VRvCorTC65 r+srsDUrjwiOLO1KNPD3a+qQGWGphjX0JiOhXLxmSNzXOXe9Q9XAQ/CgUwcTY2typbYa MtJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=B2jn7Up2+cD+eD0D5ROwEvtEdti9pDs97jpRUZiU808=; b=J3ZDLyOUJig904Z/1Nr0MTrssp7z9ZL6P2mYAc+20RvOPLelc8721FYOg9NkYsg7aw HGkAIb/MZn/nc8U+IlJvZToCJxHZNfnYP/41Eh1WS+uwbmmgl00TNQ/ARgOrFkEUG850 jnWD6A3joCSFmtp7IGqM+2Ei8OZ5jvjN9cJ68E5jYpg1m0yMvDf6KCvyo4U7Dh1eQaiJ mYnXJ1F0eBO+Gv3GUIgVhR//oxlnsoik4VyJeeYVXFv/YUGEdK9ve4olkFEdseFprdzP MoWpK5IzmRYtFiDI3DLz1zr8fZ5gDd8YG0ZnqQCs8+ZTYfHd9UXOdesWjy7eHoTG14j5 R7ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=TeflSVeC; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i10si6745144otk.195.2020.01.27.03.54.16; Mon, 27 Jan 2020 03:54:30 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=TeflSVeC; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729939AbgA0LQw (ORCPT + 99 others); Mon, 27 Jan 2020 06:16:52 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:35157 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729235AbgA0LQw (ORCPT ); Mon, 27 Jan 2020 06:16:52 -0500 Received: by mail-io1-f67.google.com with SMTP id h8so9512724iob.2 for ; Mon, 27 Jan 2020 03:16:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B2jn7Up2+cD+eD0D5ROwEvtEdti9pDs97jpRUZiU808=; b=TeflSVeClgOmybuUdraDwRDq9IBddwlPu0A697aG3aE5gp2/aIDp2vvWgEWA/XhPU5 DKrgrbvlYYAdAEyYGSHlCA3Lyu+tHHlgxKD4D17+p9Ty0j+YOIKzJpDWzCaU11xjS2ga tAECbeUjD+qPWCI4YH854OjSrAxIK+z8wE4kY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=B2jn7Up2+cD+eD0D5ROwEvtEdti9pDs97jpRUZiU808=; b=IykOX0byjB07Stl/ndz90pBkblcpN6z52Ym6MhrQfobJDX/Dwn0vWbBB9JxOCTF0BS 4KOH/Yud2jPkzaLhm6tJ2tQykyPU7/STi37hN9k5rqNjuaBYyBJLLH03tA+VtzO1CbMM bP4ULv59bkECk90G9/rqkM7bGMxHAR6PWdMqIZDCKan+4nFz4Np59vbs4sSxHelZwiaR MMEAjm7e8E40MiVksoFRVQYq7ShnMcWebN1VjCQbUduKitJI5DZqyHr2tQ0whMda+Vbf sxElG9voNZDFJVVkqDQ/fIPvGcrjqrf84UZp9RQjbnEoWILO2axgjvMOuHBLzn+PQOfL C+2g== X-Gm-Message-State: APjAAAWr3AxjwjpLQN2VEJdO/Gu1S8tY8+ZI4X51t0xsHK9KQLjjmNJX GuAaq3fzZy6S9Oezc8I5ZkwjSTDAhYTSjQbsMg76G22j6aM= X-Received: by 2002:a92:bb08:: with SMTP id w8mr13902051ili.27.1580123446775; Mon, 27 Jan 2020 03:10:46 -0800 (PST) MIME-Version: 1.0 References: <20200123130816.24815-1-kalimuthu.velappan@broadcom.com> In-Reply-To: From: Kalimuthu Velappan Date: Mon, 27 Jan 2020 16:40:09 +0530 Message-ID: Subject: Re: [PATCH] Support for nlattr and nested_nlattr attribute search in EBPF filter To: Daniel Borkmann 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Daniel, There are few network applications relying on Netlink subsystem to get notifications for net-device attribute changes like MTU, Speed, Oper-Status, Name, slave, slave info, etc. The Netlink subsystem notifies the application on every attribute change regardless of what is being needed for the application. The attribute search support in EBPF filter helps to filter the Netlink packets based on the specific set of attributes that are needed for the application. The classical BPF supports attribute search but that doesn't support MAPS. The extended BPF supports MAPS, but the attribute search is not enabled. Hence this patch enables the support for attribute search in EBPF. Thanks Kals On Thu, Jan 23, 2020 at 9:27 PM Daniel Borkmann wrote: > > 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) -- Thanks - Kals