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

xfrm: state: remove extract_input indirection from xfrm_state_afinfo

In order to keep CONFIG_IPV6=m working, xfrm6_extract_header needs to be
duplicated. It will be removed again in a followup change when the
remaining caller is moved to net/xfrm as well.

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
a269fbfc 6d64be3d

+45 -49
-3
include/net/xfrm.h
··· 362 362 363 363 int (*output)(struct net *net, struct sock *sk, struct sk_buff *skb); 364 364 int (*output_finish)(struct sock *sk, struct sk_buff *skb); 365 - int (*extract_input)(struct xfrm_state *x, 366 - struct sk_buff *skb); 367 365 int (*extract_output)(struct xfrm_state *x, 368 366 struct sk_buff *skb); 369 367 int (*transport_finish)(struct sk_buff *skb, ··· 1585 1587 int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); 1586 1588 int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); 1587 1589 void xfrm4_local_error(struct sk_buff *skb, u32 mtu); 1588 - int xfrm6_extract_header(struct sk_buff *skb); 1589 1590 int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb); 1590 1591 int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi, 1591 1592 struct ip6_tnl *t);
-5
net/ipv4/xfrm4_input.c
··· 18 18 #include <net/ip.h> 19 19 #include <net/xfrm.h> 20 20 21 - int xfrm4_extract_input(struct xfrm_state *x, struct sk_buff *skb) 22 - { 23 - return xfrm4_extract_header(skb); 24 - } 25 - 26 21 static int xfrm4_rcv_encap_finish2(struct net *net, struct sock *sk, 27 22 struct sk_buff *skb) 28 23 {
-1
net/ipv4/xfrm4_state.c
··· 36 36 .proto = IPPROTO_IPIP, 37 37 .output = xfrm4_output, 38 38 .output_finish = xfrm4_output_finish, 39 - .extract_input = xfrm4_extract_input, 40 39 .transport_finish = xfrm4_transport_finish, 41 40 .local_error = xfrm4_local_error, 42 41 };
-5
net/ipv6/xfrm6_input.c
··· 17 17 #include <net/ipv6.h> 18 18 #include <net/xfrm.h> 19 19 20 - int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb) 21 - { 22 - return xfrm6_extract_header(skb); 23 - } 24 - 25 20 int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi, 26 21 struct ip6_tnl *t) 27 22 {
+16 -1
net/ipv6/xfrm6_output.c
··· 94 94 return ret; 95 95 } 96 96 97 + static void __xfrm6_extract_header(struct sk_buff *skb) 98 + { 99 + struct ipv6hdr *iph = ipv6_hdr(skb); 100 + 101 + XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph); 102 + XFRM_MODE_SKB_CB(skb)->id = 0; 103 + XFRM_MODE_SKB_CB(skb)->frag_off = htons(IP_DF); 104 + XFRM_MODE_SKB_CB(skb)->tos = ipv6_get_dsfield(iph); 105 + XFRM_MODE_SKB_CB(skb)->ttl = iph->hop_limit; 106 + XFRM_MODE_SKB_CB(skb)->optlen = 0; 107 + memcpy(XFRM_MODE_SKB_CB(skb)->flow_lbl, iph->flow_lbl, 108 + sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl)); 109 + } 110 + 97 111 int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb) 98 112 { 99 113 int err; ··· 118 104 119 105 XFRM_MODE_SKB_CB(skb)->protocol = ipv6_hdr(skb)->nexthdr; 120 106 121 - return xfrm6_extract_header(skb); 107 + __xfrm6_extract_header(skb); 108 + return 0; 122 109 } 123 110 124 111 int xfrm6_output_finish(struct sock *sk, struct sk_buff *skb)
-24
net/ipv6/xfrm6_state.c
··· 13 13 */ 14 14 15 15 #include <net/xfrm.h> 16 - #include <linux/pfkeyv2.h> 17 - #include <linux/ipsec.h> 18 - #include <linux/netfilter_ipv6.h> 19 - #include <linux/export.h> 20 - #include <net/dsfield.h> 21 - #include <net/ipv6.h> 22 - #include <net/addrconf.h> 23 - 24 - int xfrm6_extract_header(struct sk_buff *skb) 25 - { 26 - struct ipv6hdr *iph = ipv6_hdr(skb); 27 - 28 - XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph); 29 - XFRM_MODE_SKB_CB(skb)->id = 0; 30 - XFRM_MODE_SKB_CB(skb)->frag_off = htons(IP_DF); 31 - XFRM_MODE_SKB_CB(skb)->tos = ipv6_get_dsfield(iph); 32 - XFRM_MODE_SKB_CB(skb)->ttl = iph->hop_limit; 33 - XFRM_MODE_SKB_CB(skb)->optlen = 0; 34 - memcpy(XFRM_MODE_SKB_CB(skb)->flow_lbl, iph->flow_lbl, 35 - sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl)); 36 - 37 - return 0; 38 - } 39 16 40 17 static struct xfrm_state_afinfo xfrm6_state_afinfo = { 41 18 .family = AF_INET6, 42 19 .proto = IPPROTO_IPV6, 43 20 .output = xfrm6_output, 44 21 .output_finish = xfrm6_output_finish, 45 - .extract_input = xfrm6_extract_input, 46 22 .extract_output = xfrm6_extract_output, 47 23 .transport_finish = xfrm6_transport_finish, 48 24 .local_error = xfrm6_local_error,
+18
net/xfrm/xfrm_inout.h
··· 6 6 #ifndef XFRM_INOUT_H 7 7 #define XFRM_INOUT_H 1 8 8 9 + static inline void xfrm6_extract_header(struct sk_buff *skb) 10 + { 11 + #if IS_ENABLED(CONFIG_IPV6) 12 + struct ipv6hdr *iph = ipv6_hdr(skb); 13 + 14 + XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph); 15 + XFRM_MODE_SKB_CB(skb)->id = 0; 16 + XFRM_MODE_SKB_CB(skb)->frag_off = htons(IP_DF); 17 + XFRM_MODE_SKB_CB(skb)->tos = ipv6_get_dsfield(iph); 18 + XFRM_MODE_SKB_CB(skb)->ttl = iph->hop_limit; 19 + XFRM_MODE_SKB_CB(skb)->optlen = 0; 20 + memcpy(XFRM_MODE_SKB_CB(skb)->flow_lbl, iph->flow_lbl, 21 + sizeof(XFRM_MODE_SKB_CB(skb)->flow_lbl)); 22 + #else 23 + WARN_ON_ONCE(1); 24 + #endif 25 + } 26 + 9 27 static inline void xfrm6_beet_make_header(struct sk_buff *skb) 10 28 { 11 29 struct ipv6hdr *iph = ipv6_hdr(skb);
+11 -10
net/xfrm/xfrm_input.c
··· 353 353 static int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb) 354 354 { 355 355 const struct xfrm_mode *inner_mode = &x->inner_mode; 356 - const struct xfrm_state_afinfo *afinfo; 357 - int err = -EAFNOSUPPORT; 358 356 359 - rcu_read_lock(); 360 - afinfo = xfrm_state_afinfo_get_rcu(x->outer_mode.family); 361 - if (likely(afinfo)) 362 - err = afinfo->extract_input(x, skb); 363 - rcu_read_unlock(); 364 - 365 - if (err) 366 - return err; 357 + switch (x->outer_mode.family) { 358 + case AF_INET: 359 + xfrm4_extract_header(skb); 360 + break; 361 + case AF_INET6: 362 + xfrm6_extract_header(skb); 363 + break; 364 + default: 365 + WARN_ON_ONCE(1); 366 + return -EAFNOSUPPORT; 367 + } 367 368 368 369 if (x->sel.family == AF_UNSPEC) { 369 370 inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol);