Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * xfrm_input.c |
| 4 | * |
| 5 | * Changes: |
| 6 | * YOSHIFUJI Hideaki @USAGI |
| 7 | * Split up af-specific portion |
YOSHIFUJI Hideaki | a716c11 | 2007-02-09 23:25:29 +0900 | [diff] [blame] | 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
| 10 | |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 11 | #include <linux/bottom_half.h> |
| 12 | #include <linux/interrupt.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/slab.h> |
| 14 | #include <linux/module.h> |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 15 | #include <linux/netdevice.h> |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 16 | #include <linux/percpu.h> |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 17 | #include <net/dst.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <net/ip.h> |
| 19 | #include <net/xfrm.h> |
Alexander Duyck | 049f8e2 | 2015-05-27 07:16:49 -0700 | [diff] [blame] | 20 | #include <net/ip_tunnels.h> |
| 21 | #include <net/ip6_tunnel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 23 | struct xfrm_trans_tasklet { |
| 24 | struct tasklet_struct tasklet; |
| 25 | struct sk_buff_head queue; |
| 26 | }; |
| 27 | |
| 28 | struct xfrm_trans_cb { |
| 29 | int (*finish)(struct net *net, struct sock *sk, struct sk_buff *skb); |
| 30 | }; |
| 31 | |
| 32 | #define XFRM_TRANS_SKB_CB(__skb) ((struct xfrm_trans_cb *)&((__skb)->cb[0])) |
| 33 | |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 34 | static struct kmem_cache *secpath_cachep __read_mostly; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 36 | static DEFINE_SPINLOCK(xfrm_input_afinfo_lock); |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 37 | static struct xfrm_input_afinfo const __rcu *xfrm_input_afinfo[AF_INET6 + 1]; |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 38 | |
Steffen Klassert | 1995876 | 2017-01-30 06:45:43 +0100 | [diff] [blame] | 39 | static struct gro_cells gro_cells; |
| 40 | static struct net_device xfrm_napi_dev; |
| 41 | |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 42 | static DEFINE_PER_CPU(struct xfrm_trans_tasklet, xfrm_trans_tasklet); |
| 43 | |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 44 | int xfrm_input_register_afinfo(const struct xfrm_input_afinfo *afinfo) |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 45 | { |
| 46 | int err = 0; |
| 47 | |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 48 | if (WARN_ON(afinfo->family >= ARRAY_SIZE(xfrm_input_afinfo))) |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 49 | return -EAFNOSUPPORT; |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 50 | |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 51 | spin_lock_bh(&xfrm_input_afinfo_lock); |
| 52 | if (unlikely(xfrm_input_afinfo[afinfo->family] != NULL)) |
Li RongQing | f31e8d4f | 2015-04-23 11:06:53 +0800 | [diff] [blame] | 53 | err = -EEXIST; |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 54 | else |
| 55 | rcu_assign_pointer(xfrm_input_afinfo[afinfo->family], afinfo); |
| 56 | spin_unlock_bh(&xfrm_input_afinfo_lock); |
| 57 | return err; |
| 58 | } |
| 59 | EXPORT_SYMBOL(xfrm_input_register_afinfo); |
| 60 | |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 61 | int xfrm_input_unregister_afinfo(const struct xfrm_input_afinfo *afinfo) |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 62 | { |
| 63 | int err = 0; |
| 64 | |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 65 | spin_lock_bh(&xfrm_input_afinfo_lock); |
| 66 | if (likely(xfrm_input_afinfo[afinfo->family] != NULL)) { |
| 67 | if (unlikely(xfrm_input_afinfo[afinfo->family] != afinfo)) |
| 68 | err = -EINVAL; |
| 69 | else |
| 70 | RCU_INIT_POINTER(xfrm_input_afinfo[afinfo->family], NULL); |
| 71 | } |
| 72 | spin_unlock_bh(&xfrm_input_afinfo_lock); |
| 73 | synchronize_rcu(); |
| 74 | return err; |
| 75 | } |
| 76 | EXPORT_SYMBOL(xfrm_input_unregister_afinfo); |
| 77 | |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 78 | static const struct xfrm_input_afinfo *xfrm_input_get_afinfo(unsigned int family) |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 79 | { |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 80 | const struct xfrm_input_afinfo *afinfo; |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 81 | |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 82 | if (WARN_ON_ONCE(family >= ARRAY_SIZE(xfrm_input_afinfo))) |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 83 | return NULL; |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 84 | |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 85 | rcu_read_lock(); |
| 86 | afinfo = rcu_dereference(xfrm_input_afinfo[family]); |
| 87 | if (unlikely(!afinfo)) |
| 88 | rcu_read_unlock(); |
| 89 | return afinfo; |
| 90 | } |
| 91 | |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 92 | static int xfrm_rcv_cb(struct sk_buff *skb, unsigned int family, u8 protocol, |
| 93 | int err) |
| 94 | { |
| 95 | int ret; |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 96 | const struct xfrm_input_afinfo *afinfo = xfrm_input_get_afinfo(family); |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 97 | |
| 98 | if (!afinfo) |
| 99 | return -EAFNOSUPPORT; |
| 100 | |
| 101 | ret = afinfo->callback(skb, protocol, err); |
Florian Westphal | 960fdfd | 2017-02-07 14:52:30 +0100 | [diff] [blame] | 102 | rcu_read_unlock(); |
Steffen Klassert | 2f32b51 | 2014-03-14 07:28:07 +0100 | [diff] [blame] | 103 | |
| 104 | return ret; |
| 105 | } |
| 106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | void __secpath_destroy(struct sec_path *sp) |
| 108 | { |
| 109 | int i; |
| 110 | for (i = 0; i < sp->len; i++) |
Herbert Xu | dbe5b4a | 2006-04-01 00:54:16 -0800 | [diff] [blame] | 111 | xfrm_state_put(sp->xvec[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | kmem_cache_free(secpath_cachep, sp); |
| 113 | } |
| 114 | EXPORT_SYMBOL(__secpath_destroy); |
| 115 | |
| 116 | struct sec_path *secpath_dup(struct sec_path *src) |
| 117 | { |
| 118 | struct sec_path *sp; |
| 119 | |
Christoph Lameter | 54e6ecb | 2006-12-06 20:33:16 -0800 | [diff] [blame] | 120 | sp = kmem_cache_alloc(secpath_cachep, GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | if (!sp) |
| 122 | return NULL; |
| 123 | |
| 124 | sp->len = 0; |
Steffen Klassert | 54ef207 | 2017-02-15 09:39:54 +0100 | [diff] [blame] | 125 | sp->olen = 0; |
| 126 | |
Steffen Klassert | d77e38e | 2017-04-14 10:06:10 +0200 | [diff] [blame] | 127 | memset(sp->ovec, 0, sizeof(sp->ovec[XFRM_MAX_OFFLOAD_DEPTH])); |
| 128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | if (src) { |
| 130 | int i; |
| 131 | |
| 132 | memcpy(sp, src, sizeof(*sp)); |
| 133 | for (i = 0; i < sp->len; i++) |
Herbert Xu | dbe5b4a | 2006-04-01 00:54:16 -0800 | [diff] [blame] | 134 | xfrm_state_hold(sp->xvec[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
Reshetova, Elena | 55eabed | 2017-07-04 15:53:23 +0300 | [diff] [blame] | 136 | refcount_set(&sp->refcnt, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | return sp; |
| 138 | } |
| 139 | EXPORT_SYMBOL(secpath_dup); |
| 140 | |
Steffen Klassert | b0fcee8 | 2017-02-15 09:39:24 +0100 | [diff] [blame] | 141 | int secpath_set(struct sk_buff *skb) |
| 142 | { |
| 143 | struct sec_path *sp; |
| 144 | |
| 145 | /* Allocate new secpath or COW existing one. */ |
Reshetova, Elena | 55eabed | 2017-07-04 15:53:23 +0300 | [diff] [blame] | 146 | if (!skb->sp || refcount_read(&skb->sp->refcnt) != 1) { |
Steffen Klassert | b0fcee8 | 2017-02-15 09:39:24 +0100 | [diff] [blame] | 147 | sp = secpath_dup(skb->sp); |
| 148 | if (!sp) |
| 149 | return -ENOMEM; |
| 150 | |
| 151 | if (skb->sp) |
| 152 | secpath_put(skb->sp); |
| 153 | skb->sp = sp; |
| 154 | } |
| 155 | return 0; |
| 156 | } |
| 157 | EXPORT_SYMBOL(secpath_set); |
| 158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | /* Fetch spi and seq from ipsec header */ |
| 160 | |
Al Viro | 6067b2b | 2006-09-27 18:47:59 -0700 | [diff] [blame] | 161 | int xfrm_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
| 163 | int offset, offset_seq; |
Herbert Xu | 4407250 | 2007-10-17 21:30:34 -0700 | [diff] [blame] | 164 | int hlen; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | |
| 166 | switch (nexthdr) { |
| 167 | case IPPROTO_AH: |
Herbert Xu | 4407250 | 2007-10-17 21:30:34 -0700 | [diff] [blame] | 168 | hlen = sizeof(struct ip_auth_hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | offset = offsetof(struct ip_auth_hdr, spi); |
| 170 | offset_seq = offsetof(struct ip_auth_hdr, seq_no); |
| 171 | break; |
| 172 | case IPPROTO_ESP: |
Herbert Xu | 4407250 | 2007-10-17 21:30:34 -0700 | [diff] [blame] | 173 | hlen = sizeof(struct ip_esp_hdr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | offset = offsetof(struct ip_esp_hdr, spi); |
| 175 | offset_seq = offsetof(struct ip_esp_hdr, seq_no); |
| 176 | break; |
| 177 | case IPPROTO_COMP: |
| 178 | if (!pskb_may_pull(skb, sizeof(struct ip_comp_hdr))) |
| 179 | return -EINVAL; |
Weilong Chen | 3e94c2d | 2013-12-24 09:43:47 +0800 | [diff] [blame] | 180 | *spi = htonl(ntohs(*(__be16 *)(skb_transport_header(skb) + 2))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | *seq = 0; |
| 182 | return 0; |
| 183 | default: |
| 184 | return 1; |
| 185 | } |
| 186 | |
Herbert Xu | 4407250 | 2007-10-17 21:30:34 -0700 | [diff] [blame] | 187 | if (!pskb_may_pull(skb, hlen)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | return -EINVAL; |
| 189 | |
Weilong Chen | 3e94c2d | 2013-12-24 09:43:47 +0800 | [diff] [blame] | 190 | *spi = *(__be32 *)(skb_transport_header(skb) + offset); |
| 191 | *seq = *(__be32 *)(skb_transport_header(skb) + offset_seq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | return 0; |
| 193 | } |
Steffen Klassert | 1e29537 | 2017-02-15 09:39:49 +0100 | [diff] [blame] | 194 | EXPORT_SYMBOL(xfrm_parse_spi); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
Herbert Xu | 227620e | 2007-11-13 21:41:28 -0800 | [diff] [blame] | 196 | int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb) |
| 197 | { |
Kazunori MIYAZAWA | df9dcb4 | 2008-03-24 14:51:51 -0700 | [diff] [blame] | 198 | struct xfrm_mode *inner_mode = x->inner_mode; |
Herbert Xu | 227620e | 2007-11-13 21:41:28 -0800 | [diff] [blame] | 199 | int err; |
| 200 | |
| 201 | err = x->outer_mode->afinfo->extract_input(x, skb); |
| 202 | if (err) |
| 203 | return err; |
| 204 | |
Kazunori MIYAZAWA | df9dcb4 | 2008-03-24 14:51:51 -0700 | [diff] [blame] | 205 | if (x->sel.family == AF_UNSPEC) { |
| 206 | inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol); |
| 207 | if (inner_mode == NULL) |
| 208 | return -EAFNOSUPPORT; |
| 209 | } |
| 210 | |
| 211 | skb->protocol = inner_mode->afinfo->eth_proto; |
| 212 | return inner_mode->input2(x, skb); |
Herbert Xu | 227620e | 2007-11-13 21:41:28 -0800 | [diff] [blame] | 213 | } |
| 214 | EXPORT_SYMBOL(xfrm_prepare_input); |
| 215 | |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 216 | int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) |
| 217 | { |
Alexey Dobriyan | bd235e3 | 2008-11-25 17:37:56 -0800 | [diff] [blame] | 218 | struct net *net = dev_net(skb->dev); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 219 | int err; |
| 220 | __be32 seq; |
Steffen Klassert | 2cd0846 | 2011-03-08 00:09:51 +0000 | [diff] [blame] | 221 | __be32 seq_hi; |
Steffen Klassert | 3328715 | 2014-02-21 08:41:08 +0100 | [diff] [blame] | 222 | struct xfrm_state *x = NULL; |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 223 | xfrm_address_t *daddr; |
Kazunori MIYAZAWA | df9dcb4 | 2008-03-24 14:51:51 -0700 | [diff] [blame] | 224 | struct xfrm_mode *inner_mode; |
Alexander Duyck | 049f8e2 | 2015-05-27 07:16:49 -0700 | [diff] [blame] | 225 | u32 mark = skb->mark; |
Aviv Heller | 4ce3dbe | 2017-11-28 19:55:40 +0200 | [diff] [blame] | 226 | unsigned int family = AF_UNSPEC; |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 227 | int decaps = 0; |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 228 | int async = 0; |
Steffen Klassert | 7785bba | 2017-02-15 09:40:00 +0100 | [diff] [blame] | 229 | bool xfrm_gro = false; |
Steffen Klassert | d77e38e | 2017-04-14 10:06:10 +0200 | [diff] [blame] | 230 | bool crypto_done = false; |
| 231 | struct xfrm_offload *xo = xfrm_offload(skb); |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 232 | |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 233 | if (encap_type < 0) { |
Herbert Xu | 0050112 | 2007-12-11 01:53:43 -0800 | [diff] [blame] | 234 | x = xfrm_input_state(skb); |
Aviv Heller | 4ce3dbe | 2017-11-28 19:55:40 +0200 | [diff] [blame] | 235 | |
| 236 | if (unlikely(x->km.state != XFRM_STATE_VALID)) { |
| 237 | if (x->km.state == XFRM_STATE_ACQ) |
| 238 | XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR); |
| 239 | else |
| 240 | XFRM_INC_STATS(net, |
| 241 | LINUX_MIB_XFRMINSTATEINVALID); |
| 242 | goto drop; |
| 243 | } |
| 244 | |
Steffen Klassert | 3328715 | 2014-02-21 08:41:08 +0100 | [diff] [blame] | 245 | family = x->outer_mode->afinfo->family; |
Steffen Klassert | 7785bba | 2017-02-15 09:40:00 +0100 | [diff] [blame] | 246 | |
| 247 | /* An encap_type of -1 indicates async resumption. */ |
| 248 | if (encap_type == -1) { |
| 249 | async = 1; |
| 250 | seq = XFRM_SKB_CB(skb)->seq.input.low; |
| 251 | goto resume; |
| 252 | } |
Steffen Klassert | bcd1f8a | 2017-04-14 10:07:49 +0200 | [diff] [blame] | 253 | |
Steffen Klassert | 7785bba | 2017-02-15 09:40:00 +0100 | [diff] [blame] | 254 | /* encap_type < -1 indicates a GRO call. */ |
| 255 | encap_type = 0; |
| 256 | seq = XFRM_SPI_SKB_CB(skb)->seq; |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 257 | |
Steffen Klassert | bcd1f8a | 2017-04-14 10:07:49 +0200 | [diff] [blame] | 258 | if (xo && (xo->flags & CRYPTO_DONE)) { |
| 259 | crypto_done = true; |
Steffen Klassert | bcd1f8a | 2017-04-14 10:07:49 +0200 | [diff] [blame] | 260 | family = XFRM_SPI_SKB_CB(skb)->family; |
Steffen Klassert | d77e38e | 2017-04-14 10:06:10 +0200 | [diff] [blame] | 261 | |
Steffen Klassert | bcd1f8a | 2017-04-14 10:07:49 +0200 | [diff] [blame] | 262 | if (!(xo->status & CRYPTO_SUCCESS)) { |
| 263 | if (xo->status & |
| 264 | (CRYPTO_TRANSPORT_AH_AUTH_FAILED | |
| 265 | CRYPTO_TRANSPORT_ESP_AUTH_FAILED | |
| 266 | CRYPTO_TUNNEL_AH_AUTH_FAILED | |
| 267 | CRYPTO_TUNNEL_ESP_AUTH_FAILED)) { |
Steffen Klassert | d77e38e | 2017-04-14 10:06:10 +0200 | [diff] [blame] | 268 | |
Steffen Klassert | bcd1f8a | 2017-04-14 10:07:49 +0200 | [diff] [blame] | 269 | xfrm_audit_state_icvfail(x, skb, |
| 270 | x->type->proto); |
| 271 | x->stats.integrity_failed++; |
| 272 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEPROTOERROR); |
| 273 | goto drop; |
| 274 | } |
| 275 | |
Yossi Kuperman | 47ebcc0 | 2017-08-30 11:30:39 +0300 | [diff] [blame] | 276 | if (xo->status & CRYPTO_INVALID_PROTOCOL) { |
| 277 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEPROTOERROR); |
| 278 | goto drop; |
| 279 | } |
| 280 | |
Steffen Klassert | bcd1f8a | 2017-04-14 10:07:49 +0200 | [diff] [blame] | 281 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINBUFFERERROR); |
Steffen Klassert | d77e38e | 2017-04-14 10:06:10 +0200 | [diff] [blame] | 282 | goto drop; |
| 283 | } |
| 284 | |
Steffen Klassert | bcd1f8a | 2017-04-14 10:07:49 +0200 | [diff] [blame] | 285 | if ((err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) { |
| 286 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR); |
| 287 | goto drop; |
| 288 | } |
Steffen Klassert | d77e38e | 2017-04-14 10:06:10 +0200 | [diff] [blame] | 289 | } |
| 290 | |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 291 | goto lock; |
| 292 | } |
| 293 | |
Steffen Klassert | 3328715 | 2014-02-21 08:41:08 +0100 | [diff] [blame] | 294 | family = XFRM_SPI_SKB_CB(skb)->family; |
| 295 | |
Alexander Duyck | 049f8e2 | 2015-05-27 07:16:49 -0700 | [diff] [blame] | 296 | /* if tunnel is present override skb->mark value with tunnel i_key */ |
Alexey Kodanev | 1625f45 | 2016-08-10 13:54:57 +0300 | [diff] [blame] | 297 | switch (family) { |
| 298 | case AF_INET: |
| 299 | if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4) |
Alexander Duyck | 049f8e2 | 2015-05-27 07:16:49 -0700 | [diff] [blame] | 300 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4->parms.i_key); |
Alexey Kodanev | 1625f45 | 2016-08-10 13:54:57 +0300 | [diff] [blame] | 301 | break; |
| 302 | case AF_INET6: |
| 303 | if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6) |
Alexander Duyck | 049f8e2 | 2015-05-27 07:16:49 -0700 | [diff] [blame] | 304 | mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6->parms.i_key); |
Alexey Kodanev | 1625f45 | 2016-08-10 13:54:57 +0300 | [diff] [blame] | 305 | break; |
Alexander Duyck | 049f8e2 | 2015-05-27 07:16:49 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Steffen Klassert | b0fcee8 | 2017-02-15 09:39:24 +0100 | [diff] [blame] | 308 | err = secpath_set(skb); |
| 309 | if (err) { |
| 310 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINERROR); |
| 311 | goto drop; |
Herbert Xu | b2aa5e9 | 2007-11-13 21:44:55 -0800 | [diff] [blame] | 312 | } |
| 313 | |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 314 | seq = 0; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 315 | if (!spi && (err = xfrm_parse_spi(skb, nexthdr, &spi, &seq)) != 0) { |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 316 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 317 | goto drop; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 318 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 319 | |
Florian Westphal | cb79a18 | 2017-11-01 20:30:49 +0100 | [diff] [blame] | 320 | daddr = (xfrm_address_t *)(skb_network_header(skb) + |
| 321 | XFRM_SPI_SKB_CB(skb)->daddroff); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 322 | do { |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 323 | if (skb->sp->len == XFRM_MAX_DEPTH) { |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 324 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINBUFFERERROR); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 325 | goto drop; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 326 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 327 | |
Alexander Duyck | 049f8e2 | 2015-05-27 07:16:49 -0700 | [diff] [blame] | 328 | x = xfrm_state_lookup(net, mark, daddr, spi, nexthdr, family); |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 329 | if (x == NULL) { |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 330 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINNOSTATES); |
Paul Moore | afeb14b | 2007-12-21 14:58:11 -0800 | [diff] [blame] | 331 | xfrm_audit_state_notfound(skb, family, spi, seq); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 332 | goto drop; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 333 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 334 | |
Herbert Xu | b2aa5e9 | 2007-11-13 21:44:55 -0800 | [diff] [blame] | 335 | skb->sp->xvec[skb->sp->len++] = x; |
| 336 | |
Steffen Klassert | 7785bba | 2017-02-15 09:40:00 +0100 | [diff] [blame] | 337 | lock: |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 338 | spin_lock(&x->lock); |
Fan Du | 4c4d41f | 2013-06-06 10:15:54 +0800 | [diff] [blame] | 339 | |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 340 | if (unlikely(x->km.state != XFRM_STATE_VALID)) { |
Li RongQing | dc0565c | 2015-04-24 16:49:31 +0800 | [diff] [blame] | 341 | if (x->km.state == XFRM_STATE_ACQ) |
| 342 | XFRM_INC_STATS(net, LINUX_MIB_XFRMACQUIREERROR); |
| 343 | else |
| 344 | XFRM_INC_STATS(net, |
| 345 | LINUX_MIB_XFRMINSTATEINVALID); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 346 | goto drop_unlock; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 347 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 348 | |
David S. Miller | 3de77cf | 2008-12-18 19:23:56 -0800 | [diff] [blame] | 349 | if ((x->encap ? x->encap->encap_type : 0) != encap_type) { |
| 350 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMISMATCH); |
| 351 | goto drop_unlock; |
| 352 | } |
| 353 | |
Steffen Klassert | 36ae014 | 2011-03-28 19:45:52 +0000 | [diff] [blame] | 354 | if (x->repl->check(x, skb, seq)) { |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 355 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 356 | goto drop_unlock; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 357 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 358 | |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 359 | if (xfrm_state_check_expire(x)) { |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 360 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEEXPIRED); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 361 | goto drop_unlock; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 362 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 363 | |
Herbert Xu | 0ebea8e | 2007-11-13 21:45:58 -0800 | [diff] [blame] | 364 | spin_unlock(&x->lock); |
| 365 | |
Alexey Dobriyan | 68c11e9 | 2015-04-02 10:58:24 +0300 | [diff] [blame] | 366 | if (xfrm_tunnel_check(skb, x, family)) { |
| 367 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMODEERROR); |
| 368 | goto drop; |
| 369 | } |
| 370 | |
Steffen Klassert | 2cd0846 | 2011-03-08 00:09:51 +0000 | [diff] [blame] | 371 | seq_hi = htonl(xfrm_replay_seqhi(x, seq)); |
| 372 | |
Steffen Klassert | 1ce3644 | 2011-03-08 00:06:31 +0000 | [diff] [blame] | 373 | XFRM_SKB_CB(skb)->seq.input.low = seq; |
Steffen Klassert | 2cd0846 | 2011-03-08 00:09:51 +0000 | [diff] [blame] | 374 | XFRM_SKB_CB(skb)->seq.input.hi = seq_hi; |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 375 | |
Steffen Klassert | 3bc0732 | 2011-03-15 21:08:28 +0000 | [diff] [blame] | 376 | skb_dst_force(skb); |
subashab@codeaurora.org | 071d36b | 2016-03-23 22:39:50 -0600 | [diff] [blame] | 377 | dev_hold(skb->dev); |
Steffen Klassert | 3bc0732 | 2011-03-15 21:08:28 +0000 | [diff] [blame] | 378 | |
Steffen Klassert | d77e38e | 2017-04-14 10:06:10 +0200 | [diff] [blame] | 379 | if (crypto_done) |
| 380 | nexthdr = x->type_offload->input_tail(x, skb); |
| 381 | else |
| 382 | nexthdr = x->type->input(x, skb); |
Herbert Xu | 0ebea8e | 2007-11-13 21:45:58 -0800 | [diff] [blame] | 383 | |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 384 | if (nexthdr == -EINPROGRESS) |
| 385 | return 0; |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 386 | resume: |
subashab@codeaurora.org | 071d36b | 2016-03-23 22:39:50 -0600 | [diff] [blame] | 387 | dev_put(skb->dev); |
| 388 | |
Herbert Xu | 0ebea8e | 2007-11-13 21:45:58 -0800 | [diff] [blame] | 389 | spin_lock(&x->lock); |
Herbert Xu | 668dc8a | 2007-12-16 15:55:02 -0800 | [diff] [blame] | 390 | if (nexthdr <= 0) { |
Herbert Xu | 9dd3245 | 2007-12-30 21:10:30 -0800 | [diff] [blame] | 391 | if (nexthdr == -EBADMSG) { |
| 392 | xfrm_audit_state_icvfail(x, skb, |
| 393 | x->type->proto); |
Herbert Xu | 668dc8a | 2007-12-16 15:55:02 -0800 | [diff] [blame] | 394 | x->stats.integrity_failed++; |
Herbert Xu | 9dd3245 | 2007-12-30 21:10:30 -0800 | [diff] [blame] | 395 | } |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 396 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEPROTOERROR); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 397 | goto drop_unlock; |
Herbert Xu | 668dc8a | 2007-12-16 15:55:02 -0800 | [diff] [blame] | 398 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 399 | |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 400 | /* only the first xfrm gets the encap type */ |
| 401 | encap_type = 0; |
| 402 | |
Steffen Klassert | 3b59df4 | 2012-09-04 00:03:29 +0000 | [diff] [blame] | 403 | if (async && x->repl->recheck(x, skb, seq)) { |
Steffen Klassert | bcf66bf | 2011-09-20 23:38:58 +0000 | [diff] [blame] | 404 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR); |
| 405 | goto drop_unlock; |
| 406 | } |
| 407 | |
Steffen Klassert | 9fdc488 | 2011-03-08 00:08:32 +0000 | [diff] [blame] | 408 | x->repl->advance(x, seq); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 409 | |
| 410 | x->curlft.bytes += skb->len; |
| 411 | x->curlft.packets++; |
| 412 | |
| 413 | spin_unlock(&x->lock); |
| 414 | |
Herbert Xu | 60d5fcf | 2007-11-19 18:47:58 -0800 | [diff] [blame] | 415 | XFRM_MODE_SKB_CB(skb)->protocol = nexthdr; |
| 416 | |
Kazunori MIYAZAWA | df9dcb4 | 2008-03-24 14:51:51 -0700 | [diff] [blame] | 417 | inner_mode = x->inner_mode; |
| 418 | |
| 419 | if (x->sel.family == AF_UNSPEC) { |
| 420 | inner_mode = xfrm_ip2inner_mode(x, XFRM_MODE_SKB_CB(skb)->protocol); |
Steffen Klassert | cb866e3 | 2015-10-23 07:52:58 +0200 | [diff] [blame] | 421 | if (inner_mode == NULL) { |
| 422 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMODEERROR); |
Kazunori MIYAZAWA | df9dcb4 | 2008-03-24 14:51:51 -0700 | [diff] [blame] | 423 | goto drop; |
Steffen Klassert | cb866e3 | 2015-10-23 07:52:58 +0200 | [diff] [blame] | 424 | } |
Kazunori MIYAZAWA | df9dcb4 | 2008-03-24 14:51:51 -0700 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | if (inner_mode->input(x, skb)) { |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 428 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMODEERROR); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 429 | goto drop; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 430 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 431 | |
| 432 | if (x->outer_mode->flags & XFRM_MODE_FLAG_TUNNEL) { |
| 433 | decaps = 1; |
| 434 | break; |
| 435 | } |
| 436 | |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 437 | /* |
| 438 | * We need the inner address. However, we only get here for |
| 439 | * transport mode so the outer address is identical. |
| 440 | */ |
| 441 | daddr = &x->id.daddr; |
Herbert Xu | 2fcb45b | 2007-12-03 22:54:12 -0800 | [diff] [blame] | 442 | family = x->outer_mode->afinfo->family; |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 443 | |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 444 | err = xfrm_parse_spi(skb, nexthdr, &spi, &seq); |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 445 | if (err < 0) { |
Alexey Dobriyan | 59c9940 | 2008-11-25 17:59:52 -0800 | [diff] [blame] | 446 | XFRM_INC_STATS(net, LINUX_MIB_XFRMINHDRERROR); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 447 | goto drop; |
Masahide NAKAMURA | 0aa6477 | 2007-12-20 20:43:36 -0800 | [diff] [blame] | 448 | } |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 449 | } while (!err); |
| 450 | |
Steffen Klassert | 3328715 | 2014-02-21 08:41:08 +0100 | [diff] [blame] | 451 | err = xfrm_rcv_cb(skb, family, x->type->proto, 0); |
| 452 | if (err) |
| 453 | goto drop; |
| 454 | |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 455 | nf_reset(skb); |
| 456 | |
| 457 | if (decaps) { |
Alexey Kodanev | 23e9fcf | 2017-09-12 14:53:46 +0300 | [diff] [blame] | 458 | if (skb->sp) |
| 459 | skb->sp->olen = 0; |
Eric Dumazet | adf3090 | 2009-06-02 05:19:30 +0000 | [diff] [blame] | 460 | skb_dst_drop(skb); |
Steffen Klassert | 1995876 | 2017-01-30 06:45:43 +0100 | [diff] [blame] | 461 | gro_cells_receive(&gro_cells, skb); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 462 | return 0; |
| 463 | } else { |
Steffen Klassert | 7785bba | 2017-02-15 09:40:00 +0100 | [diff] [blame] | 464 | xo = xfrm_offload(skb); |
| 465 | if (xo) |
| 466 | xfrm_gro = xo->flags & XFRM_GRO; |
| 467 | |
Sabrina Dubroca | cfcf99f | 2017-04-27 12:03:37 +0200 | [diff] [blame] | 468 | err = x->inner_mode->afinfo->transport_finish(skb, xfrm_gro || async); |
Steffen Klassert | 7785bba | 2017-02-15 09:40:00 +0100 | [diff] [blame] | 469 | if (xfrm_gro) { |
Alexey Kodanev | 23e9fcf | 2017-09-12 14:53:46 +0300 | [diff] [blame] | 470 | if (skb->sp) |
| 471 | skb->sp->olen = 0; |
Steffen Klassert | 7785bba | 2017-02-15 09:40:00 +0100 | [diff] [blame] | 472 | skb_dst_drop(skb); |
| 473 | gro_cells_receive(&gro_cells, skb); |
| 474 | return err; |
| 475 | } |
| 476 | |
| 477 | return err; |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | drop_unlock: |
| 481 | spin_unlock(&x->lock); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 482 | drop: |
Steffen Klassert | 3328715 | 2014-02-21 08:41:08 +0100 | [diff] [blame] | 483 | xfrm_rcv_cb(skb, family, x && x->type ? x->type->proto : nexthdr, -1); |
Herbert Xu | 716062f | 2007-11-13 21:44:23 -0800 | [diff] [blame] | 484 | kfree_skb(skb); |
| 485 | return 0; |
| 486 | } |
| 487 | EXPORT_SYMBOL(xfrm_input); |
| 488 | |
Herbert Xu | 1bf06cd | 2007-11-19 18:50:17 -0800 | [diff] [blame] | 489 | int xfrm_input_resume(struct sk_buff *skb, int nexthdr) |
| 490 | { |
| 491 | return xfrm_input(skb, nexthdr, 0, -1); |
| 492 | } |
| 493 | EXPORT_SYMBOL(xfrm_input_resume); |
| 494 | |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 495 | static void xfrm_trans_reinject(unsigned long data) |
| 496 | { |
| 497 | struct xfrm_trans_tasklet *trans = (void *)data; |
| 498 | struct sk_buff_head queue; |
| 499 | struct sk_buff *skb; |
| 500 | |
| 501 | __skb_queue_head_init(&queue); |
| 502 | skb_queue_splice_init(&trans->queue, &queue); |
| 503 | |
| 504 | while ((skb = __skb_dequeue(&queue))) |
| 505 | XFRM_TRANS_SKB_CB(skb)->finish(dev_net(skb->dev), NULL, skb); |
| 506 | } |
| 507 | |
| 508 | int xfrm_trans_queue(struct sk_buff *skb, |
| 509 | int (*finish)(struct net *, struct sock *, |
| 510 | struct sk_buff *)) |
| 511 | { |
| 512 | struct xfrm_trans_tasklet *trans; |
| 513 | |
| 514 | trans = this_cpu_ptr(&xfrm_trans_tasklet); |
| 515 | |
| 516 | if (skb_queue_len(&trans->queue) >= netdev_max_backlog) |
| 517 | return -ENOBUFS; |
| 518 | |
| 519 | XFRM_TRANS_SKB_CB(skb)->finish = finish; |
Herbert Xu | d16b46e | 2018-01-04 22:25:07 +1100 | [diff] [blame] | 520 | __skb_queue_tail(&trans->queue, skb); |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 521 | tasklet_schedule(&trans->tasklet); |
| 522 | return 0; |
| 523 | } |
| 524 | EXPORT_SYMBOL(xfrm_trans_queue); |
| 525 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | void __init xfrm_input_init(void) |
| 527 | { |
Steffen Klassert | 1995876 | 2017-01-30 06:45:43 +0100 | [diff] [blame] | 528 | int err; |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 529 | int i; |
Steffen Klassert | 1995876 | 2017-01-30 06:45:43 +0100 | [diff] [blame] | 530 | |
| 531 | init_dummy_netdev(&xfrm_napi_dev); |
| 532 | err = gro_cells_init(&gro_cells, &xfrm_napi_dev); |
| 533 | if (err) |
| 534 | gro_cells.cells = NULL; |
| 535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 536 | secpath_cachep = kmem_cache_create("secpath_cache", |
| 537 | sizeof(struct sec_path), |
Alexey Dobriyan | e5d679f33 | 2006-08-26 19:25:52 -0700 | [diff] [blame] | 538 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 539 | NULL); |
Herbert Xu | acf568e | 2017-12-15 16:40:44 +1100 | [diff] [blame] | 540 | |
| 541 | for_each_possible_cpu(i) { |
| 542 | struct xfrm_trans_tasklet *trans; |
| 543 | |
| 544 | trans = &per_cpu(xfrm_trans_tasklet, i); |
| 545 | __skb_queue_head_init(&trans->queue); |
| 546 | tasklet_init(&trans->tasklet, xfrm_trans_reinject, |
| 547 | (unsigned long)trans); |
| 548 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 549 | } |