aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorFlorian Westphal <fw@strlen.de>2019-03-29 16:16:29 -0400
committerSteffen Klassert <steffen.klassert@secunet.com>2019-04-08 03:15:02 -0400
commit1de70830066b72b6a8e259e5363f6c0bc4ba7bbc (patch)
tree7a2eee9dd471145b44de1257d52eb89a1a62b8e8 /net/ipv6
parentb3284df1c86f7ac078dcb8fb250fe3d6437e740c (diff)
xfrm: remove output2 indirection from xfrm_mode
similar to previous patch: no external module dependencies, so we can avoid the indirection by placing this in the core. This change removes the last indirection from xfrm_mode and the xfrm4|6_mode_{beet,tunnel}.c modules contain (almost) no code anymore. Before: text data bss dec hex filename 3957 136 0 4093 ffd net/xfrm/xfrm_output.o 587 44 0 631 277 net/ipv4/xfrm4_mode_beet.o 649 32 0 681 2a9 net/ipv4/xfrm4_mode_tunnel.o 625 44 0 669 29d net/ipv6/xfrm6_mode_beet.o 599 32 0 631 277 net/ipv6/xfrm6_mode_tunnel.o After: text data bss dec hex filename 5359 184 0 5543 15a7 net/xfrm/xfrm_output.o 171 24 0 195 c3 net/ipv4/xfrm4_mode_beet.o 171 24 0 195 c3 net/ipv4/xfrm4_mode_tunnel.o 172 24 0 196 c4 net/ipv6/xfrm6_mode_beet.o 172 24 0 196 c4 net/ipv6/xfrm6_mode_tunnel.o v2: fold the *encap_add functions into xfrm*_prepare_output preserve (move) output2 comment (Sabrina) use x->outer_mode->encap, not inner fix a build breakage on ppc (kbuild robot) Signed-off-by: Florian Westphal <fw@strlen.de> Reviewed-by: Sabrina Dubroca <sd@queasysnail.net> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/xfrm6_mode_beet.c58
-rw-r--r--net/ipv6/xfrm6_mode_tunnel.c36
2 files changed, 0 insertions, 94 deletions
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c
index a0537b4f62f8..1c4a76bdd889 100644
--- a/net/ipv6/xfrm6_mode_beet.c
+++ b/net/ipv6/xfrm6_mode_beet.c
@@ -19,65 +19,7 @@
19#include <net/ipv6.h> 19#include <net/ipv6.h>
20#include <net/xfrm.h> 20#include <net/xfrm.h>
21 21
22static void xfrm6_beet_make_header(struct sk_buff *skb)
23{
24 struct ipv6hdr *iph = ipv6_hdr(skb);
25
26 iph->version = 6;
27
28 memcpy(iph->flow_lbl, XFRM_MODE_SKB_CB(skb)->flow_lbl,
29 sizeof(iph->flow_lbl));
30 iph->nexthdr = XFRM_MODE_SKB_CB(skb)->protocol;
31
32 ipv6_change_dsfield(iph, 0, XFRM_MODE_SKB_CB(skb)->tos);
33 iph->hop_limit = XFRM_MODE_SKB_CB(skb)->ttl;
34}
35
36/* Add encapsulation header.
37 *
38 * The top IP header will be constructed per draft-nikander-esp-beet-mode-06.txt.
39 */
40static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb)
41{
42 struct ipv6hdr *top_iph;
43 struct ip_beet_phdr *ph;
44 int optlen, hdr_len;
45
46 hdr_len = 0;
47 optlen = XFRM_MODE_SKB_CB(skb)->optlen;
48 if (unlikely(optlen))
49 hdr_len += IPV4_BEET_PHMAXLEN - (optlen & 4);
50
51 skb_set_network_header(skb, -x->props.header_len - hdr_len);
52 if (x->sel.family != AF_INET6)
53 skb->network_header += IPV4_BEET_PHMAXLEN;
54 skb->mac_header = skb->network_header +
55 offsetof(struct ipv6hdr, nexthdr);
56 skb->transport_header = skb->network_header + sizeof(*top_iph);
57 ph = __skb_pull(skb, XFRM_MODE_SKB_CB(skb)->ihl - hdr_len);
58
59 xfrm6_beet_make_header(skb);
60
61 top_iph = ipv6_hdr(skb);
62 if (unlikely(optlen)) {
63
64 BUG_ON(optlen < 0);
65
66 ph->padlen = 4 - (optlen & 4);
67 ph->hdrlen = optlen / 8;
68 ph->nexthdr = top_iph->nexthdr;
69 if (ph->padlen)
70 memset(ph + 1, IPOPT_NOP, ph->padlen);
71
72 top_iph->nexthdr = IPPROTO_BEETPH;
73 }
74
75 top_iph->saddr = *(struct in6_addr *)&x->props.saddr;
76 top_iph->daddr = *(struct in6_addr *)&x->id.daddr;
77 return 0;
78}
79static struct xfrm_mode xfrm6_beet_mode = { 22static struct xfrm_mode xfrm6_beet_mode = {
80 .output2 = xfrm6_beet_output,
81 .owner = THIS_MODULE, 23 .owner = THIS_MODULE,
82 .encap = XFRM_MODE_BEET, 24 .encap = XFRM_MODE_BEET,
83 .flags = XFRM_MODE_FLAG_TUNNEL, 25 .flags = XFRM_MODE_FLAG_TUNNEL,
diff --git a/net/ipv6/xfrm6_mode_tunnel.c b/net/ipv6/xfrm6_mode_tunnel.c
index 79c57decb472..e5c928dd70e3 100644
--- a/net/ipv6/xfrm6_mode_tunnel.c
+++ b/net/ipv6/xfrm6_mode_tunnel.c
@@ -22,43 +22,7 @@
22 * 22 *
23 * The top IP header will be constructed per RFC 2401. 23 * The top IP header will be constructed per RFC 2401.
24 */ 24 */
25static int xfrm6_mode_tunnel_output(struct xfrm_state *x, struct sk_buff *skb)
26{
27 struct dst_entry *dst = skb_dst(skb);
28 struct ipv6hdr *top_iph;
29 int dsfield;
30
31 skb_set_inner_network_header(skb, skb_network_offset(skb));
32 skb_set_inner_transport_header(skb, skb_transport_offset(skb));
33
34 skb_set_network_header(skb, -x->props.header_len);
35 skb->mac_header = skb->network_header +
36 offsetof(struct ipv6hdr, nexthdr);
37 skb->transport_header = skb->network_header + sizeof(*top_iph);
38 top_iph = ipv6_hdr(skb);
39
40 top_iph->version = 6;
41
42 memcpy(top_iph->flow_lbl, XFRM_MODE_SKB_CB(skb)->flow_lbl,
43 sizeof(top_iph->flow_lbl));
44 top_iph->nexthdr = xfrm_af2proto(skb_dst(skb)->ops->family);
45
46 if (x->props.extra_flags & XFRM_SA_XFLAG_DONT_ENCAP_DSCP)
47 dsfield = 0;
48 else
49 dsfield = XFRM_MODE_SKB_CB(skb)->tos;
50 dsfield = INET_ECN_encapsulate(dsfield, XFRM_MODE_SKB_CB(skb)->tos);
51 if (x->props.flags & XFRM_STATE_NOECN)
52 dsfield &= ~INET_ECN_MASK;
53 ipv6_change_dsfield(top_iph, 0, dsfield);
54 top_iph->hop_limit = ip6_dst_hoplimit(xfrm_dst_child(dst));
55 top_iph->saddr = *(struct in6_addr *)&x->props.saddr;
56 top_iph->daddr = *(struct in6_addr *)&x->id.daddr;
57 return 0;
58}
59
60static struct xfrm_mode xfrm6_tunnel_mode = { 25static struct xfrm_mode xfrm6_tunnel_mode = {
61 .output2 = xfrm6_mode_tunnel_output,
62 .owner = THIS_MODULE, 26 .owner = THIS_MODULE,
63 .encap = XFRM_MODE_TUNNEL, 27 .encap = XFRM_MODE_TUNNEL,
64 .flags = XFRM_MODE_FLAG_TUNNEL, 28 .flags = XFRM_MODE_FLAG_TUNNEL,