Skip to content

Commit ec1af27

Browse files
committed
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: David S. Miller <davem@davemloft.net>
2 parents b404127 + 89ca694 commit ec1af27

File tree

15 files changed

+294
-108
lines changed

15 files changed

+294
-108
lines changed

fs/afs/rxrpc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ int afs_make_call(struct in_addr *addr, struct afs_call *call, gfp_t gfp,
419419
call->state = AFS_CALL_COMPLETE;
420420
if (ret != -ECONNABORTED) {
421421
rxrpc_kernel_abort_call(afs_socket, rxcall, RX_USER_ABORT,
422-
-ret, "KSD");
422+
ret, "KSD");
423423
} else {
424424
abort_code = 0;
425425
offset = 0;
@@ -478,12 +478,12 @@ static void afs_deliver_to_call(struct afs_call *call)
478478
case -ENOTCONN:
479479
abort_code = RX_CALL_DEAD;
480480
rxrpc_kernel_abort_call(afs_socket, call->rxcall,
481-
abort_code, -ret, "KNC");
481+
abort_code, ret, "KNC");
482482
goto save_error;
483483
case -ENOTSUPP:
484484
abort_code = RXGEN_OPCODE;
485485
rxrpc_kernel_abort_call(afs_socket, call->rxcall,
486-
abort_code, -ret, "KIV");
486+
abort_code, ret, "KIV");
487487
goto save_error;
488488
case -ENODATA:
489489
case -EBADMSG:
@@ -493,7 +493,7 @@ static void afs_deliver_to_call(struct afs_call *call)
493493
if (call->state != AFS_CALL_AWAIT_REPLY)
494494
abort_code = RXGEN_SS_UNMARSHAL;
495495
rxrpc_kernel_abort_call(afs_socket, call->rxcall,
496-
abort_code, EBADMSG, "KUM");
496+
abort_code, -EBADMSG, "KUM");
497497
goto save_error;
498498
}
499499
}
@@ -754,7 +754,7 @@ void afs_send_empty_reply(struct afs_call *call)
754754
case -ENOMEM:
755755
_debug("oom");
756756
rxrpc_kernel_abort_call(afs_socket, call->rxcall,
757-
RX_USER_ABORT, ENOMEM, "KOO");
757+
RX_USER_ABORT, -ENOMEM, "KOO");
758758
default:
759759
_leave(" [error]");
760760
return;
@@ -792,7 +792,7 @@ void afs_send_simple_reply(struct afs_call *call, const void *buf, size_t len)
792792
if (n == -ENOMEM) {
793793
_debug("oom");
794794
rxrpc_kernel_abort_call(afs_socket, call->rxcall,
795-
RX_USER_ABORT, ENOMEM, "KOO");
795+
RX_USER_ABORT, -ENOMEM, "KOO");
796796
}
797797
_leave(" [error]");
798798
}

include/net/af_rxrpc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ int rxrpc_kernel_send_data(struct socket *, struct rxrpc_call *,
3939
struct msghdr *, size_t);
4040
int rxrpc_kernel_recv_data(struct socket *, struct rxrpc_call *,
4141
void *, size_t, size_t *, bool, u32 *);
42-
void rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
42+
bool rxrpc_kernel_abort_call(struct socket *, struct rxrpc_call *,
4343
u32, int, const char *);
4444
void rxrpc_kernel_end_call(struct socket *, struct rxrpc_call *);
4545
void rxrpc_kernel_get_peer(struct socket *, struct rxrpc_call *,

include/trace/events/rxrpc.h

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,57 @@ TRACE_EVENT(rxrpc_rx_ack,
683683
__entry->n_acks)
684684
);
685685

