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=-5.5 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_MUTT 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 C4349C282CB for ; Tue, 5 Feb 2019 20:40:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 925B02077B for ; Tue, 5 Feb 2019 20:40:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=fomichev-me.20150623.gappssmtp.com header.i=@fomichev-me.20150623.gappssmtp.com header.b="gkrnlBNi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728609AbfBEUkp (ORCPT ); Tue, 5 Feb 2019 15:40:45 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41957 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726547AbfBEUkp (ORCPT ); Tue, 5 Feb 2019 15:40:45 -0500 Received: by mail-pg1-f196.google.com with SMTP id m1so1896655pgq.8 for ; Tue, 05 Feb 2019 12:40:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fomichev-me.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Azqi1OU2i5hnazbee28BV/JbdNUPc1YZZWtvzOhnJCo=; b=gkrnlBNiO+Lw7hg8+Nbaiq2+qPE7XriiXD/jQ0slgP/y8l3yi0NTTKYEE1wT+uz5i1 j3ups8iMaE09WOZruM9jAiu9fEgdHuFHfZgEQM2rKA+EChzNR727o8XY0a/rkuf3JPFZ bY5ttCMYegEj8J8a5eZ3DhFqhsloSsjS7cUnDzrjrL87rPKhPLtQ4R6F0qDcMNvJiFv2 z7zuYWldYE0uggz+nBp/dtZ22llEgFCivPDE+JknTYw4mhyhrgwT6FlNRtNSiXlQwMbz 9YWPeWxBJ2vlBTJdP0JTuSqQWzficBx0iUEMZdni9H2cVMPoV4dcJaiNxdMzBY0Lv3Q7 bFGA== 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=Azqi1OU2i5hnazbee28BV/JbdNUPc1YZZWtvzOhnJCo=; b=b9wORz/kFpR5xc84yQr+ajIneQwuPmbNyRddNcpyum99/n9RXvia95SFUjFmYvwXu1 hPbZBaUVZLhtKVLhEj3QsA2BrRXoK7NAeV4QzF53y/9GtK76bjBeyAE6EKC5egFYiEQQ 2o1B/AC+M+wiQZSOyXJEKExhZkzpIo07wYkXJbIkARG74MUIfkrY4cMpO1UtQVw5xmwp 5h1EzfPEVbt2jjk3SJnGob0mpqBed5Nq3NxioztB2iI2dQv31hf9/3ZEHSu6UuE2n/mg Oz1IKLFR1YZWe8IpY4pVpby2gC8+KMPewYGx5roplt/2RUazgIyJCN3XylYRguu8Ie9n eDaA== X-Gm-Message-State: AHQUAuZDr40qFcelOvEt+M/Bl85lP8s+Qe06WI7NeG0J2IgDpVREjW71 HzegXATu1d0UiP55ZFtYUmy0+Q== X-Google-Smtp-Source: AHgI3IYhgfh7gAOeOZymPmtQBMO6i7FncwSgT646zFHtf1sFw7lum5hcrbpZXs+AAvOd6MvIu9+Tog== X-Received: by 2002:a62:5793:: with SMTP id i19mr6945948pfj.49.1549399244198; Tue, 05 Feb 2019 12:40:44 -0800 (PST) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id g11sm5126808pfo.139.2019.02.05.12.40.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 12:40:43 -0800 (PST) Date: Tue, 5 Feb 2019 12:40:42 -0800 From: Stanislav Fomichev To: Willem de Bruijn Cc: Stanislav Fomichev , Network Development , David Miller , Alexei Starovoitov , Daniel Borkmann , simon.horman@netronome.com, Willem de Bruijn Subject: Re: [RFC bpf-next 3/7] net: plumb network namespace into __skb_flow_dissect Message-ID: <20190205204042.GC10769@mini-arch> References: <20190205173629.160717-1-sdf@google.com> <20190205173629.160717-4-sdf@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.2 (2019-01-07) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 02/05, Willem de Bruijn wrote: > On Tue, Feb 5, 2019 at 12:57 PM Stanislav Fomichev wrote: > > > > This new argument will be used in the next patches for the > > eth_get_headlen use case. eth_get_headlen calls flow dissector > > with only data (without skb) so there is currently no way to > > pull attached BPF flow dissector program. With this new argument, > > we can amend the callers to explicitly pass network namespace > > so we can use attached BPF program. > > > > Note: WARN_ON_ONCE(!net) will now trigger for eth_get_headlen users. > > > > Signed-off-by: Stanislav Fomichev > > > /** > > * __skb_flow_dissect - extract the flow_keys struct and return it > > + * @net: associated network namespace, if NULL pulled from skb > > * @skb: sk_buff to extract the flow from, can be NULL if the rest are specified > > * @flow_dissector: list of keys to dissect > > * @target_container: target structure to put dissected values into > > @@ -739,7 +740,8 @@ bool __skb_flow_bpf_dissect(struct bpf_prog *prog, > > * > > * Caller must take care of zeroing target container memory. > > */ > > -bool __skb_flow_dissect(const struct sk_buff *skb, > > +bool __skb_flow_dissect(struct net *net, > > + const struct sk_buff *skb, > > struct flow_dissector *flow_dissector, > > void *target_container, > > void *data, __be16 proto, int nhoff, int hlen, > > @@ -799,12 +801,11 @@ bool __skb_flow_dissect(const struct sk_buff *skb, > > > > rcu_read_lock(); > > > > - if (skb->dev) > > - attached = rcu_dereference(dev_net(skb->dev)->flow_dissector_prog); > > - else if (skb->sk) > > - attached = rcu_dereference(sock_net(skb->sk)->flow_dissector_prog); > > - else > > - WARN_ON_ONCE(1); > > + if (!net && skb) > > + net = skb_net(skb); > > + if (net) > > + attached = rcu_dereference(net->flow_dissector_prog); > > + WARN_ON_ONCE(!net); > > Instead of this just call skb_net(skb) in all callers of > __skb_flow_dissect that are called with an skb argument directly? > > It may have to be able to handle skb == NULL args. Ack, will look into it.