Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp16472pxb; Tue, 12 Jan 2021 18:35:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHd86wm1fphHTiz7DpL6wvokowZeR0vljrdu/4rpDTm1LjxLw7M7Uqu5YiuTEEp57iX1aE X-Received: by 2002:a50:d888:: with SMTP id p8mr629edj.147.1610505314635; Tue, 12 Jan 2021 18:35:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610505314; cv=none; d=google.com; s=arc-20160816; b=zkElUcfgLfsZwwJPbNKSJeOsoRPrVGfDLDQ6zLmM+j1xcBZl+w/NrWytTrQ6dot1NR GE+iC5vD/eIo1aNJ7kyBhg+9iOZhZ7Xre+BKNFTwh0sN/EJpwb2y4lJvFw+r5PHMfahr mKsLnQJBBYiiUxFxvvu7y2X/x6RHPzkGe05Pyr1nOxIM2jibI0Vrmv9bN+i3bgmS4IQH zxxcZIhsEi7kI5MGS7yRbMYUY+EN/BjqUh1XaQK1z+Tg1MxgV4TRWJKI6XABt7oEcIpq BVWMHYkjQh0cA3TewAPihl/kUR1XXcSX8Slboi4nlIaKL54VL611sHSkDlsD5m5czOdA Sr9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=uD2LwoNsLHO2bQTapcwBrSqoHTZzd1YmNCw2S92ag9Q=; b=FxAcFngz/i7HtJ6tSno+4fHKRY1Z6QiNesbTInLlLwjlqMCpZwFP4hORZmxMTPUOSx FJqHRye5B55Q6ZRGrIl20qmc3IXrPudanY8alCg1F/TvA6YGzHxjembMCekQ2zOVu6TH jlUC7djLVaRlwNOoABAQ6lYlyY9ZNUnZwxLAjClXCSa2f7NdyZv0D0b3712RYSnVFTLw 9xBcJyktKEs0XRzV3jBlGU97SkGLqRiTci8jo09NDmk+kFGDIhWqgiVVt1lcsdNNh41k uBJdgKcLQUgWbwIOgl5Rty/rBzXAqQOmHHFmbbk78DI6HaxoL+tKhlGJhEjMkqN0HVx4 gtqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@daynix-com.20150623.gappssmtp.com header.s=20150623 header.b=Y43uZ7bL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si296435eji.387.2021.01.12.18.34.51; Tue, 12 Jan 2021 18:35:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@daynix-com.20150623.gappssmtp.com header.s=20150623 header.b=Y43uZ7bL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437846AbhALVeh (ORCPT + 99 others); Tue, 12 Jan 2021 16:34:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437068AbhALU4A (ORCPT ); Tue, 12 Jan 2021 15:56:00 -0500 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [IPv6:2607:f8b0:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F671C061795 for ; Tue, 12 Jan 2021 12:55:20 -0800 (PST) Received: by mail-ot1-x32c.google.com with SMTP id o11so3661246ote.4 for ; Tue, 12 Jan 2021 12:55:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uD2LwoNsLHO2bQTapcwBrSqoHTZzd1YmNCw2S92ag9Q=; b=Y43uZ7bLVKMqH9GbZ4BYcx2lvxcJ2i103HsmZiv7+g4ZppufN2r5P61wpRmKjQtDm+ 6Iw5P4Q3jCWLRJntB2VAsKmOyFWepWSPdDNfMwp7rBHOArihxsXGpviAmbLDbLReNp5T 1GsQFLXpkPd3O8YBg1d9ys2pl+Y2iRrBcQPXibs/a8PG64RIBsakJm4UbXN4O3AmUBMB LcWcVtFHbgPEspus3oJa8xqqPKE6R8KJiuW56r+SCcE5YMmlzY88EwbtWXVIvz2bjoYL 9avkyk50tPvH0NmYp6atvBDNCPwlyY5Wzt+QY/5vlJHqedpwjVB5eQYvs1hgfE8jwBFg z4Cw== 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=uD2LwoNsLHO2bQTapcwBrSqoHTZzd1YmNCw2S92ag9Q=; b=B7aGvFeE67QdOzx1kyFCE69fyT61MVMx74yeQhAp/0ZxDtApPZ5RdNl9FTr1YWCTs8 ARIw3U+BR9F5PA/eWZMysG9jO38aXiZI63m2rRAqIIrQkzspcdDZ08/LRJ+84YeK04kr jNtSHQmTgaqfkebTN6PtYpbCidph7PcBhci1RhaMsyD+8FeiPWuMFj6uPGJpU4zAG0q6 1zU9v1n0QEW3hgetx5nv1mAVUO+1wgnRZYOoOJ2XesRQoTDtOhoD8rJqoA2mq3WYN5CD Oi4Hq6YTurrceAgoujz1LUza4EBYCUVievCDJulOMHtrSYA+s/XxQtISdGZ36N+GLQ2J G1bw== X-Gm-Message-State: AOAM531cmxnaukJSf4lr6JWecc2wk4g0chlnL2ZI7hSWOywpci1lz52d VQSqr7H8biVZa/1dHGfgls+wUgB8y5BjvFSSVttBFQ== X-Received: by 2002:a05:6830:572:: with SMTP id f18mr874911otc.109.1610484919603; Tue, 12 Jan 2021 12:55:19 -0800 (PST) MIME-Version: 1.0 References: <20210112194143.1494-1-yuri.benditovich@daynix.com> <20210112194143.1494-4-yuri.benditovich@daynix.com> In-Reply-To: From: Yuri Benditovich Date: Tue, 12 Jan 2021 22:55:07 +0200 Message-ID: Subject: Re: [RFC PATCH 3/7] tun: allow use of BPF_PROG_TYPE_SCHED_CLS program type To: "David S. Miller" , Jakub Kicinski , "Michael S . Tsirkin" , Jason Wang , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , rdunlap@infradead.org, willemb@google.com, gustavoars@kernel.org, herbert@gondor.apana.org.au, steffen.klassert@secunet.com, pablo@netfilter.org, decui@microsoft.com, cai@lca.pw, jakub@cloudflare.com, elver@google.com, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, bpf@vger.kernel.org Cc: Yan Vugenfirer Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 12, 2021 at 10:40 PM Yuri Benditovich wrote: > > On Tue, Jan 12, 2021 at 9:42 PM Yuri Benditovich > wrote: > > > > This program type can set skb hash value. It will be useful > > when the tun will support hash reporting feature if virtio-net. > > > > Signed-off-by: Yuri Benditovich > > --- > > drivers/net/tun.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > > index 7959b5c2d11f..455f7afc1f36 100644 > > --- a/drivers/net/tun.c > > +++ b/drivers/net/tun.c > > @@ -2981,6 +2981,8 @@ static int tun_set_ebpf(struct tun_struct *tun, struct tun_prog __rcu **prog_p, > > prog = NULL; > > } else { > > prog = bpf_prog_get_type(fd, BPF_PROG_TYPE_SOCKET_FILTER); > > + if (IS_ERR(prog)) > > + prog = bpf_prog_get_type(fd, BPF_PROG_TYPE_SCHED_CLS); > > if (IS_ERR(prog)) > > return PTR_ERR(prog); > > } > > Comment from Alexei Starovoitov: > Patches 1 and 2 are missing for me, so I couldn't review properly, > but this diff looks odd. > It allows sched_cls prog type to attach to tun. > That means everything that sched_cls progs can do will be done from tun hook? We do not have an intention to modify the packet in this steering eBPF. There is just one function that unavailable for BPF_PROG_TYPE_SOCKET_FILTER that the eBPF needs to make possible to deliver the hash to the guest VM - it is 'bpf_set_hash' Does it mean that we need to define a new eBPF type for socket filter operations + set_hash? Our problem is that the eBPF calculates 32-bit hash, 16-bit queue index and 8-bit of hash type. But it is able to return only 32-bit integer, so in this set of patches the eBPF returns queue index and hash type and saves the hash in skb->hash using bpf_set_hash(). If this is unacceptable, can you please recommend a better solution? > sched_cls assumes l2 and can modify the packet. The steering eBPF in TUN module also assumes l2. > I think crashes are inevitable. > > > -- > > 2.17.1 > >