Commit ec1af27e authored by David S. Miller's avatar David S. Miller

Merge tag 'rxrpc-rewrite-20170406' of...

Merge tag 'rxrpc-rewrite-20170406' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs

David Howells says:

====================
rxrpc: Miscellany

Here's a set of patches that make some minor changes to AF_RXRPC:

 (1) Store error codes in struct rxrpc_call::error as negative codes and
     only convert to positive in recvmsg() to avoid confusion inside the
     kernel.

 (2) Note the result of trying to abort a call (this fails if the call is
     already 'completed').

 (3) Don't abort on temporary errors whilst processing challenge and
     response packets, but rather drop the packet and wait for
     retransmission.

And also adds some more tracing:

 (4) Protocol errors.

 (5) Received abort packets.

 (6) Changes in the Rx window size due to ACK packet information.

 (7) Client call initiation (to allow the rxrpc_call struct pointer, the
     wire call ID and the user ID/afs_call pointer to be cross-referenced).
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b4041278 89ca6948
...@@ -419,7 +419,7 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp, ...@@ -419,7 +419,7 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
call->state = AFS_CALL_COMPLETE; call->state = AFS_CALL_COMPLETE;
if (ret != -ECONNABORTED) { if (ret != -ECONNABORTED) {
rxrpc_kernel_abort_call(afs_socket, rxcall, RX_USER_ABORT, rxrpc_kernel_abort_call(afs_socket, rxcall, RX_USER_ABORT,
-ret, "KSD"); ret, "KSD");
} else { } else {
abort_code = 0; abort_code = 0;
offset = 0; offset = 0;
...@@ -478,12 +478,12 @@ static void afs_deliver_to_call(struct afs_call *call) ...@@ -478,12 +478,12 @@ static void afs_deliver_to_call(struct afs_call *call)
case -ENOTCONN: case -ENOTCONN:
abort_code = RX_CALL_DEAD; abort_code = RX_CALL_DEAD;
rxrpc_kernel_abort_call(afs_socket, call->rxcall, rxrpc_kernel_abort_call(afs_socket, call->rxcall,
abort_code, -ret, "KNC"); abort_code, ret, "KNC");
goto save_error; goto save_error;
case -ENOTSUPP: case -ENOTSUPP:
abort_code = RXGEN_OPCODE; abort_code = RXGEN_OPCODE;
rxrpc_kernel_abort_call(afs_socket, call->rxcall, rxrpc_kernel_abort_call(afs_socket, call->rxcall,
abort_code, -ret, "KIV"); abort_code, ret, "KIV");
goto save_error; goto save_error;
case -ENODATA: case -ENODATA:
case -EBADMSG: case -EBADMSG:
...@@ -493,7 +493,7 @@ static void afs_deliver_to_call(struct afs_call *call) ...@@ -493,7 +493,7 @@ static void afs_deliver_to_call(struct afs_call *call)
if (call->state != AFS_CALL_AWAIT_REPLY) if (call->state != AFS_CALL_AWAIT_REPLY)
abort_code = RXGEN_SS_UNMARSHAL; abort_code = RXGEN_SS_UNMARSHAL;
rxrpc_kernel_abort_call(afs_socket, call->rxcall, rxrpc_kernel_abort_call(afs_socket, call->rxcall,
abort_code, EBADMSG, "KUM"); abort_code, -EBADMSG, "KUM");
goto save_error; goto save_error;
} }
} }
...@@ -754,7 +754,7 @@ void afs_send_empty_reply(struct afs_call *call) ...@@ -754,7 +754,7 @@ void afs_send_empty_reply(struct afs_call *call)
case -ENOMEM: case -ENOMEM:
_debug("oom"); _debug("oom");
rxrpc_kernel_abort_call(afs_socket, call->rxcall, rxrpc_kernel_abort_call(afs_socket, call->rxcall,
RX_USER_ABORT, ENOMEM, "KOO"); RX_USER_ABORT, -ENOMEM, "KOO");
default: default:
_leave(" [error]"); _leave(" [error]");
return; return;
...@@ -792,7 +792,7 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len) ...@@ -792,7 +792,7 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len)
if (n == -ENOMEM) { if (n == -ENOMEM) {
_debug("oom"); _debug("oom");
rxrpc_kernel_abort_call(afs_socket, call->rxcall, rxrpc_kernel_abort_call(afs_socket, call->rxcall,
RX_USER_ABORT, ENOMEM, "KOO"); RX_USER_ABORT, -ENOMEM, "KOO");
} }
_leave(" [error]"); _leave(" [error]");
} }
......
...@@ -39,7 +39,7 @@ int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *, ...@@ -39,7 +39,7 @@ int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *,
struct msghdr *, size_t); struct msghdr *, size_t);
int rxrpc_kernel_recv_data(struct socket *, struct rxrpc_call *, int rxrpc_kernel_recv_data(struct socket *, struct rxrpc_call *,
void *, size_t, size_t *, bool, u32 *); void *, size_t, size_t *, bool, u32 *);
void rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *, bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
u32, int, const char *); u32, int, const char *);
void rxrpc_kernel_end_call(struct socket *, struct rxrpc_call *); void rxrpc_kernel_end_call(struct socket *, struct rxrpc_call *);
void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *, void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *,
......
...@@ -683,6 +683,57 @@ TRACE_EVENT(rxrpc_rx_ack, ...@@ -683,6 +683,57 @@ TRACE_EVENT(rxrpc_rx_ack,
__entry->n_acks) __entry->n_acks)
); );
TRACE_EVENT(rxrpc_rx_abort,
TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
u32 abort_code),
TP_ARGS(call, serial, abort_code),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(rxrpc_serial_t, serial )
__field(u32, abort_code )
),
TP_fast_assign(
__entry->call = call;
__entry->serial = serial;
__entry->abort_code = abort_code;
),
TP_printk("c=%p ABORT %08x ac=%d",
__entry->call,
__entry->serial,
__entry->abort_code)
);
TRACE_EVENT(rxrpc_rx_rwind_change,
TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
u32 rwind, bool wake),
TP_ARGS(call, serial, rwind, wake),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(rxrpc_serial_t, serial )
__field(u32, rwind )
__field(bool, wake )
),
TP_fast_assign(
__entry->call = call;
__entry->serial = serial;
__entry->rwind = rwind;
__entry->wake = wake;
),
TP_printk("c=%p %08x rw=%u%s",
__entry->call,
__entry->serial,
__entry->rwind,
__entry->wake ? " wake" : "")
);
TRACE_EVENT(rxrpc_tx_data, TRACE_EVENT(rxrpc_tx_data,
TP_PROTO(struct rxrpc_call *call, rxrpc_seq_t seq, TP_PROTO(struct rxrpc_call *call, rxrpc_seq_t seq,
rxrpc_serial_t serial, u8 flags, bool retrans, bool lose), rxrpc_serial_t serial, u8 flags, bool retrans, bool lose),
...@@ -1087,6 +1138,56 @@ TRACE_EVENT(rxrpc_improper_term, ...@@ -1087,6 +1138,56 @@ TRACE_EVENT(rxrpc_improper_term,
__entry->abort_code) __entry->abort_code)
); );
TRACE_EVENT(rxrpc_rx_eproto,
TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
const char *why),
TP_ARGS(call, serial, why),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(rxrpc_serial_t, serial )
__field(const char *, why )
),
TP_fast_assign(
__entry->call = call;
__entry->serial = serial;
__entry->why = why;
),
TP_printk("c=%p EPROTO %08x %s",
__entry->call,
__entry->serial,
__entry->why)
);
TRACE_EVENT(rxrpc_connect_call,
TP_PROTO(struct rxrpc_call *call),
TP_ARGS(call),
TP_STRUCT__entry(
__field(struct rxrpc_call *, call )
__field(unsigned long, user_call_ID )
__field(u32, cid )
__field(u32, call_id )
),
TP_fast_assign(
__entry->call = call;
__entry->user_call_ID = call->user_call_ID;
__entry->cid = call->cid;
__entry->call_id = call->call_id;
),
TP_printk("c=%p u=%p %08x:%08x",
__entry->call,
(void *)__entry->user_call_ID,
__entry->cid,
__entry->call_id)
);
#endif /* _TRACE_RXRPC_H */ #endif /* _TRACE_RXRPC_H */
/* This part must be outside protection */ /* This part must be outside protection */
......
...@@ -739,6 +739,25 @@ static inline bool rxrpc_abort_call(const char *why, struct rxrpc_call *call, ...@@ -739,6 +739,25 @@ static inline bool rxrpc_abort_call(const char *why, struct rxrpc_call *call,
return ret; return ret;
} }
/*
* Abort a call due to a protocol error.
*/
static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call,
struct sk_buff *skb,
const char *eproto_why,
const char *why,
u32 abort_code)
{
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
trace_rxrpc_rx_eproto(call, sp->hdr.serial, eproto_why);
return rxrpc_abort_call(why, call, sp->hdr.seq, abort_code, -EPROTO);
}
#define rxrpc_abort_eproto(call, skb, eproto_why, abort_why, abort_code) \
__rxrpc_abort_eproto((call), (skb), tracepoint_string(eproto_why), \
(abort_why), (abort_code))
/* /*
* conn_client.c * conn_client.c
*/ */
......
...@@ -413,11 +413,11 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local, ...@@ -413,11 +413,11 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
case RXRPC_CONN_REMOTELY_ABORTED: case RXRPC_CONN_REMOTELY_ABORTED:
rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED, rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED,
conn->remote_abort, ECONNABORTED); conn->remote_abort, -ECONNABORTED);
break; break;
case RXRPC_CONN_LOCALLY_ABORTED: case RXRPC_CONN_LOCALLY_ABORTED:
rxrpc_abort_call("CON", call, sp->hdr.seq, rxrpc_abort_call("CON", call, sp->hdr.seq,
conn->local_abort, ECONNABORTED); conn->local_abort, -ECONNABORTED);
break; break;
default: default:
BUG(); BUG();
...@@ -600,7 +600,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx) ...@@ -600,7 +600,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx)
write_lock_bh(&call->state_lock); write_lock_bh(&call->state_lock);
switch (call->state) { switch (call->state) {
case RXRPC_CALL_SERVER_ACCEPTING: case RXRPC_CALL_SERVER_ACCEPTING:
__rxrpc_abort_call("REJ", call, 1, RX_USER_ABORT, ECONNABORTED); __rxrpc_abort_call("REJ", call, 1, RX_USER_ABORT, -ECONNABORTED);
abort = true; abort = true;
/* fall through */ /* fall through */
case RXRPC_CALL_COMPLETE: case RXRPC_CALL_COMPLETE:
......
...@@ -386,7 +386,7 @@ void rxrpc_process_call(struct work_struct *work) ...@@ -386,7 +386,7 @@ void rxrpc_process_call(struct work_struct *work)
now = ktime_get_real(); now = ktime_get_real();
if (ktime_before(call->expire_at, now)) { if (ktime_before(call->expire_at, now)) {
rxrpc_abort_call("EXP", call, 0, RX_CALL_TIMEOUT, ETIME); rxrpc_abort_call("EXP", call, 0, RX_CALL_TIMEOUT, -ETIME);
set_bit(RXRPC_CALL_EV_ABORT, &call->events); set_bit(RXRPC_CALL_EV_ABORT, &call->events);
goto recheck_state; goto recheck_state;
} }
......
...@@ -486,7 +486,7 @@ void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx) ...@@ -486,7 +486,7 @@ void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx)
call = list_entry(rx->to_be_accepted.next, call = list_entry(rx->to_be_accepted.next,
struct rxrpc_call, accept_link); struct rxrpc_call, accept_link);
list_del(&call->accept_link); list_del(&call->accept_link);
rxrpc_abort_call("SKR", call, 0, RX_CALL_DEAD, ECONNRESET); rxrpc_abort_call("SKR", call, 0, RX_CALL_DEAD, -ECONNRESET);
rxrpc_put_call(call, rxrpc_call_put); rxrpc_put_call(call, rxrpc_call_put);
} }
...@@ -494,7 +494,7 @@ void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx) ...@@ -494,7 +494,7 @@ void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx)
call = list_entry(rx->sock_calls.next, call = list_entry(rx->sock_calls.next,
struct rxrpc_call, sock_link); struct rxrpc_call, sock_link);
rxrpc_get_call(call, rxrpc_call_got); rxrpc_get_call(call, rxrpc_call_got);
rxrpc_abort_call("SKT", call, 0, RX_CALL_DEAD, ECONNRESET); rxrpc_abort_call("SKT", call, 0, RX_CALL_DEAD, -ECONNRESET);
rxrpc_send_abort_packet(call); rxrpc_send_abort_packet(call);
rxrpc_release_call(rx, call); rxrpc_release_call(rx, call);
rxrpc_put_call(call, rxrpc_call_put); rxrpc_put_call(call, rxrpc_call_put);
......
...@@ -550,6 +550,7 @@ static void rxrpc_activate_one_channel(struct rxrpc_connection *conn, ...@@ -550,6 +550,7 @@ static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,
call->cid = conn->proto.cid | channel; call->cid = conn->proto.cid | channel;
call->call_id = call_id; call->call_id = call_id;
trace_rxrpc_connect_call(call);
_net("CONNECT call %08x:%08x as call %d on conn %d", _net("CONNECT call %08x:%08x as call %d on conn %d",
call->cid, call->call_id, call->debug_id, conn->debug_id); call->cid, call->call_id, call->debug_id, conn->debug_id);
......
...@@ -168,7 +168,7 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn, ...@@ -168,7 +168,7 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn,
* generate a connection-level abort * generate a connection-level abort
*/ */
static int rxrpc_abort_connection(struct rxrpc_connection *conn, static int rxrpc_abort_connection(struct rxrpc_connection *conn,
u32 error, u32 abort_code) int error, u32 abort_code)
{ {
struct rxrpc_wire_header whdr; struct rxrpc_wire_header whdr;
struct msghdr msg; struct msghdr msg;
...@@ -281,14 +281,17 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, ...@@ -281,14 +281,17 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
case RXRPC_PACKET_TYPE_ABORT: case RXRPC_PACKET_TYPE_ABORT:
if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header), if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
&wtmp, sizeof(wtmp)) < 0) &wtmp, sizeof(wtmp)) < 0) {
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
tracepoint_string("bad_abort"));
return -EPROTO; return -EPROTO;
}
abort_code = ntohl(wtmp); abort_code = ntohl(wtmp);
_proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code); _proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);
conn->state = RXRPC_CONN_REMOTELY_ABORTED; conn->state = RXRPC_CONN_REMOTELY_ABORTED;
rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED, rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED,
abort_code, ECONNABORTED); abort_code, -ECONNABORTED);
return -ECONNABORTED; return -ECONNABORTED;
case RXRPC_PACKET_TYPE_CHALLENGE: case RXRPC_PACKET_TYPE_CHALLENGE:
...@@ -327,7 +330,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn, ...@@ -327,7 +330,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
return 0; return 0;
default: default:
_leave(" = -EPROTO [%u]", sp->hdr.type); trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
tracepoint_string("bad_conn_pkt"));
return -EPROTO; return -EPROTO;
} }
} }
...@@ -370,7 +374,7 @@ static void rxrpc_secure_connection(struct rxrpc_connection *conn) ...@@ -370,7 +374,7 @@ static void rxrpc_secure_connection(struct rxrpc_connection *conn)
abort: abort:
_debug("abort %d, %d", ret, abort_code); _debug("abort %d, %d", ret, abort_code);
rxrpc_abort_connection(conn, -ret, abort_code); rxrpc_abort_connection(conn, ret, abort_code);
_leave(" [aborted]"); _leave(" [aborted]");
} }
...@@ -419,9 +423,8 @@ void rxrpc_process_connection(struct work_struct *work) ...@@ -419,9 +423,8 @@ void rxrpc_process_connection(struct work_struct *work)
goto out; goto out;
protocol_error: protocol_error:
if (rxrpc_abort_connection(conn, -ret, abort_code) < 0) if (rxrpc_abort_connection(conn, ret, abort_code) < 0)
goto requeue_and_leave; goto requeue_and_leave;
rxrpc_free_skb(skb, rxrpc_skb_rx_freed); rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
_leave(" [EPROTO]");
goto out; goto out;
} }
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
static void rxrpc_proto_abort(const char *why, static void rxrpc_proto_abort(const char *why,
struct rxrpc_call *call, rxrpc_seq_t seq) struct rxrpc_call *call, rxrpc_seq_t seq)
{ {
if (rxrpc_abort_call(why, call, seq, RX_PROTOCOL_ERROR, EBADMSG)) { if (rxrpc_abort_call(why, call, seq, RX_PROTOCOL_ERROR, -EBADMSG)) {
set_bit(RXRPC_CALL_EV_ABORT, &call->events); set_bit(RXRPC_CALL_EV_ABORT, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
...@@ -665,6 +665,8 @@ static void rxrpc_input_ackinfo(struct rxrpc_call *call, struct sk_buff *skb, ...@@ -665,6 +665,8 @@ static void rxrpc_input_ackinfo(struct rxrpc_call *call, struct sk_buff *skb,
rwind = RXRPC_RXTX_BUFF_SIZE - 1; rwind = RXRPC_RXTX_BUFF_SIZE - 1;
if (rwind > call->tx_winsize) if (rwind > call->tx_winsize)
wake = true; wake = true;
trace_rxrpc_rx_rwind_change(call, sp->hdr.serial,
ntohl(ackinfo->rwind), wake);
call->tx_winsize = rwind; call->tx_winsize = rwind;
} }
...@@ -877,7 +879,7 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -877,7 +879,7 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb)
} }
/* /*
* Process an ABORT packet. * Process an ABORT packet directed at a call.
*/ */
static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb) static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb)
{ {
...@@ -892,10 +894,12 @@ static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb) ...@@ -892,10 +894,12 @@ static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb)
&wtmp, sizeof(wtmp)) >= 0) &wtmp, sizeof(wtmp)) >= 0)
abort_code = ntohl(wtmp); abort_code = ntohl(wtmp);
trace_rxrpc_rx_abort(call, sp->hdr.serial, abort_code);
_proto("Rx ABORT %%%u { %x }", sp->hdr.serial, abort_code); _proto("Rx ABORT %%%u { %x }", sp->hdr.serial, abort_code);
if (rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED, if (rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED,
abort_code, ECONNABORTED)) abort_code, -ECONNABORTED))
rxrpc_notify_socket(call); rxrpc_notify_socket(call);
} }
...@@ -958,7 +962,7 @@ static void rxrpc_input_implicit_end_call(struct rxrpc_connection *conn, ...@@ -958,7 +962,7 @@ static void rxrpc_input_implicit_end_call(struct rxrpc_connection *conn,
case RXRPC_CALL_COMPLETE: case RXRPC_CALL_COMPLETE:
break; break;
default: default:
if (rxrpc_abort_call("IMP", call, 0, RX_CALL_DEAD, ESHUTDOWN)) { if (rxrpc_abort_call("IMP", call, 0, RX_CALL_DEAD, -ESHUTDOWN)) {
set_bit(RXRPC_CALL_EV_ABORT, &call->events); set_bit(RXRPC_CALL_EV_ABORT, &call->events);
rxrpc_queue_call(call); rxrpc_queue_call(call);
} }
...@@ -1017,8 +1021,11 @@ int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb) ...@@ -1017,8 +1021,11 @@ int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb)
struct rxrpc_wire_header whdr; struct rxrpc_wire_header whdr;
/* dig out the RxRPC connection details */ /* dig out the RxRPC connection details */
if (skb_copy_bits(skb, 0, &whdr, sizeof(whdr)) < 0) if (skb_copy_bits(skb, 0, &whdr, sizeof(whdr)) < 0) {
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
tracepoint_string("bad_hdr"));
return -EBADMSG; return -EBADMSG;
}
memset(sp, 0, sizeof(*sp)); memset(sp, 0, sizeof(*sp));
sp->hdr.epoch = ntohl(whdr.epoch); sp->hdr.epoch = ntohl(whdr.epoch);
......
...@@ -46,7 +46,10 @@ static int none_respond_to_challenge(struct rxrpc_connection *conn, ...@@ -46,7 +46,10 @@ static int none_respond_to_challenge(struct rxrpc_connection *conn,
struct sk_buff *skb, struct sk_buff *skb,
u32 *_abort_code) u32 *_abort_code)
{ {
*_abort_code = RX_PROTOCOL_ERROR; struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
tracepoint_string("chall_none"));
return -EPROTO; return -EPROTO;
} }
...@@ -54,7 +57,10 @@ static int none_verify_response(struct rxrpc_connection *conn, ...@@ -54,7 +57,10 @@ static int none_verify_response(struct rxrpc_connection *conn,
struct sk_buff *skb, struct sk_buff *skb,
u32 *_abort_code) u32 *_abort_code)
{ {
*_abort_code = RX_PROTOCOL_ERROR; struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
tracepoint_string("resp_none"));
return -EPROTO; return -EPROTO;
} }
......
...@@ -296,7 +296,7 @@ void rxrpc_peer_error_distributor(struct work_struct *work) ...@@ -296,7 +296,7 @@ void rxrpc_peer_error_distributor(struct work_struct *work)
hlist_del_init(&call->error_link); hlist_del_init(&call->error_link);
rxrpc_see_call(call); rxrpc_see_call(call);
if (rxrpc_set_call_completion(call, compl, 0, error)) if (rxrpc_set_call_completion(call, compl, 0, -error))
rxrpc_notify_socket(call); rxrpc_notify_socket(call);
} }
......
...@@ -83,11 +83,11 @@ static int rxrpc_recvmsg_term(struct rxrpc_call *call, struct msghdr *msg) ...@@ -83,11 +83,11 @@ static int rxrpc_recvmsg_term(struct rxrpc_call *call, struct msghdr *msg)
ret = put_cmsg(msg, SOL_RXRPC, RXRPC_ABORT, 4, &tmp); ret = put_cmsg(msg, SOL_RXRPC, RXRPC_ABORT, 4, &tmp);
break; break;
case RXRPC_CALL_NETWORK_ERROR: case RXRPC_CALL_NETWORK_ERROR:
tmp = call->error; tmp = -call->error;
ret = put_cmsg(msg, SOL_RXRPC, RXRPC_NET_ERROR, 4, &tmp); ret = put_cmsg(msg, SOL_RXRPC, RXRPC_NET_ERROR, 4, &tmp);
break; break;
case RXRPC_CALL_LOCAL_ERROR: case RXRPC_CALL_LOCAL_ERROR:
tmp = call->error; tmp = -call->error;
ret = put_cmsg(msg, SOL_RXRPC, RXRPC_LOCAL_ERROR, 4, &tmp); ret = put_cmsg(msg, SOL_RXRPC, RXRPC_LOCAL_ERROR, 4, &tmp);
break; break;
default: default:
...@@ -682,14 +682,16 @@ int rxrpc_kernel_recv_data(struct socket *sock, struct rxrpc_call *call, ...@@ -682,14 +682,16 @@ int rxrpc_kernel_recv_data(struct socket *sock, struct rxrpc_call *call,
return ret; return ret;
short_data: short_data:
trace_rxrpc_rx_eproto(call, 0, tracepoint_string("short_data"));
ret = -EBADMSG; ret = -EBADMSG;
goto out; goto out;
excess_data: excess_data:
trace_rxrpc_rx_eproto(call, 0, tracepoint_string("excess_data"));
ret = -EMSGSIZE; ret = -EMSGSIZE;
goto out; goto out;
call_complete: call_complete:
*_abort = call->abort_code; *_abort = call->abort_code;
ret = -call->error; ret = call->error;
if (call->completion == RXRPC_CALL_SUCCEEDED) { if (call->completion == RXRPC_CALL_SUCCEEDED) {
ret = 1; ret = 1;
if (size > 0) if (size > 0)
......
This diff is collapsed.
...@@ -556,7 +556,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len) ...@@ -556,7 +556,7 @@ int rxrpc_do_sendmsg(struct rxrpc_sock *rx, struct msghdr *msg, size_t len)
ret = -ESHUTDOWN; ret = -ESHUTDOWN;
} else if (cmd == RXRPC_CMD_SEND_ABORT) { } else if (cmd == RXRPC_CMD_SEND_ABORT) {
ret = 0; ret = 0;
if (rxrpc_abort_call("CMD", call, 0, abort_code, ECONNABORTED)) if (rxrpc_abort_call("CMD", call, 0, abort_code, -ECONNABORTED))
ret = rxrpc_send_abort_packet(call); ret = rxrpc_send_abort_packet(call);
} else if (cmd != RXRPC_CMD_SEND_DATA) { } else if (cmd != RXRPC_CMD_SEND_DATA) {
ret = -EINVAL; ret = -EINVAL;
...@@ -623,7 +623,8 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call, ...@@ -623,7 +623,8 @@ int rxrpc_kernel_send_data(struct socket *sock, struct rxrpc_call *call,
read_unlock_bh(&call->state_lock); read_unlock_bh(&call->state_lock);
break; break;
default: default:
/* Request phase complete for this client call */ /* Request phase complete for this client call */
trace_rxrpc_rx_eproto(call, 0, tracepoint_string("late_send"));
ret = -EPROTO; ret = -EPROTO;
break; break;
} }
...@@ -642,20 +643,24 @@ EXPORT_SYMBOL(rxrpc_kernel_send_data); ...@@ -642,20 +643,24 @@ EXPORT_SYMBOL(rxrpc_kernel_send_data);
* @error: Local error value * @error: Local error value
* @why: 3-char string indicating why. * @why: 3-char string indicating why.
* *
* Allow a kernel service to abort a call, if it's still in an abortable state. * Allow a kernel service to abort a call, if it's still in an abortable state
* and return true if the call was aborted, false if it was already complete.
*/ */
void rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call, bool rxrpc_kernel_abort_call(struct socket *sock, struct rxrpc_call *call,
u32 abort_code, int error, const char *why) u32 abort_code, int error, const char *why)
{ {
bool aborted;
_enter("{%d},%d,%d,%s", call->debug_id, abort_code, error, why); _enter("{%d},%d,%d,%s", call->debug_id, abort_code, error, why);
mutex_lock(&call->user_mutex); mutex_lock(&call->user_mutex);
if (rxrpc_abort_call(why, call, 0, abort_code, error)) aborted = rxrpc_abort_call(why, call, 0, abort_code, error);
if (aborted)
rxrpc_send_abort_packet(call); rxrpc_send_abort_packet(call);
mutex_unlock(&call->user_mutex); mutex_unlock(&call->user_mutex);
_leave(""); return aborted;
} }
EXPORT_SYMBOL(rxrpc_kernel_abort_call); EXPORT_SYMBOL(rxrpc_kernel_abort_call);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment