Skip to content

Commit

Permalink
rxrpc: Extract the code from a received ABORT packet much earlier
Browse files Browse the repository at this point in the history
Extract the code from a received rx ABORT packet much earlier and in a
single place and harmonise the responses to malformed ABORT packets.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
  • Loading branch information
David Howells committed Dec 1, 2022
1 parent 2cc8008 commit f14febd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
12 changes: 1 addition & 11 deletions net/rxrpc/conn_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,6 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
u32 *_abort_code)
{
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
__be32 wtmp;
u32 abort_code;
int loop, ret;

if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) {
Expand All @@ -305,16 +303,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
return 0;

case RXRPC_PACKET_TYPE_ABORT:
if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
&wtmp, sizeof(wtmp)) < 0) {
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
tracepoint_string("bad_abort"));
return -EPROTO;
}
abort_code = ntohl(wtmp);

conn->error = -ECONNABORTED;
conn->abort_code = abort_code;
conn->abort_code = skb->priority;
conn->state = RXRPC_CONN_REMOTELY_ABORTED;
set_bit(RXRPC_CONN_DONT_REUSE, &conn->flags);
rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED, sp->hdr.serial);
Expand Down
31 changes: 19 additions & 12 deletions net/rxrpc/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -1019,20 +1019,11 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb)
static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb)
{
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
__be32 wtmp;
u32 abort_code = RX_CALL_DEAD;

_enter("");

if (skb->len >= 4 &&
skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
&wtmp, sizeof(wtmp)) >= 0)
abort_code = ntohl(wtmp);

trace_rxrpc_rx_abort(call, sp->hdr.serial, abort_code);
trace_rxrpc_rx_abort(call, sp->hdr.serial, skb->priority);

rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED,
abort_code, -ECONNABORTED);
skb->priority, -ECONNABORTED);
}

/*
Expand Down Expand Up @@ -1193,6 +1184,20 @@ int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb)
return 0;
}

/*
* Extract the abort code from an ABORT packet and stash it in skb->priority.
*/
static bool rxrpc_extract_abort(struct sk_buff *skb)
{
__be32 wtmp;

if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
&wtmp, sizeof(wtmp)) < 0)
return false;
skb->priority = ntohl(wtmp);
return true;
}

/*
* handle data received on the local endpoint
* - may be called in interrupt context
Expand Down Expand Up @@ -1264,8 +1269,10 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
case RXRPC_PACKET_TYPE_ACKALL:
if (sp->hdr.callNumber == 0)
goto bad_message;
fallthrough;
break;
case RXRPC_PACKET_TYPE_ABORT:
if (!rxrpc_extract_abort(skb))
return true; /* Just discard if malformed */
break;

case RXRPC_PACKET_TYPE_DATA:
Expand Down

0 comments on commit f14febd

Please sign in to comment.