686+
TRACE_EVENT(rxrpc_rx_abort,
687+
TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
688+
u32 abort_code),
689+
690+
TP_ARGS(call, serial, abort_code),
691+
692+
TP_STRUCT__entry(
693+
__field(struct rxrpc_call *, call )
694+
__field(rxrpc_serial_t, serial )
695+
__field(u32, abort_code )
696+
),
697+
698+
TP_fast_assign(
699+
__entry->call = call;
700+
__entry->serial = serial;
701+
__entry->abort_code = abort_code;
702+
),
703+
704+
TP_printk("c=%p ABORT %08x ac=%d",
705+
__entry->call,
706+
__entry->serial,
707+
__entry->abort_code)
708+
);
709+
710+
TRACE_EVENT(rxrpc_rx_rwind_change,
711+
TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
712+
u32 rwind, bool wake),
713+
714+
TP_ARGS(call, serial, rwind, wake),
715+
716+
TP_STRUCT__entry(
717+
__field(struct rxrpc_call *, call )
718+
__field(rxrpc_serial_t, serial )
719+
__field(u32, rwind )
720+
__field(bool, wake )
721+
),
722+
723+
TP_fast_assign(
724+
__entry->call = call;
725+
__entry->serial = serial;
726+
__entry->rwind = rwind;
727+
__entry->wake = wake;
728+
),
729+
730+
TP_printk("c=%p %08x rw=%u%s",
731+
__entry->call,
732+
__entry->serial,
733+
__entry->rwind,
734+
__entry->wake ? " wake" : "")
735+
);
736+
686737
TRACE_EVENT(rxrpc_tx_data,
687738
TP_PROTO(struct rxrpc_call *call, rxrpc_seq_t seq,
688739
rxrpc_serial_t serial, u8 flags, bool retrans, bool lose),
@@ -1087,6 +1138,56 @@ TRACE_EVENT(rxrpc_improper_term,
10871138
__entry->abort_code)
10881139
);
10891140

1141+
TRACE_EVENT(rxrpc_rx_eproto,
1142+
TP_PROTO(struct rxrpc_call *call, rxrpc_serial_t serial,
1143+
const char *why),
1144+
1145+
TP_ARGS(call, serial, why),
1146+
1147+
TP_STRUCT__entry(
1148+
__field(struct rxrpc_call *, call )
1149+
__field(rxrpc_serial_t, serial )
1150+
__field(const char *, why )
1151+
),
1152+
1153+
TP_fast_assign(
1154+
__entry->call = call;
1155+
__entry->serial = serial;
1156+
__entry->why = why;
1157+
),
1158+
1159+
TP_printk("c=%p EPROTO %08x %s",
1160+
__entry->call,
1161+
__entry->serial,
1162+
__entry->why)
1163+
);
1164+
1165+
TRACE_EVENT(rxrpc_connect_call,
1166+
TP_PROTO(struct rxrpc_call *call),
1167+
1168+
TP_ARGS(call),
1169+
1170+
TP_STRUCT__entry(
1171+
__field(struct rxrpc_call *, call )
1172+
__field(unsigned long, user_call_ID )
1173+
__field(u32, cid )
1174+
__field(u32, call_id )
1175+
),
1176+
1177+
TP_fast_assign(
1178+
__entry->call = call;
1179+
__entry->user_call_ID = call->user_call_ID;
1180+
__entry->cid = call->cid;
1181+
__entry->call_id = call->call_id;
1182+
),
1183+
1184+
TP_printk("c=%p u=%p %08x:%08x",
1185+
__entry->call,
1186+
(void *)__entry->user_call_ID,
1187+
__entry->cid,
1188+
__entry->call_id)
1189+
);
1190+
10901191
#endif /* _TRACE_RXRPC_H */
10911192

10921193
/* This part must be outside protection */

net/rxrpc/ar-internal.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,25 @@ static inline bool rxrpc_abort_call(const char *why, struct rxrpc_call *call,
739739
return ret;
740740
}
741741

742+
/*
743+
* Abort a call due to a protocol error.
744+
*/
745+
static inline bool __rxrpc_abort_eproto(struct rxrpc_call *call,
746+
struct sk_buff *skb,
747+
const char *eproto_why,
748+
const char *why,
749+
u32 abort_code)
750+
{
751+
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
752+
753+
trace_rxrpc_rx_eproto(call, sp->hdr.serial, eproto_why);
754+
return rxrpc_abort_call(why, call, sp->hdr.seq, abort_code, -EPROTO);
755+
}
756+
757+
#define rxrpc_abort_eproto(call, skb, eproto_why, abort_why, abort_code) \
758+
__rxrpc_abort_eproto((call), (skb), tracepoint_string(eproto_why), \
759+
(abort_why), (abort_code))
760+
742761
/*
743762
* conn_client.c
744763
*/

