• Home
  • Raw
  • Download

Lines Matching +full:xo +full:- +full:1

54 #define ESP_SKB_CB(__skb) ((struct esp_skb_cb *)&((__skb)->cb[0]))
77 ~(crypto_tfm_ctx_alignment() - 1); in esp_alloc_tmp()
98 crypto_aead_alignmask(aead) + 1) : tmp + seqhilen; in esp_tmp_iv()
114 return (void *)ALIGN((unsigned long)(req + 1) + in esp_req_sg()
121 struct crypto_aead *aead = x->data; in esp_ssg_unref()
127 if (x->props.flags & XFRM_STATE_ESN) in esp_ssg_unref()
134 * Skip the first sg which comes from skb->data. in esp_ssg_unref()
136 if (req->src != req->dst) in esp_ssg_unref()
137 for (sg = sg_next(req->src); sg; sg = sg_next(sg)) in esp_ssg_unref()
143 struct sk_buff *skb = base->data; in esp_output_done()
144 struct xfrm_offload *xo = xfrm_offload(skb); in esp_output_done() local
148 if (xo && (xo->flags & XFRM_DEV_RESUME)) in esp_output_done()
149 x = skb->sp->xvec[skb->sp->len - 1]; in esp_output_done()
151 x = skb_dst(skb)->xfrm; in esp_output_done()
153 tmp = ESP_SKB_CB(skb)->tmp; in esp_output_done()
157 if (xo && (xo->flags & XFRM_DEV_RESUME)) { in esp_output_done()
164 skb_push(skb, skb->data - skb_mac_header(skb)); in esp_output_done()
175 struct ip_esp_hdr *esph = (void *)(skb->data + offset); in esp_restore_header()
176 void *tmp = ESP_SKB_CB(skb)->tmp; in esp_restore_header()
179 esph->seq_no = esph->spi; in esp_restore_header()
180 esph->spi = *seqhi; in esp_restore_header()
185 esp_restore_header(skb, skb_transport_offset(skb) - sizeof(__be32)); in esp_output_restore_header()
197 if ((x->props.flags & XFRM_STATE_ESN)) { in esp_output_set_esn()
198 struct xfrm_offload *xo = xfrm_offload(skb); in esp_output_set_esn() local
200 esph = (void *)(skb_transport_header(skb) - sizeof(__be32)); in esp_output_set_esn()
201 *seqhi = esph->spi; in esp_output_set_esn()
202 if (xo) in esp_output_set_esn()
203 esph->seq_no = htonl(xo->seq.hi); in esp_output_set_esn()
205 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.hi); in esp_output_set_esn()
208 esph->spi = x->id.spi; in esp_output_set_esn()
215 struct sk_buff *skb = base->data; in esp_output_done_esn()
230 for (i = 0; i < plen - 2; i++) in esp_output_fill_trailer()
231 tail[i] = i + 1; in esp_output_fill_trailer()
233 tail[plen - 2] = plen - 2; in esp_output_fill_trailer()
234 tail[plen - 1] = proto; in esp_output_fill_trailer()
244 int tailen = esp->tailen; in esp6_output_head()
247 allocsz = ALIGN(skb->data_len + tailen, L1_CACHE_BYTES); in esp6_output_head()
253 nfrags = 1; in esp6_output_head()
258 } else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS) in esp6_output_head()
261 struct sock *sk = skb->sk; in esp6_output_head()
262 struct page_frag *pfrag = &x->xfrag; in esp6_output_head()
264 esp->inplace = false; in esp6_output_head()
268 spin_lock_bh(&x->lock); in esp6_output_head()
271 spin_unlock_bh(&x->lock); in esp6_output_head()
275 page = pfrag->page; in esp6_output_head()
280 tail = vaddr + pfrag->offset; in esp6_output_head()
282 esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto); in esp6_output_head()
286 nfrags = skb_shinfo(skb)->nr_frags; in esp6_output_head()
288 __skb_fill_page_desc(skb, nfrags, page, pfrag->offset, in esp6_output_head()
290 skb_shinfo(skb)->nr_frags = ++nfrags; in esp6_output_head()
292 pfrag->offset = pfrag->offset + allocsize; in esp6_output_head()
294 spin_unlock_bh(&x->lock); in esp6_output_head()
298 skb->len += tailen; in esp6_output_head()
299 skb->data_len += tailen; in esp6_output_head()
300 skb->truesize += tailen; in esp6_output_head()
302 refcount_add(tailen, &sk->sk_wmem_alloc); in esp6_output_head()
315 esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto); in esp6_output_head()
337 int err = -ENOMEM; in esp6_output_tail()
342 if (x->props.flags & XFRM_STATE_ESN) { in esp6_output_tail()
347 aead = x->data; in esp6_output_tail()
351 tmp = esp_alloc_tmp(aead, esp->nfrags + 2, seqhilen); in esp6_output_tail()
360 if (esp->inplace) in esp6_output_tail()
363 dsg = &sg[esp->nfrags]; in esp6_output_tail()
367 sg_init_table(sg, esp->nfrags); in esp6_output_tail()
369 (unsigned char *)esph - skb->data, in esp6_output_tail()
370 assoclen + ivlen + esp->clen + alen); in esp6_output_tail()
374 if (!esp->inplace) { in esp6_output_tail()
376 struct page_frag *pfrag = &x->xfrag; in esp6_output_tail()
378 allocsize = ALIGN(skb->data_len, L1_CACHE_BYTES); in esp6_output_tail()
380 spin_lock_bh(&x->lock); in esp6_output_tail()
382 spin_unlock_bh(&x->lock); in esp6_output_tail()
386 skb_shinfo(skb)->nr_frags = 1; in esp6_output_tail()
388 page = pfrag->page; in esp6_output_tail()
391 __skb_fill_page_desc(skb, 0, page, pfrag->offset, skb->data_len); in esp6_output_tail()
392 pfrag->offset = pfrag->offset + allocsize; in esp6_output_tail()
393 spin_unlock_bh(&x->lock); in esp6_output_tail()
395 sg_init_table(dsg, skb_shinfo(skb)->nr_frags + 1); in esp6_output_tail()
397 (unsigned char *)esph - skb->data, in esp6_output_tail()
398 assoclen + ivlen + esp->clen + alen); in esp6_output_tail()
403 if ((x->props.flags & XFRM_STATE_ESN)) in esp6_output_tail()
408 aead_request_set_crypt(req, sg, dsg, ivlen + esp->clen, iv); in esp6_output_tail()
412 memcpy(iv + ivlen - min(ivlen, 8), (u8 *)&esp->seqno + 8 - min(ivlen, 8), in esp6_output_tail()
415 ESP_SKB_CB(skb)->tmp = tmp; in esp6_output_tail()
419 case -EINPROGRESS: in esp6_output_tail()
422 case -ENOSPC: in esp6_output_tail()
427 if ((x->props.flags & XFRM_STATE_ESN)) in esp6_output_tail()
456 aead = x->data; in esp6_output()
460 if (x->tfcpad) { in esp6_output()
464 padto = min(x->tfcpad, esp6_get_mtu(x, dst->child_mtu_cached)); in esp6_output()
465 if (skb->len < padto) in esp6_output()
466 esp.tfclen = padto - skb->len; in esp6_output()
469 esp.clen = ALIGN(skb->len + 2 + esp.tfclen, blksize); in esp6_output()
470 esp.plen = esp.clen - skb->len - esp.tfclen; in esp6_output()
478 esph->spi = x->id.spi; in esp6_output()
480 esph->seq_no = htonl(XFRM_SKB_CB(skb)->seq.output.low); in esp6_output()
481 esp.seqno = cpu_to_be64(XFRM_SKB_CB(skb)->seq.output.low + in esp6_output()
482 ((u64)XFRM_SKB_CB(skb)->seq.output.hi << 32)); in esp6_output()
484 skb_push(skb, -skb_network_offset(skb)); in esp6_output()
492 struct xfrm_offload *xo = xfrm_offload(skb); in esp_remove_trailer() local
493 struct crypto_aead *aead = x->data; in esp_remove_trailer()
502 elen = skb->len - hlen; in esp_remove_trailer()
504 if (xo && (xo->flags & XFRM_ESP_NO_TRAILER)) { in esp_remove_trailer()
505 ret = xo->proto; in esp_remove_trailer()
509 ret = skb_copy_bits(skb, skb->len - alen - 2, nexthdr, 2); in esp_remove_trailer()
512 ret = -EINVAL; in esp_remove_trailer()
516 padlen + 2, elen - alen); in esp_remove_trailer()
521 if (skb->ip_summed == CHECKSUM_COMPLETE) { in esp_remove_trailer()
522 csumdiff = skb_checksum(skb, skb->len - trimlen, trimlen, 0); in esp_remove_trailer()
523 skb->csum = csum_block_sub(skb->csum, csumdiff, in esp_remove_trailer()
524 skb->len - trimlen); in esp_remove_trailer()
526 pskb_trim(skb, skb->len - trimlen); in esp_remove_trailer()
528 ret = nexthdr[1]; in esp_remove_trailer()
537 struct xfrm_offload *xo = xfrm_offload(skb); in esp6_input_done2() local
538 struct crypto_aead *aead = x->data; in esp6_input_done2()
542 if (!xo || (xo && !(xo->flags & CRYPTO_DONE))) in esp6_input_done2()
543 kfree(ESP_SKB_CB(skb)->tmp); in esp6_input_done2()
555 if (x->props.mode == XFRM_MODE_TUNNEL) in esp6_input_done2()
558 skb_set_transport_header(skb, -hdr_len); in esp6_input_done2()
562 err = -EINVAL; in esp6_input_done2()
571 struct sk_buff *skb = base->data; in esp_input_done()
590 if ((x->props.flags & XFRM_STATE_ESN)) { in esp_input_set_header()
593 *seqhi = esph->spi; in esp_input_set_header()
594 esph->spi = esph->seq_no; in esp_input_set_header()
595 esph->seq_no = XFRM_SKB_CB(skb)->seq.input.hi; in esp_input_set_header()
601 struct sk_buff *skb = base->data; in esp_input_done_esn()
610 struct crypto_aead *aead = x->data; in esp6_input()
614 int elen = skb->len - sizeof(*esph) - ivlen; in esp6_input()
625 ret = -EINVAL; in esp6_input()
630 ret = -EINVAL; in esp6_input()
637 if (x->props.flags & XFRM_STATE_ESN) { in esp6_input()
644 nfrags = 1; in esp6_input()
648 nfrags = skb_shinfo(skb)->nr_frags; in esp6_input()
657 ret = -EINVAL; in esp6_input()
662 ret = -ENOMEM; in esp6_input()
667 ESP_SKB_CB(skb)->tmp = tmp; in esp6_input()
676 ret = skb_to_sgvec(skb, sg, 0, skb->len); in esp6_input()
682 skb->ip_summed = CHECKSUM_NONE; in esp6_input()
684 if ((x->props.flags & XFRM_STATE_ESN)) in esp6_input()
693 if (ret == -EINPROGRESS) in esp6_input()
696 if ((x->props.flags & XFRM_STATE_ESN)) in esp6_input()
707 struct crypto_aead *aead = x->data; in esp6_get_mtu()
711 if (x->props.mode != XFRM_MODE_TUNNEL) in esp6_get_mtu()
716 return ((mtu - x->props.header_len - crypto_aead_authsize(aead) - in esp6_get_mtu()
717 net_adj) & ~(blksize - 1)) + net_adj - 2; in esp6_get_mtu()
723 struct net *net = dev_net(skb->dev); in esp6_err()
724 const struct ipv6hdr *iph = (const struct ipv6hdr *)skb->data; in esp6_err()
725 struct ip_esp_hdr *esph = (struct ip_esp_hdr *)(skb->data + offset); in esp6_err()
732 x = xfrm_state_lookup(net, skb->mark, (const xfrm_address_t *)&iph->daddr, in esp6_err()
733 esph->spi, IPPROTO_ESP, AF_INET6); in esp6_err()
738 ip6_redirect(skb, net, skb->dev->ifindex, 0, in esp6_err()
749 struct crypto_aead *aead = x->data; in esp6_destroy()
763 err = -ENAMETOOLONG; in esp_init_aead()
765 x->geniv, x->aead->alg_name) >= CRYPTO_MAX_ALG_NAME) in esp_init_aead()
773 x->data = aead; in esp_init_aead()
775 err = crypto_aead_setkey(aead, x->aead->alg_key, in esp_init_aead()
776 (x->aead->alg_key_len + 7) / 8); in esp_init_aead()
780 err = crypto_aead_setauthsize(aead, x->aead->alg_icv_len / 8); in esp_init_aead()
799 err = -EINVAL; in esp_init_authenc()
800 if (!x->ealg) in esp_init_authenc()
803 err = -ENAMETOOLONG; in esp_init_authenc()
805 if ((x->props.flags & XFRM_STATE_ESN)) { in esp_init_authenc()
808 x->geniv ?: "", x->geniv ? "(" : "", in esp_init_authenc()
809 x->aalg ? x->aalg->alg_name : "digest_null", in esp_init_authenc()
810 x->ealg->alg_name, in esp_init_authenc()
811 x->geniv ? ")" : "") >= CRYPTO_MAX_ALG_NAME) in esp_init_authenc()
816 x->geniv ?: "", x->geniv ? "(" : "", in esp_init_authenc()
817 x->aalg ? x->aalg->alg_name : "digest_null", in esp_init_authenc()
818 x->ealg->alg_name, in esp_init_authenc()
819 x->geniv ? ")" : "") >= CRYPTO_MAX_ALG_NAME) in esp_init_authenc()
828 x->data = aead; in esp_init_authenc()
830 keylen = (x->aalg ? (x->aalg->alg_key_len + 7) / 8 : 0) + in esp_init_authenc()
831 (x->ealg->alg_key_len + 7) / 8 + RTA_SPACE(sizeof(*param)); in esp_init_authenc()
832 err = -ENOMEM; in esp_init_authenc()
839 rta->rta_type = CRYPTO_AUTHENC_KEYA_PARAM; in esp_init_authenc()
840 rta->rta_len = RTA_LENGTH(sizeof(*param)); in esp_init_authenc()
844 if (x->aalg) { in esp_init_authenc()
847 memcpy(p, x->aalg->alg_key, (x->aalg->alg_key_len + 7) / 8); in esp_init_authenc()
848 p += (x->aalg->alg_key_len + 7) / 8; in esp_init_authenc()
850 aalg_desc = xfrm_aalg_get_byname(x->aalg->alg_name, 0); in esp_init_authenc()
853 err = -EINVAL; in esp_init_authenc()
854 if (aalg_desc->uinfo.auth.icv_fullbits / 8 != in esp_init_authenc()
857 x->aalg->alg_name, in esp_init_authenc()
859 aalg_desc->uinfo.auth.icv_fullbits / 8); in esp_init_authenc()
864 aead, x->aalg->alg_trunc_len / 8); in esp_init_authenc()
869 param->enckeylen = cpu_to_be32((x->ealg->alg_key_len + 7) / 8); in esp_init_authenc()
870 memcpy(p, x->ealg->alg_key, (x->ealg->alg_key_len + 7) / 8); in esp_init_authenc()
887 if (x->encap) in esp6_init_state()
888 return -EINVAL; in esp6_init_state()
890 x->data = NULL; in esp6_init_state()
892 if (x->aead) in esp6_init_state()
900 aead = x->data; in esp6_init_state()
902 x->props.header_len = sizeof(struct ip_esp_hdr) + in esp6_init_state()
904 switch (x->props.mode) { in esp6_init_state()
906 if (x->sel.family != AF_INET6) in esp6_init_state()
907 x->props.header_len += IPV4_BEET_PHMAXLEN + in esp6_init_state()
908 (sizeof(struct ipv6hdr) - sizeof(struct iphdr)); in esp6_init_state()
914 x->props.header_len += sizeof(struct ipv6hdr); in esp6_init_state()
919 x->props.trailer_len = align + 1 + crypto_aead_authsize(aead); in esp6_init_state()
954 return -EAGAIN; in esp6_init()
959 return -EAGAIN; in esp6_init()