diff mbox

[net-next,v11,1/6] net: introduce skb_transport_header_was_set()

Message ID 1467827996-32547-2-git-send-email-simon.horman@netronome.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Simon Horman July 6, 2016, 5:59 p.m. UTC
This helper resets the mac_header of an skb to a state where
skb_transport_header_was_set() will return false.

This is intended to be used with packets received on
ARPHRD_NONE devices without an Ethernet header in the inner packet.
It allows skb_transport_header_was_set to be subsequently used to
differentiate such packets from those with an Ethernet header.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
v11
* New patch
---
 include/linux/skbuff.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Pravin Shelar July 7, 2016, 8:51 p.m. UTC | #1
On Wed, Jul 6, 2016 at 10:59 AM, Simon Horman
<simon.horman@netronome.com> wrote:
> This helper resets the mac_header of an skb to a state where
> skb_transport_header_was_set() will return false.
>
> This is intended to be used with packets received on
> ARPHRD_NONE devices without an Ethernet header in the inner packet.
> It allows skb_transport_header_was_set to be subsequently used to
> differentiate such packets from those with an Ethernet header.
>
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
Acked-by: Pravin B Shelar <pshelar@ovn.org>
diff mbox

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 638b0e004310..669d63b038f6 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2170,6 +2170,11 @@  static inline void skb_reset_mac_header(struct sk_buff *skb)
 	skb->mac_header = skb->data - skb->head;
 }
 
+static inline void skb_unset_mac_header(struct sk_buff *skb)
+{
+	skb->mac_header = (typeof(skb->mac_header))~0U;
+}
+
 static inline void skb_set_mac_header(struct sk_buff *skb, const int offset)
 {
 	skb_reset_mac_header(skb);