rxrpc: Ask the security class how much space to allow in a packet
Ask the security class how much header and trailer space to allow for when allocating a packet, given how much data is remaining. This will allow the rxgk security class to stick both a trailer in as well as a header as appropriate in the future. Signed-off-by: David Howells <dhowells@redhat.com>
This commit is contained in:
@@ -327,7 +327,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
|
||||
rxrpc_send_ack_packet(call, false, NULL);
|
||||
|
||||
if (!skb) {
|
||||
size_t size, chunk, max, space;
|
||||
size_t remain, bufsize, chunk, offset;
|
||||
|
||||
_debug("alloc");
|
||||
|
||||
@@ -342,24 +342,21 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
|
||||
goto maybe_error;
|
||||
}
|
||||
|
||||
max = RXRPC_JUMBO_DATALEN;
|
||||
max -= call->conn->security_size;
|
||||
max &= ~(call->conn->size_align - 1UL);
|
||||
/* Work out the maximum size of a packet. Assume that
|
||||
* the security header is going to be in the padded
|
||||
* region (enc blocksize), but the trailer is not.
|
||||
*/
|
||||
remain = more ? INT_MAX : msg_data_left(msg);
|
||||
ret = call->conn->security->how_much_data(call, remain,
|
||||
&bufsize, &chunk, &offset);
|
||||
if (ret < 0)
|
||||
goto maybe_error;
|
||||
|
||||
chunk = max;
|
||||
if (chunk > msg_data_left(msg) && !more)
|
||||
chunk = msg_data_left(msg);
|
||||
|
||||
space = chunk + call->conn->size_align;
|
||||
space &= ~(call->conn->size_align - 1UL);
|
||||
|
||||
size = space + call->conn->security_size;
|
||||
|
||||
_debug("SIZE: %zu/%zu/%zu", chunk, space, size);
|
||||
_debug("SIZE: %zu/%zu @%zu", chunk, bufsize, offset);
|
||||
|
||||
/* create a buffer that we can retain until it's ACK'd */
|
||||
skb = sock_alloc_send_skb(
|
||||
sk, size, msg->msg_flags & MSG_DONTWAIT, &ret);
|
||||
sk, bufsize, msg->msg_flags & MSG_DONTWAIT, &ret);
|
||||
if (!skb)
|
||||
goto maybe_error;
|
||||
|
||||
@@ -371,8 +368,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
|
||||
|
||||
ASSERTCMP(skb->mark, ==, 0);
|
||||
|
||||
_debug("HS: %u", call->conn->security_size);
|
||||
__skb_put(skb, call->conn->security_size);
|
||||
__skb_put(skb, offset);
|
||||
|
||||
sp->remain = chunk;
|
||||
if (sp->remain > skb_tailroom(skb))
|
||||
@@ -421,17 +417,6 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
|
||||
(msg_data_left(msg) == 0 && !more)) {
|
||||
struct rxrpc_connection *conn = call->conn;
|
||||
uint32_t seq;
|
||||
size_t pad;
|
||||
|
||||
/* pad out if we're using security */
|
||||
if (conn->security_ix) {
|
||||
pad = conn->security_size + skb->mark;
|
||||
pad = conn->size_align - pad;
|
||||
pad &= conn->size_align - 1;
|
||||
_debug("pad %zu", pad);
|
||||
if (pad)
|
||||
skb_put_zero(skb, pad);
|
||||
}
|
||||
|
||||
seq = call->tx_top + 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user