[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAF=yD-KR+=h94ccMeeB-CBwQQQvp+BLv9H=FawNE_nE3e4uZgg@mail.gmail.com>
Date: Tue, 5 Feb 2019 15:19:09 -0500
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Stanislav Fomichev <sdf@...gle.com>
Cc: Network Development <netdev@...r.kernel.org>,
David Miller <davem@...emloft.net>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
simon.horman@...ronome.com, Willem de Bruijn <willemb@...gle.com>
Subject: Re: [RFC bpf-next 2/7] net: introduce skb_net helper
On Tue, Feb 5, 2019 at 12:57 PM Stanislav Fomichev <sdf@...gle.com> 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 <sdf@...gle.com>
> ---
> 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.
Powered by blists - more mailing lists