Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:35244 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbeLIVzW (ORCPT ); Sun, 9 Dec 2018 16:55:22 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "John Fastabend" , "Daniel Borkmann" , "David S. Miller" , "Alexei Starovoitov" Date: Sun, 09 Dec 2018 21:50:33 +0000 Message-ID: Subject: [PATCH 3.16 241/328] bpf, net: add skb_mac_header_len helper In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: 3.16.62-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann commit 0daf4349406074fc03e4889ba5e97e6fb5311bab upstream. Add a small skb_mac_header_len() helper similarly as the skb_network_header_len() we have and replace open coded places in BPF's bpf_skb_change_proto() helper. Will also be used in upcoming work. Signed-off-by: Daniel Borkmann Acked-by: John Fastabend Acked-by: Alexei Starovoitov Signed-off-by: David S. Miller [bwh: Backported to 3.16: drop changes in bpf] Signed-off-by: Ben Hutchings --- --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1801,6 +1801,11 @@ static inline unsigned char *skb_mac_hea return skb->head + skb->mac_header; } +static inline u32 skb_mac_header_len(const struct sk_buff *skb) +{ + return skb->network_header - skb->mac_header; +} + static inline int skb_mac_header_was_set(const struct sk_buff *skb) { return skb->mac_header != (typeof(skb->mac_header))~0U;