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=-3.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_NEOMUTT autolearn=ham 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 6916EC43381 for ; Thu, 14 Feb 2019 06:38:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 329A22064C for ; Thu, 14 Feb 2019 06:38:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p5hxU21y" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405794AbfBNGiy (ORCPT ); Thu, 14 Feb 2019 01:38:54 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35124 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387576AbfBNGiy (ORCPT ); Thu, 14 Feb 2019 01:38:54 -0500 Received: by mail-pf1-f196.google.com with SMTP id z15so2584323pfa.2 for ; Wed, 13 Feb 2019 22:38:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=uaX9attJoW/ZKMDWXxtGChFIpcqZXekzSf4D2dqNFkM=; b=p5hxU21yeBCCftNoA08soZOfyhQHmgGwTf27d+utCtYdAEchcGEQJFLtgej6zRR6MZ oh15bRHlemofurqu/9G0mUTYnr6liSJE4FtNIiQ2FtXFT9i8dMCcaeiecWWbEC3/MQpD F2n/wfrckmEUvCnwnRcgZFMeskbxSZ4PclPWjL4LLJvZv42LN7wSJS4C4E2Paz2898V3 jU6nP/zj7JuFUpFL1hyYfa4qmIO3ZpeFP/ohG2MFKiC/MM+6gFjZvBjwaWz4b41HBtNf 3lCdp7cdrv/TYQxp1RlowEsunrPpGBZDC+6MNHLJucdEPmp0qr5egG3dlotrIlh16yy0 deeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=uaX9attJoW/ZKMDWXxtGChFIpcqZXekzSf4D2dqNFkM=; b=FRmi6w//n+cEV8GotkYEBgp0Xe0Sc+Nu4aAwsKxQkxBFzLRwXWzfa3XPbmLjppBp8N xlX/dt7msFYstrsY/ARFjlWkXvojgAUKCfL/6zZPB8OuHK9m9/ChR8jgeca/FoX7BJcH zX06fyYejLnk3F2exdAHQtp1Kw64+hnVWlLom6slHPy0BXHqTvO+jXymSZZw2FshR0t+ i7jZeyAemZqKAE4CNy/+YO/E7buw6V6yQX5knO9BNnihF2I/gmZyo88tTkp1+U//ttCh dv9GCIXLP+8pHmtAAg20HJusg6RXuR6s0wxPsDK3oPtJHXy3Jydwt20pyv+JkRhWKVxY O+0Q== X-Gm-Message-State: AHQUAuYkGEJpxKHqgaie0mM+BlagdnIdmbBdgmKgtnWaCLs8SMM1LCxL omJ3frlIPVWTz8oSJ1mgVBc= X-Google-Smtp-Source: AHgI3IYnvcbjAccTb2ritAjNhXALNdU+HcjLNYX4Yf6//eaTVFD1LHnpXPNHW+JIqTqD7gA8q0KR5w== X-Received: by 2002:aa7:854a:: with SMTP id y10mr2400611pfn.210.1550126333360; Wed, 13 Feb 2019 22:38:53 -0800 (PST) Received: from ast-mbp.dhcp.thefacebook.com ([2620:10d:c090:180::1:2b07]) by smtp.gmail.com with ESMTPSA id k17sm1915449pfj.92.2019.02.13.22.38.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 22:38:52 -0800 (PST) Date: Wed, 13 Feb 2019 22:38:50 -0800 From: Alexei Starovoitov To: Stanislav Fomichev Cc: Willem de Bruijn , Stanislav Fomichev , Network Development , David Miller , Alexei Starovoitov , Daniel Borkmann , simon.horman@netronome.com, Willem de Bruijn Subject: Re: [RFC bpf-next 0/7] net: flow_dissector: trigger BPF hook when called from eth_get_headlen Message-ID: <20190214063848.7zr5ph3ijp3wmjgx@ast-mbp.dhcp.thefacebook.com> References: <20190205204003.GB10769@mini-arch> <20190206004714.pz44evow5uwgvt4x@ast-mbp.dhcp.thefacebook.com> <20190206005931.GF10769@mini-arch> <20190206031215.qldeh7pfgqr3frg3@ast-mbp> <20190206035619.GG10769@mini-arch> <20190206041112.h3ccahimp2uerdfk@ast-mbp> <20190206054946.GH10769@mini-arch> <20190212170232.GB10595@mini-arch> <20190214043931.hdpddeom57rnnlhm@ast-mbp> <20190214055725.GC10595@mini-arch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190214055725.GC10595@mini-arch> User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Feb 13, 2019 at 09:57:25PM -0800, Stanislav Fomichev wrote: > > > That 'stuck with __sk_buff' is what bothers me. > I might have use the wrong word here. I don't think there is another > option to be honest. Using __sk_buff makes flow dissector programs work > with fragmented packets; good point. indeed real skb is essential. > > It's an indication that api wasn't thought through if first thing > > it needs is this fake skb hack. > > If bpf_flow.c is a realistic example of such flow dissector prog > > it means that real skb fields are accessed. > > In particular skb->vlan_proto, skb->protocol. > I do manually set skb->protocol to eth->h_proto in my proposal. This is later > correctly handled by bpf_flow.c: parse_eth_proto() is called on skb->protocol > and we correctly handle bpf_htons(ETH_P_8021Q) there. So existing > bpf_flow.c works as expected. ... > The goal of this patch series was to essentially make this skb/no-skb > context transparent to the bpf_flow.c (i.e. no changes from the user > flow programs). Adding another flow dissector for eth_get_headlen case > also seems as a no go. The problem with this thinking is assumption that bpf_flow.c is the only program. Since ctx of flow_dissector prog type is 'struct __sk_buff' all fields should be valid or the verifier has to reject access to fields that were not set. You cannot "manually set skb->protocol to eth->h_proto" in fake skb and ignore the rest.