Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1855505pxb; Mon, 18 Jan 2021 01:31:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJwGcBA9YsR2t2XfhjgMH6e43cdwLBA0co+Y/D12Vtbm4aqY0R6XsPqSbUnvzbf1Et40kvsh X-Received: by 2002:a17:906:1689:: with SMTP id s9mr8474582ejd.500.1610962286807; Mon, 18 Jan 2021 01:31:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610962286; cv=none; d=google.com; s=arc-20160816; b=X7vf4QTjsde4jGPMCrPOE7b9DEU+A0lgaQNAfczLqXiw8w/ocWsnhpw4R3JmlBoBNE 0574dUMXNudOk0B0mezyRZ7YPdpKME2ViUZBs/yodz/vVvJAWJ54CtuU1xIDZHfMCnNW y6n04VhVsVKbkoXVhD7ZmNnMTsy4I5OhW7eINq5iRFu1GLjslaiikOUPvj9uHrSmjVPy pQTs6t+tDB1gLrTjEQ/adxWb1Bh+EfqHEuv8gLZbtCsKfTyMVePXe78q11O6ef4it5PB 61Ea6HFiGWrt9K8r4jEcHTKJzWgYP62cF9/uBmaSRA3Tpb4eJTES3VaIFQ2PHBWE+Lwj 4wpg== 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=XSK+lvyQA4uXA5xPhZ/8h6A7IFG5qSuPlS2fMmSK9uE=; b=f2AKK8uJykaa+0/rBG0SwcUa+X3Z7AXlUYJSnVLQQGKhddFGaljvKaZCZ7wmoSNqx/ tvbpzycBYO+nhXo7pNXmkbs/z7ZusUE5Os+dzExtbvfLSW9Mc3AtuEPCPbtDl1j30Rlv O7yDC1oRwj7mV9SYBfK1HSwQkJkVN9JOgTq8kjXJ64Bqd4qEUfvyCSgzTJYbd/1Eybhi Pq61BVyZk2WdsObmF8GcD7vLX4+aQZdZUgtjlILQxRgg0fkl5n7h02o6lA2/dCysqgMC XngGsRgjaQmgKEHuJTq4UGFxkqp3JENX1Kwn8Nk2M1mBjwmrHj1aMssIwK4Rd1t/6ppu fM4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@daynix-com.20150623.gappssmtp.com header.s=20150623 header.b=g0OihKEQ; 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 dj27si6127783edb.398.2021.01.18.01.31.03; Mon, 18 Jan 2021 01:31:26 -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=g0OihKEQ; 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 S2388748AbhARJXr (ORCPT + 99 others); Mon, 18 Jan 2021 04:23:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388560AbhARJRd (ORCPT ); Mon, 18 Jan 2021 04:17:33 -0500 Received: from mail-oo1-xc33.google.com (mail-oo1-xc33.google.com [IPv6:2607:f8b0:4864:20::c33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 592B5C061575 for ; Mon, 18 Jan 2021 01:16:52 -0800 (PST) Received: by mail-oo1-xc33.google.com with SMTP id j8so3948583oon.3 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=hz5RjOVRv3ykA3lvCDy17C8/EUrt48tsebEhrD68VgMXki8WbNU4nDT/dElcJ2mKO6 IZ/ghGRSMEkpd3nAjXaNbPjeXKU9RCwmRJBkI50swTsK6vSPwfFUt+9vj218einVWuuT 19rQH/fSro8odbf2rQMNvACKRod40gpinAUXQfweYQblgk4zkzAjH+OuwzIBZEytoM8h nfZA9x4i4E4dxB8HEgd/i/ecfSXpj1gGC8S8SYiH3ByerR8NrYSaMdphD4qJotl8PXNJ f1E1nA37uAW6mg/7tNlfREepXSXL0KtQMsl1fNCk/T/Wi70dRFDKc1OQT/juG33ZnYsq ayyg== X-Gm-Message-State: AOAM531iesDWj5uFYvlDATMzGWLJTcswO6XdbnNExjBiRREj2EqpSZAl 6bBvZEit7zj3Xtz1D6hMjw34OqrQsA1s4wE1tKgI7w== 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: linux-kernel@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 > > >