summaryrefslogtreecommitdiff
path: root/net/xfrm/xfrm_inout.h
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2020-05-04 11:06:05 +0300
committerSteffen Klassert <steffen.klassert@secunet.com>2020-05-06 10:40:08 +0300
commit171916cbd53dec5c7b05efb56a201671d92effc1 (patch)
treed4e2e497d945076a847c10b861653da590f75127 /net/xfrm/xfrm_inout.h
parenta269fbfc4e9ffe48c1f8142e60a49b6f2e588c58 (diff)
downloadlinux-171916cbd53dec5c7b05efb56a201671d92effc1.tar.xz
xfrm: move xfrm4_extract_header to common helper
The function only initializes the XFRM CB in the skb. After previous patch xfrm4_extract_header is only called from net/xfrm/xfrm_{input,output}.c. Because of IPV6=m linker errors the ipv6 equivalent (xfrm6_extract_header) was already placed in xfrm_inout.h because we can't call functions residing in a module from the core. So do the same for the ipv4 helper and place it next to the ipv6 one. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm/xfrm_inout.h')
-rw-r--r--net/xfrm/xfrm_inout.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_inout.h b/net/xfrm/xfrm_inout.h
index e24abac92dc2..efc5e6b2e87b 100644
--- a/net/xfrm/xfrm_inout.h
+++ b/net/xfrm/xfrm_inout.h
@@ -6,6 +6,20 @@
#ifndef XFRM_INOUT_H
#define XFRM_INOUT_H 1
+static inline void xfrm4_extract_header(struct sk_buff *skb)
+{
+ const struct iphdr *iph = ip_hdr(skb);
+
+ XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph);
+ XFRM_MODE_SKB_CB(skb)->id = iph->id;
+ XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off;
+ XFRM_MODE_SKB_CB(skb)->tos = iph->tos;
+ XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl;
+ XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph);
+ memset(XFRM_MODE_SKB_CB(skb)->flow_lbl, 0,
+ sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl));
+}
+
static inline void xfrm6_extract_header(struct sk_buff *skb)
{
#if IS_ENABLED(CONFIG_IPV6)