Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Florian Westphal and committed by
Steffen Klassert
171916cb a269fbfc

+14 -22
-1
include/net/xfrm.h
··· 1562 1562 #endif 1563 1563 1564 1564 void xfrm_local_error(struct sk_buff *skb, int mtu); 1565 - int xfrm4_extract_header(struct sk_buff *skb); 1566 1565 int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb); 1567 1566 int xfrm4_rcv_encap(struct sk_buff *skb, int nexthdr, __be32 spi, 1568 1567 int encap_type);
-21
net/ipv4/xfrm4_state.c
··· 8 8 * 9 9 */ 10 10 11 - #include <net/ip.h> 12 11 #include <net/xfrm.h> 13 - #include <linux/pfkeyv2.h> 14 - #include <linux/ipsec.h> 15 - #include <linux/netfilter_ipv4.h> 16 - #include <linux/export.h> 17 - 18 - int xfrm4_extract_header(struct sk_buff *skb) 19 - { 20 - const struct iphdr *iph = ip_hdr(skb); 21 - 22 - XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph); 23 - XFRM_MODE_SKB_CB(skb)->id = iph->id; 24 - XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off; 25 - XFRM_MODE_SKB_CB(skb)->tos = iph->tos; 26 - XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl; 27 - XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph); 28 - memset(XFRM_MODE_SKB_CB(skb)->flow_lbl, 0, 29 - sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl)); 30 - 31 - return 0; 32 - } 33 12 34 13 static struct xfrm_state_afinfo xfrm4_state_afinfo = { 35 14 .family = AF_INET,
+14
net/xfrm/xfrm_inout.h
··· 6 6 #ifndef XFRM_INOUT_H 7 7 #define XFRM_INOUT_H 1 8 8 9 + static inline void xfrm4_extract_header(struct sk_buff *skb) 10 + { 11 + const struct iphdr *iph = ip_hdr(skb); 12 + 13 + XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph); 14 + XFRM_MODE_SKB_CB(skb)->id = iph->id; 15 + XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off; 16 + XFRM_MODE_SKB_CB(skb)->tos = iph->tos; 17 + XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl; 18 + XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph); 19 + memset(XFRM_MODE_SKB_CB(skb)->flow_lbl, 0, 20 + sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl)); 21 + } 22 + 9 23 static inline void xfrm6_extract_header(struct sk_buff *skb) 10 24 { 11 25 #if IS_ENABLED(CONFIG_IPV6)