net/rxrpc/call_accept.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,11 @@ struct rxrpc_call *rxrpc_new_incoming_call(struct rxrpc_local *local,
413413

414414
case RXRPC_CONN_REMOTELY_ABORTED:
415415
rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED,
416-
conn->remote_abort, ECONNABORTED);
416+
conn->remote_abort, -ECONNABORTED);
417417
break;
418418
case RXRPC_CONN_LOCALLY_ABORTED:
419419
rxrpc_abort_call("CON", call, sp->hdr.seq,
420-
conn->local_abort, ECONNABORTED);
420+
conn->local_abort, -ECONNABORTED);
421421
break;
422422
default:
423423
BUG();
@@ -600,7 +600,7 @@ int rxrpc_reject_call(struct rxrpc_sock *rx)
600600
write_lock_bh(&call->state_lock);
601601
switch (call->state) {
602602
case RXRPC_CALL_SERVER_ACCEPTING:
603-
__rxrpc_abort_call("REJ", call, 1, RX_USER_ABORT, ECONNABORTED);
603+
__rxrpc_abort_call("REJ", call, 1, RX_USER_ABORT, -ECONNABORTED);
604604
abort = true;
605605
/* fall through */
606606
case RXRPC_CALL_COMPLETE:

net/rxrpc/call_event.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ void rxrpc_process_call(struct work_struct *work)
386386

387387
now = ktime_get_real();
388388
if (ktime_before(call->expire_at, now)) {
389-
rxrpc_abort_call("EXP", call, 0, RX_CALL_TIMEOUT, ETIME);
389+
rxrpc_abort_call("EXP", call, 0, RX_CALL_TIMEOUT, -ETIME);
390390
set_bit(RXRPC_CALL_EV_ABORT, &call->events);
391391
goto recheck_state;
392392
}

net/rxrpc/call_object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,15 +486,15 @@ void rxrpc_release_calls_on_socket(struct rxrpc_sock *rx)
486486
call = list_entry(rx->to_be_accepted.next,
487487
struct rxrpc_call, accept_link);
488488
list_del(&call->accept_link);
489-
rxrpc_abort_call("SKR", call, 0, RX_CALL_DEAD, ECONNRESET);
489+
rxrpc_abort_call("SKR", call, 0, RX_CALL_DEAD, -ECONNRESET);
490490
rxrpc_put_call(call, rxrpc_call_put);
491491
}
492492

493493
while (!list_empty(&rx->sock_calls)) {
494494
call = list_entry(rx->sock_calls.next,
495495
struct rxrpc_call, sock_link);
496496
rxrpc_get_call(call, rxrpc_call_got);
497-
rxrpc_abort_call("SKT", call, 0, RX_CALL_DEAD, ECONNRESET);
497+
rxrpc_abort_call("SKT", call, 0, RX_CALL_DEAD, -ECONNRESET);
498498
rxrpc_send_abort_packet(call);
499499
rxrpc_release_call(rx, call);
500500
rxrpc_put_call(call, rxrpc_call_put);

net/rxrpc/conn_client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ static void rxrpc_activate_one_channel(struct rxrpc_connection *conn,
550550
call->cid = conn->proto.cid | channel;
551551
call->call_id = call_id;
552552

553+
trace_rxrpc_connect_call(call);
553554
_net("CONNECT call %08x:%08x as call %d on conn %d",
554555
call->cid, call->call_id, call->debug_id, conn->debug_id);
555556

net/rxrpc/conn_event.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static void rxrpc_abort_calls(struct rxrpc_connection *conn,
168168
* generate a connection-level abort
169169
*/
170170
static int rxrpc_abort_connection(struct rxrpc_connection *conn,
171-
u32 error, u32 abort_code)
171+
int error, u32 abort_code)
172172
{
173173
struct rxrpc_wire_header whdr;
174174
struct msghdr msg;
@@ -281,14 +281,17 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
281281

282282
case RXRPC_PACKET_TYPE_ABORT:
283283
if (skb_copy_bits(skb, sizeof(struct rxrpc_wire_header),
284-
&wtmp, sizeof(wtmp)) < 0)
284+
&wtmp, sizeof(wtmp)) < 0) {
285+
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
286+
tracepoint_string("bad_abort"));
285287
return -EPROTO;
288+
}
286289
abort_code = ntohl(wtmp);
287290
_proto("Rx ABORT %%%u { ac=%d }", sp->hdr.serial, abort_code);
288291

289292
conn->state = RXRPC_CONN_REMOTELY_ABORTED;
290293
rxrpc_abort_calls(conn, RXRPC_CALL_REMOTELY_ABORTED,
291-
abort_code, ECONNABORTED);
294+
abort_code, -ECONNABORTED);
292295
return -ECONNABORTED;
293296

