From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF4E2C433E0 for ; Mon, 18 Jan 2021 10:44:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78DAB229C7 for ; Mon, 18 Jan 2021 10:44:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388497AbhARKkW (ORCPT ); Mon, 18 Jan 2021 05:40:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388557AbhARJRd (ORCPT ); Mon, 18 Jan 2021 04:17:33 -0500 Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 602CFC061757 for ; Mon, 18 Jan 2021 01:16:52 -0800 (PST) Received: by mail-oo1-xc29.google.com with SMTP id k9so3938440oop.6 for ; Mon, 18 Jan 2021 01:16:52 -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=XSK+lvyQA4uXA5xPhZ/8h6A7IFG5qSuPlS2fMmSK9uE=; b=g0OihKEQp3iql/CK/5EC0JwmqXVTR+AOVENIOuGMPFsGSeHvvkxftBiA9Mu5HHh+Dt yvdAaWFsnRmu/efRdYIFkFNmcwDY8n4XbSXOGUbzF5HMyG2W6010KLYjXpnOvsskibZO 41hEyNwNAI1zV/ra54yz7iIQq6oPLY47r80NacYWAAwb5D3RUTBWZXYtnHP66WVTtG6g 9MLMjmxBLg1sV9mbRo4JoyerLfkcZl/BKB52D6wLSbFj5QWAETS8bW05NLyQ1eOxD3DM RwBSlkQU9mbctTrNWvRgt1eLrUWZbgF/aXRyp0nsHBbGv+pc8JZJer9XJF9JbSxim1YM 0wEw== 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=XSK+lvyQA4uXA5xPhZ/8h6A7IFG5qSuPlS2fMmSK9uE=; b=btmrilEV04SLH0uKqpCq++4OnAlgVb1X/asEXK8B7usFs43gshU5qRYlFnXDOatttv RIzBbcsquIKF8WlLKEuQ1maIZs5WYJb4UCTzrK/j13itBGrbZ3mgJmwErkvwto5A8sn1 xXEEPWLCeakM8K3bB6dU9+Hakle/w0vfMJwLSU+/+EudsQv/EBJOkC/c68v2Z5lyWrZ6 DVszkxncCVSqt8DB6nwQKmcBI7Fib7M75e8FX6yQRZWfEWUwEf7iJmi+t3hOun7Xsg4w qAcsKjDgkcsDoSmHi//AP84Nsg+L8pEvUdQiRV6ylBnckQL2ZvXmzQDE5Hn+Lguti6hP JHjg== X-Gm-Message-State: AOAM5307r6dOYpdjJRjnjbzChUnQOW+VZQC2jYRqd9jEaVNXvIlZ4+lq T7XORxdF7giqr/DbVQk11erGyU+Sks+jxx9C179t5g== X-Google-Smtp-Source: ABdhPJzqTOl3MqL0bVrAhDZtCS3mLYK4WgEB46OSUFecnlcwl11ttUt9pEepSbvh3bw3kfb4oCIECDbWZljHghrIAlk= X-Received: by 2002:a4a:d396:: with SMTP id i22mr16311455oos.55.1610961411680; Mon, 18 Jan 2021 01:16:51 -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: Mon, 18 Jan 2021 11:16:40 +0200 Message-ID: Subject: Re: [RFC PATCH 3/7] tun: allow use of BPF_PROG_TYPE_SCHED_CLS program type To: Alexei Starovoitov , Network Development , LKML , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, bpf Cc: Yan Vugenfirer , Jakub Kicinski , "David S. Miller" , Jason Wang , "Michael S . Tsirkin" , Andrii Nakryiko , Daniel Borkmann , Song Liu , Martin KaFai Lau , John Fastabend , Yonghong Song , Willem de Bruijn , KP Singh , "Gustavo A . R . Silva" , Randy Dunlap , Marco Elver , decui@microsoft.com, cai@lca.pw, Pablo Neira Ayuso , Steffen Klassert , Herbert Xu , Jakub Sitnicki , Paolo Abeni Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Hello Alexei, Can you please answer the questions in the last email of this thread? Your comment will be extremely helpful. Thanks On Tue, Jan 12, 2021 at 10:55 PM Yuri Benditovich wrote: > > 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 > > >