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=-8.5 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 627C0C282CB for ; Tue, 5 Feb 2019 20:42:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 300652077B for ; Tue, 5 Feb 2019 20:42:05 +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="lLs3xGSo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726726AbfBEUmD (ORCPT ); Tue, 5 Feb 2019 15:42:03 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:42990 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbfBEUmD (ORCPT ); Tue, 5 Feb 2019 15:42:03 -0500 Received: by mail-pg1-f196.google.com with SMTP id d72so1892945pga.9 for ; Tue, 05 Feb 2019 12:42:02 -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=xN2LUXu8oXxM7iDX6idVNMXOqhic+lFRQRk72pN+Ylk=; b=lLs3xGSoMLh4pVYTjuPOx4IxaSAEHb4Jiac8nhw6Q85zFNdv9RhL2Cx5XPXRTBYGOD hcI5BRvqHL2ksId+t+ovgzH07pjbEvWbJbIGc88me4z3rCTyLUcLwpyudgCT15cfwdn9 qEYHkY/Ji8pDu/WfehYiq1DWgOPbHOPtzDjGVMHJNCAfl8xAgnlK6wmzeTro3Cf1yg2H YpdVLu4yqp0R08Mj3NGBxTYq8o0qDBjLvFjVIGP0UjpL8m90JtKSEopQ4XkCY+jWcTaK GPak8tKKDpH7v1b8nU08JYPEZoepCSU86P1JHspABb1g2rTmYH61c9WY/OKZMOvDXfUo XODQ== 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=xN2LUXu8oXxM7iDX6idVNMXOqhic+lFRQRk72pN+Ylk=; b=Q9KF2OYuGqtnn9yKUrAd31DUSrnTOpz2UrpLHCHdPI+AEFZOwlVFWN9Elhwgg2zLA+ RD07EwKQDUezG6tJnubjFcCTV2u9dwoHUB4DGxxHfOD4LbB4MeAtrDdHQ9JRY2dkqA2v zwouU1/idGEwZwmUm3t1ZFFAr4OVyAJshlBRHrNQqC3aEiSQd3pZnsnYKj1ZPyg58u/c yPutxWzS/DzcvaN2q9s9jYbw/wycS68wEHKKk4fi+4/E4loGWurNMPYnrAxF9t2W5P3E bvvZTaQjeymVJUvNvjAyoy+vEJ+TPb50FfSwrRJrSQch04hL5oozEI3l7GF5LSeB0VjS Mo3A== X-Gm-Message-State: AHQUAubfa68VskUlZYcFKaL0BGt7s500DEzRT9s+BcNroKZu34JZMRWM s0zE5K5kX4EXOKmGrcSXLMOR5g== X-Google-Smtp-Source: AHgI3Iaarv9nTkJ1LKSPHnr3sKH1OkcVHIjENcixUgucQ2xBltYPQ184wvvEv48ewH8inv0H1WQaOg== X-Received: by 2002:a63:235f:: with SMTP id u31mr6250813pgm.122.1549399322658; Tue, 05 Feb 2019 12:42:02 -0800 (PST) Received: from localhost ([2601:646:8f00:18d9:d0fa:7a4b:764f:de48]) by smtp.gmail.com with ESMTPSA id g70sm8569368pfg.98.2019.02.05.12.42.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 05 Feb 2019 12:42:02 -0800 (PST) Date: Tue, 5 Feb 2019 12:42:01 -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 2/7] net: introduce skb_net helper Message-ID: <20190205204201.GD10769@mini-arch> References: <20190205173629.160717-1-sdf@google.com> <20190205173629.160717-3-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: > > > > skb_net returns network namespace from the associated device or socket. > > > > This will be used in the next commit. > > > > Signed-off-by: Stanislav Fomichev > > --- > > include/linux/skbuff.h | 2 ++ > > net/core/skbuff.c | 10 ++++++++++ > > 2 files changed, 12 insertions(+) > > > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > > index ad883ab2762c..28723a86efdf 100644 > > --- a/include/linux/skbuff.h > > +++ b/include/linux/skbuff.h > > @@ -4343,5 +4343,7 @@ static inline __wsum lco_csum(struct sk_buff *skb) > > return csum_partial(l4_hdr, csum_start - l4_hdr, partial); > > } > > > > +struct net *skb_net(const struct sk_buff *skb); > > + > > #endif /* __KERNEL__ */ > > #endif /* _LINUX_SKBUFF_H */ > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > > index 23c9cf100bd4..016db13fa2b6 100644 > > --- a/net/core/skbuff.c > > +++ b/net/core/skbuff.c > > @@ -5585,6 +5585,16 @@ void skb_condense(struct sk_buff *skb) > > skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); > > } > > > > +struct net *skb_net(const struct sk_buff *skb) > > +{ > > + if (skb->dev) > > + return dev_net(skb->dev); > > + else if (skb->sk) > > + return sock_net(skb->sk); > > + return NULL; > > +} > > +EXPORT_SYMBOL(skb_net); > > If this needs a helper it is probably better static inline in the header. I did that initially in skbuff.h as inline, but it is missing some struct definitions, decided to go with this for RFC. Will look into inlining.