/* Copyright (c) 2018, Mellanox Technologies All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.
*/
*in_len -= len; if (*in_len < 0) {
*in_len += cipher_desc->tag; /* the input buffer doesn't contain the entire record. * trim len accordingly. The resulting authentication tag * will contain garbage, but we don't care, so we won't * include any of it in the output skb * Note that we assume the output buffer length * is larger then input buffer length + tag size
*/ if (*in_len < 0)
len += *in_len;
*in_len = 0;
}
if (*in_len) {
scatterwalk_skip(in, len);
scatterwalk_skip(out, len);
}
len -= cipher_desc->tag;
aead_request_set_crypt(aead_req, sg_in, sg_out, len, iv);
do {
rc = tls_enc_record(aead_req, aead, aad, iv,
cpu_to_be64(rcd_sn), &in, &out, &len, prot);
rcd_sn++;
} while (rc == 0 && len);
return rc;
}
/* Can't use icsk->icsk_af_ops->send_check here because the ip addresses * might have been changed by NAT.
*/ staticvoid update_chksum(struct sk_buff *skb, int headln)
{ struct tcphdr *th = tcp_hdr(skb); int datalen = skb->len - headln; conststruct ipv6hdr *ipv6h; conststruct iphdr *iph;
/* We only changed the payload so if we are using partial we don't * need to update anything.
*/ if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) return;
/* This function may be called after the user socket is already * closed so make sure we don't use anything freed during * tls_sk_proto_close here
*/
staticint fill_sg_in(struct scatterlist *sg_in, struct sk_buff *skb, struct tls_offload_context_tx *ctx,
u64 *rcd_sn,
s32 *sync_size, int *resync_sgs)
{ int tcp_payload_offset = skb_tcp_all_headers(skb); int payload_len = skb->len - tcp_payload_offset;
u32 tcp_seq = ntohl(tcp_hdr(skb)->seq); struct tls_record_info *record; unsignedlong flags; int remaining; int i;
spin_lock_irqsave(&ctx->lock, flags);
record = tls_get_record(ctx, tcp_seq, rcd_sn); if (!record) {
spin_unlock_irqrestore(&ctx->lock, flags); return -EINVAL;
}
*sync_size = tcp_seq - tls_record_start_seq(record); if (*sync_size < 0) { int is_start_marker = tls_record_is_start_marker(record);
spin_unlock_irqrestore(&ctx->lock, flags); /* This should only occur if the relevant record was * already acked. In that case it should be ok * to drop the packet and avoid retransmission. * * There is a corner case where the packet contains * both an acked and a non-acked record. * We currently don't handle that case and rely * on TCP to retransmit a packet that doesn't contain * already acked payload.
*/ if (!is_start_marker)
*sync_size = 0; return -EINVAL;
}
remaining = *sync_size; for (i = 0; remaining > 0; i++) {
skb_frag_t *frag = &record->frags[i];
__skb_frag_ref(frag);
sg_set_page(sg_in + i, skb_frag_page(frag),
skb_frag_size(frag), skb_frag_off(frag));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.