summaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2019-07-05 18:01:15 -0400
committerDavid S. Miller <davem@davemloft.net>2019-07-05 18:01:15 -0400
commite3b60ffbc16feeb007d07b2b7d1da4304e98c1a3 (patch)
tree2de159d2ed3f637bc5423e82a31b7e34da032e76 /net/ipv4
parentc4cde5804d512a2f8934017dbf7df642dfbdf2ad (diff)
parentc7b37c769d2a5e711106a3c793140a4f46768e04 (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec-next
Steffen Klassert says: ==================== pull request (net-next): ipsec-next 2019-07-05 1) A lot of work to remove indirections from the xfrm code. From Florian Westphal. 2) Fix a WARN_ON with ipv6 that triggered because of a forgotten break statement. From Florian Westphal. 3) Remove xfrmi_init_net, it is not needed. From Li RongQing. Please pull or let me know if there are problems. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/ah4.c3
-rw-r--r--net/ipv4/esp4.c30
-rw-r--r--net/ipv4/esp4_offload.c4
-rw-r--r--net/ipv4/ipcomp.c3
-rw-r--r--net/ipv4/xfrm4_state.c45
-rw-r--r--net/ipv4/xfrm4_tunnel.c3
6 files changed, 6 insertions, 82 deletions
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 9c3afd550612..974179b3b314 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -590,8 +590,7 @@ static void __exit ah4_fini(void)
590{ 590{
591 if (xfrm4_protocol_deregister(&ah4_protocol, IPPROTO_AH) < 0) 591 if (xfrm4_protocol_deregister(&ah4_protocol, IPPROTO_AH) < 0)
592 pr_info("%s: can't remove protocol\n", __func__); 592 pr_info("%s: can't remove protocol\n", __func__);
593 if (xfrm_unregister_type(&ah_type, AF_INET) < 0) 593 xfrm_unregister_type(&ah_type, AF_INET);
594 pr_info("%s: can't remove xfrm type\n", __func__);
595} 594}
596 595
597module_init(ah4_init); 596module_init(ah4_init);
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index b9ae95576084..5c967764041f 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -33,8 +33,6 @@ struct esp_output_extra {
33 33
34#define ESP_SKB_CB(__skb) ((struct esp_skb_cb *)&((__skb)->cb[0])) 34#define ESP_SKB_CB(__skb) ((struct esp_skb_cb *)&((__skb)->cb[0]))
35 35
36static u32 esp4_get_mtu(struct xfrm_state *x, int mtu);
37
38/* 36/*
39 * Allocate an AEAD request structure with extra space for SG and IV. 37 * Allocate an AEAD request structure with extra space for SG and IV.
40 * 38 *
@@ -506,7 +504,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
506 struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb); 504 struct xfrm_dst *dst = (struct xfrm_dst *)skb_dst(skb);
507 u32 padto; 505 u32 padto;
508 506
509 padto = min(x->tfcpad, esp4_get_mtu(x, dst->child_mtu_cached)); 507 padto = min(x->tfcpad, xfrm_state_mtu(x, dst->child_mtu_cached));
510 if (skb->len < padto) 508 if (skb->len < padto)
511 esp.tfclen = padto - skb->len; 509 esp.tfclen = padto - skb->len;
512 } 510 }
@@ -788,28 +786,6 @@ out:
788 return err; 786 return err;
789} 787}
790 788
791static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
792{
793 struct crypto_aead *aead = x->data;
794 u32 blksize = ALIGN(crypto_aead_blocksize(aead), 4);
795 unsigned int net_adj;
796
797 switch (x->props.mode) {
798 case XFRM_MODE_TRANSPORT:
799 case XFRM_MODE_BEET:
800 net_adj = sizeof(struct iphdr);
801 break;
802 case XFRM_MODE_TUNNEL:
803 net_adj = 0;
804 break;
805 default:
806 BUG();
807 }
808
809 return ((mtu - x->props.header_len - crypto_aead_authsize(aead) -
810 net_adj) & ~(blksize - 1)) + net_adj - 2;
811}
812
813static int esp4_err(struct sk_buff *skb, u32 info) 789static int esp4_err(struct sk_buff *skb, u32 info)
814{ 790{
815 struct net *net = dev_net(skb->dev); 791 struct net *net = dev_net(skb->dev);
@@ -1035,7 +1011,6 @@ static const struct xfrm_type esp_type =
1035 .flags = XFRM_TYPE_REPLAY_PROT, 1011 .flags = XFRM_TYPE_REPLAY_PROT,
1036 .init_state = esp_init_state, 1012 .init_state = esp_init_state,
1037 .destructor = esp_destroy, 1013 .destructor = esp_destroy,
1038 .get_mtu = esp4_get_mtu,
1039 .input = esp_input, 1014 .input = esp_input,
1040 .output = esp_output, 1015 .output = esp_output,
1041}; 1016};
@@ -1066,8 +1041,7 @@ static void __exit esp4_fini(void)
1066{ 1041{
1067 if (xfrm4_protocol_deregister(&esp4_protocol, IPPROTO_ESP) < 0) 1042 if (xfrm4_protocol_deregister(&esp4_protocol, IPPROTO_ESP) < 0)
1068 pr_info("%s: can't remove protocol\n", __func__); 1043 pr_info("%s: can't remove protocol\n", __func__);
1069 if (xfrm_unregister_type(&esp_type, AF_INET) < 0) 1044 xfrm_unregister_type(&esp_type, AF_INET);
1070 pr_info("%s: can't remove xfrm type\n", __func__);
1071} 1045}
1072 1046
1073module_init(esp4_init); 1047module_init(esp4_init);
diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c
index 2e5e377f50a1..0e4a7cf6bc87 100644
--- a/net/ipv4/esp4_offload.c
+++ b/net/ipv4/esp4_offload.c
@@ -312,9 +312,7 @@ static int __init esp4_offload_init(void)
312 312
313static void __exit esp4_offload_exit(void) 313static void __exit esp4_offload_exit(void)
314{ 314{
315 if (xfrm_unregister_type_offload(&esp_type_offload, AF_INET) < 0) 315 xfrm_unregister_type_offload(&esp_type_offload, AF_INET);
316 pr_info("%s: can't remove xfrm type offload\n", __func__);
317
318 inet_del_offload(&esp4_offload, IPPROTO_ESP); 316 inet_del_offload(&esp4_offload, IPPROTO_ESP);
319} 317}
320 318
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
index 2f4cdcc13d53..59bfa3825810 100644
--- a/net/ipv4/ipcomp.c
+++ b/net/ipv4/ipcomp.c
@@ -186,8 +186,7 @@ static void __exit ipcomp4_fini(void)
186{ 186{
187 if (xfrm4_protocol_deregister(&ipcomp4_protocol, IPPROTO_COMP) < 0) 187 if (xfrm4_protocol_deregister(&ipcomp4_protocol, IPPROTO_COMP) < 0)
188 pr_info("%s: can't remove protocol\n", __func__); 188 pr_info("%s: can't remove protocol\n", __func__);
189 if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0) 189 xfrm_unregister_type(&ipcomp_type, AF_INET);
190 pr_info("%s: can't remove xfrm type\n", __func__);
191} 190}
192 191
193module_init(ipcomp4_init); 192module_init(ipcomp4_init);
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c
index 80c40b4981bb..f8ed3c3bb928 100644
--- a/net/ipv4/xfrm4_state.c
+++ b/net/ipv4/xfrm4_state.c
@@ -15,46 +15,6 @@
15#include <linux/netfilter_ipv4.h> 15#include <linux/netfilter_ipv4.h>
16#include <linux/export.h> 16#include <linux/export.h>
17 17
18static int xfrm4_init_flags(struct xfrm_state *x)
19{
20 if (xs_net(x)->ipv4.sysctl_ip_no_pmtu_disc)
21 x->props.flags |= XFRM_STATE_NOPMTUDISC;
22 return 0;
23}
24
25static void
26__xfrm4_init_tempsel(struct xfrm_selector *sel, const struct flowi *fl)
27{
28 const struct flowi4 *fl4 = &fl->u.ip4;
29
30 sel->daddr.a4 = fl4->daddr;
31 sel->saddr.a4 = fl4->saddr;
32 sel->dport = xfrm_flowi_dport(fl, &fl4->uli);
33 sel->dport_mask = htons(0xffff);
34 sel->sport = xfrm_flowi_sport(fl, &fl4->uli);
35 sel->sport_mask = htons(0xffff);
36 sel->family = AF_INET;
37 sel->prefixlen_d = 32;
38 sel->prefixlen_s = 32;
39 sel->proto = fl4->flowi4_proto;
40 sel->ifindex = fl4->flowi4_oif;
41}
42
43static void
44xfrm4_init_temprop(struct xfrm_state *x, const struct xfrm_tmpl *tmpl,
45 const xfrm_address_t *daddr, const xfrm_address_t *saddr)
46{
47 x->id = tmpl->id;
48 if (x->id.daddr.a4 == 0)
49 x->id.daddr.a4 = daddr->a4;
50 x->props.saddr = tmpl->saddr;
51 if (x->props.saddr.a4 == 0)
52 x->props.saddr.a4 = saddr->a4;
53 x->props.mode = tmpl->mode;
54 x->props.reqid = tmpl->reqid;
55 x->props.family = AF_INET;
56}
57
58int xfrm4_extract_header(struct sk_buff *skb) 18int xfrm4_extract_header(struct sk_buff *skb)
59{ 19{
60 const struct iphdr *iph = ip_hdr(skb); 20 const struct iphdr *iph = ip_hdr(skb);
@@ -74,11 +34,6 @@ int xfrm4_extract_header(struct sk_buff *skb)
74static struct xfrm_state_afinfo xfrm4_state_afinfo = { 34static struct xfrm_state_afinfo xfrm4_state_afinfo = {
75 .family = AF_INET, 35 .family = AF_INET,
76 .proto = IPPROTO_IPIP, 36 .proto = IPPROTO_IPIP,
77 .eth_proto = htons(ETH_P_IP),
78 .owner = THIS_MODULE,
79 .init_flags = xfrm4_init_flags,
80 .init_tempsel = __xfrm4_init_tempsel,
81 .init_temprop = xfrm4_init_temprop,
82 .output = xfrm4_output, 37 .output = xfrm4_output,
83 .output_finish = xfrm4_output_finish, 38 .output_finish = xfrm4_output_finish,
84 .extract_input = xfrm4_extract_input, 39 .extract_input = xfrm4_extract_input,
diff --git a/net/ipv4/xfrm4_tunnel.c b/net/ipv4/xfrm4_tunnel.c
index 5d00e54cd319..dc19aff7c2e0 100644
--- a/net/ipv4/xfrm4_tunnel.c
+++ b/net/ipv4/xfrm4_tunnel.c
@@ -108,8 +108,7 @@ static void __exit ipip_fini(void)
108 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET)) 108 if (xfrm4_tunnel_deregister(&xfrm_tunnel_handler, AF_INET))
109 pr_info("%s: can't remove xfrm handler for AF_INET\n", 109 pr_info("%s: can't remove xfrm handler for AF_INET\n",
110 __func__); 110 __func__);
111 if (xfrm_unregister_type(&ipip_type, AF_INET) < 0) 111 xfrm_unregister_type(&ipip_type, AF_INET);
112 pr_info("%s: can't remove xfrm type\n", __func__);
113} 112}
114 113
115module_init(ipip_init); 114module_init(ipip_init);