294297
case RXRPC_PACKET_TYPE_CHALLENGE:
@@ -327,7 +330,8 @@ static int rxrpc_process_event(struct rxrpc_connection *conn,
327330
return 0;
328331

329332
default:
330-
_leave(" = -EPROTO [%u]", sp->hdr.type);
333+
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
334+
tracepoint_string("bad_conn_pkt"));
331335
return -EPROTO;
332336
}
333337
}
@@ -370,7 +374,7 @@ static void rxrpc_secure_connection(struct rxrpc_connection *conn)
370374

371375
abort:
372376
_debug("abort %d, %d", ret, abort_code);
373-
rxrpc_abort_connection(conn, -ret, abort_code);
377+
rxrpc_abort_connection(conn, ret, abort_code);
374378
_leave(" [aborted]");
375379
}
376380

@@ -419,9 +423,8 @@ void rxrpc_process_connection(struct work_struct *work)
419423
goto out;
420424

421425
protocol_error:
422-
if (rxrpc_abort_connection(conn, -ret, abort_code) < 0)
426+
if (rxrpc_abort_connection(conn, ret, abort_code) < 0)
423427
goto requeue_and_leave;
424428
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
425-
_leave(" [EPROTO]");
426429
goto out;
427430
}

net/rxrpc/input.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
static void rxrpc_proto_abort(const char *why,
3131
struct rxrpc_call *call, rxrpc_seq_t seq)
3232
{
33-
if (rxrpc_abort_call(why, call, seq, RX_PROTOCOL_ERROR, EBADMSG)) {
33+
if (rxrpc_abort_call(why, call, seq, RX_PROTOCOL_ERROR, -EBADMSG)) {
3434
set_bit(RXRPC_CALL_EV_ABORT, &call->events);
3535
rxrpc_queue_call(call);
3636
}
@@ -665,6 +665,8 @@ static void rxrpc_input_ackinfo(struct rxrpc_call *call, struct sk_buff *skb,
665665
rwind = RXRPC_RXTX_BUFF_SIZE - 1;
666666
if (rwind > call->tx_winsize)
667667
wake = true;
668+
trace_rxrpc_rx_rwind_change(call, sp->hdr.serial,
669+
ntohl(ackinfo->rwind), wake);
668670
call->tx_winsize = rwind;
669671
}
670672

@@ -877,7 +879,7 @@ static void rxrpc_input_ackall(struct rxrpc_call *call, struct sk_buff *skb)
877879
}
878880

879881
/*
880-
* Process an ABORT packet.
882+
* Process an ABORT packet directed at a call.
881883
*/
882884
static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb)
883885
{
@@ -892,10 +894,12 @@ static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb)
892894
&wtmp, sizeof(wtmp)) >= 0)
893895
abort_code = ntohl(wtmp);
894896

897+
trace_rxrpc_rx_abort(call, sp->hdr.serial, abort_code);
898+
895899
_proto("Rx ABORT %%%u { %x }", sp->hdr.serial, abort_code);
896900

897901
if (rxrpc_set_call_completion(call, RXRPC_CALL_REMOTELY_ABORTED,
898-
abort_code, ECONNABORTED))
902+
abort_code, -ECONNABORTED))
899903
rxrpc_notify_socket(call);
900904
}
901905

@@ -958,7 +962,7 @@ static void rxrpc_input_implicit_end_call(struct rxrpc_connection *conn,
958962
case RXRPC_CALL_COMPLETE:
959963
break;
960964
default:
961-
if (rxrpc_abort_call("IMP", call, 0, RX_CALL_DEAD, ESHUTDOWN)) {
965+
if (rxrpc_abort_call("IMP", call, 0, RX_CALL_DEAD, -ESHUTDOWN)) {
962966
set_bit(RXRPC_CALL_EV_ABORT, &call->events);
963967
rxrpc_queue_call(call);
964968
}
@@ -1017,8 +1021,11 @@ int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb)
10171021
struct rxrpc_wire_header whdr;
10181022

10191023
/* dig out the RxRPC connection details */
1020-
if (skb_copy_bits(skb, 0, &whdr, sizeof(whdr)) < 0)
1024+
if (skb_copy_bits(skb, 0, &whdr, sizeof(whdr)) < 0) {
1025+
trace_rxrpc_rx_eproto(NULL, sp->hdr.serial,
1026+
tracepoint_string("bad_hdr"));
10211027
return -EBADMSG;
1028+
}
10221029

10231030
memset(sp, 0, sizeof(*sp));
10241031
sp->hdr.epoch = ntohl(whdr.epoch);

0 commit comments

Comments
 (0)