diff options
author | Steffen Klassert <steffen.klassert@secunet.com> | 2014-02-21 02:41:09 -0500 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2014-02-25 01:04:17 -0500 |
commit | d099160e029391de857464d987b141f30434052b (patch) | |
tree | cceae3d2e2ad43efd7658f2a17b3b53da3060d7f /net/ipv4 | |
parent | e5b56454e09a45ea6206d5253f78042c4e63f7d4 (diff) |
ipcomp4: Use the IPsec protocol multiplexer API
Switch ipcomp4 to use the new IPsec protocol multiplexer.
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/ipv4')
-rw-r--r-- | net/ipv4/ipcomp.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c index 826be4cb482a..c0855d50a3fa 100644 --- a/net/ipv4/ipcomp.c +++ b/net/ipv4/ipcomp.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <net/protocol.h> | 23 | #include <net/protocol.h> |
24 | #include <net/sock.h> | 24 | #include <net/sock.h> |
25 | 25 | ||
26 | static void ipcomp4_err(struct sk_buff *skb, u32 info) | 26 | static int ipcomp4_err(struct sk_buff *skb, u32 info) |
27 | { | 27 | { |
28 | struct net *net = dev_net(skb->dev); | 28 | struct net *net = dev_net(skb->dev); |
29 | __be32 spi; | 29 | __be32 spi; |
@@ -34,24 +34,26 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info) | |||
34 | switch (icmp_hdr(skb)->type) { | 34 | switch (icmp_hdr(skb)->type) { |
35 | case ICMP_DEST_UNREACH: | 35 | case ICMP_DEST_UNREACH: |
36 | if (icmp_hdr(skb)->code != ICMP_FRAG_NEEDED) | 36 | if (icmp_hdr(skb)->code != ICMP_FRAG_NEEDED) |
37 | return; | 37 | return 0; |
38 | case ICMP_REDIRECT: | 38 | case ICMP_REDIRECT: |
39 | break; | 39 | break; |
40 | default: | 40 | default: |
41 | return; | 41 | return 0; |
42 | } | 42 | } |
43 | 43 | ||
44 | spi = htonl(ntohs(ipch->cpi)); | 44 | spi = htonl(ntohs(ipch->cpi)); |
45 | x = xfrm_state_lookup(net, skb->mark, (const xfrm_address_t *)&iph->daddr, | 45 | x = xfrm_state_lookup(net, skb->mark, (const xfrm_address_t *)&iph->daddr, |
46 | spi, IPPROTO_COMP, AF_INET); | 46 | spi, IPPROTO_COMP, AF_INET); |
47 | if (!x) | 47 | if (!x) |
48 | return; | 48 | return 0; |
49 | 49 | ||
50 | if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) | 50 | if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) |
51 | ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0); | 51 | ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0); |
52 | else | 52 | else |
53 | ipv4_redirect(skb, net, 0, 0, IPPROTO_COMP, 0); | 53 | ipv4_redirect(skb, net, 0, 0, IPPROTO_COMP, 0); |
54 | xfrm_state_put(x); | 54 | xfrm_state_put(x); |
55 | |||
56 | return 0; | ||
55 | } | 57 | } |
56 | 58 | ||
57 | /* We always hold one tunnel user reference to indicate a tunnel */ | 59 | /* We always hold one tunnel user reference to indicate a tunnel */ |
@@ -147,6 +149,11 @@ out: | |||
147 | return err; | 149 | return err; |
148 | } | 150 | } |
149 | 151 | ||
152 | static int ipcomp4_rcv_cb(struct sk_buff *skb, int err) | ||
153 | { | ||
154 | return 0; | ||
155 | } | ||
156 | |||
150 | static const struct xfrm_type ipcomp_type = { | 157 | static const struct xfrm_type ipcomp_type = { |
151 | .description = "IPCOMP4", | 158 | .description = "IPCOMP4", |
152 | .owner = THIS_MODULE, | 159 | .owner = THIS_MODULE, |
@@ -157,11 +164,12 @@ static const struct xfrm_type ipcomp_type = { | |||
157 | .output = ipcomp_output | 164 | .output = ipcomp_output |
158 | }; | 165 | }; |
159 | 166 | ||
160 | static const struct net_protocol ipcomp4_protocol = { | 167 | static struct xfrm4_protocol ipcomp4_protocol = { |
161 | .handler = xfrm4_rcv, | 168 | .handler = xfrm4_rcv, |
169 | .input_handler = xfrm_input, | ||
170 | .cb_handler = ipcomp4_rcv_cb, | ||
162 | .err_handler = ipcomp4_err, | 171 | .err_handler = ipcomp4_err, |
163 | .no_policy = 1, | 172 | .priority = 0, |
164 | .netns_ok = 1, | ||
165 | }; | 173 | }; |
166 | 174 | ||
167 | static int __init ipcomp4_init(void) | 175 | static int __init ipcomp4_init(void) |
@@ -170,7 +178,7 @@ static int __init ipcomp4_init(void) | |||
170 | pr_info("%s: can't add xfrm type\n", __func__); | 178 | pr_info("%s: can't add xfrm type\n", __func__); |
171 | return -EAGAIN; | 179 | return -EAGAIN; |
172 | } | 180 | } |
173 | if (inet_add_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) { | 181 | if (xfrm4_protocol_register(&ipcomp4_protocol, IPPROTO_COMP) < 0) { |
174 | pr_info("%s: can't add protocol\n", __func__); | 182 | pr_info("%s: can't add protocol\n", __func__); |
175 | xfrm_unregister_type(&ipcomp_type, AF_INET); | 183 | xfrm_unregister_type(&ipcomp_type, AF_INET); |
176 | return -EAGAIN; | 184 | return -EAGAIN; |
@@ -180,7 +188,7 @@ static int __init ipcomp4_init(void) | |||
180 | 188 | ||
181 | static void __exit ipcomp4_fini(void) | 189 | static void __exit ipcomp4_fini(void) |
182 | { | 190 | { |
183 | if (inet_del_protocol(&ipcomp4_protocol, IPPROTO_COMP) < 0) | 191 | if (xfrm4_protocol_deregister(&ipcomp4_protocol, IPPROTO_COMP) < 0) |
184 | pr_info("%s: can't remove protocol\n", __func__); | 192 | pr_info("%s: can't remove protocol\n", __func__); |
185 | if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0) | 193 | if (xfrm_unregister_type(&ipcomp_type, AF_INET) < 0) |
186 | pr_info("%s: can't remove xfrm type\n", __func__); | 194 | pr_info("%s: can't remove xfrm type\n", __func__); |