Skip to content

Commit 5f109b9

Browse files
committed
Merge tag 'rxrpc-fixes-20171124' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
David Howells says: ==================== rxrpc: Fixes and improvements Here's a set of patches that fix and improve some stuff in the AF_RXRPC protocol: The patches are: (1) Unlock mutex returned by rxrpc_accept_call(). (2) Don't set connection upgrade by default. (3) Differentiate the call->user_mutex used by the kernel from that used by userspace calling sendmsg() to avoid lockdep warnings. (4) Delay terminal ACK transmission to a work queue so that it can be replaced by the next call if there is one. (5) Split the call parameters from the connection parameters so that more call-specific parameters can be passed through. (6) Fix the call timeouts to work the same as for other RxRPC/AFS implementations. (7) Don't transmit DELAY ACKs immediately, but instead delay them slightly so that can be discarded or can represent more packets. (8) Use RTT to calculate certain protocol timeouts. (9) Add a timeout to detect lost ACK/DATA packets. (10) Add a keepalive function so that we ping the peer if we haven't transmitted for a short while, thereby keeping intervening firewall routes open. (11) Make service endpoints expire like they're supposed to so that the UDP port can be reused. (12) Fix connection expiry timers to make cleanup happen in a more timely fashion. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 1d3b78b + 3d18cbb commit 5f109b9

File tree

17 files changed

+752
-325
lines changed

17 files changed

+752
-325
lines changed

include/trace/events/rxrpc.h

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ enum rxrpc_conn_trace {
4949
rxrpc_conn_put_client,
5050
rxrpc_conn_put_service,
5151
rxrpc_conn_queued,
52+
rxrpc_conn_reap_service,
5253
rxrpc_conn_seen,
5354
};
5455

@@ -138,10 +139,24 @@ enum rxrpc_rtt_rx_trace {
138139

139140
enum rxrpc_timer_trace {
140141
rxrpc_timer_begin,
142+
rxrpc_timer_exp_ack,
143+
rxrpc_timer_exp_hard,
144+
rxrpc_timer_exp_idle,
145+
rxrpc_timer_exp_keepalive,
146+
rxrpc_timer_exp_lost_ack,
147+
rxrpc_timer_exp_normal,
148+
rxrpc_timer_exp_ping,
149+
rxrpc_timer_exp_resend,
141150
rxrpc_timer_expired,
142151
rxrpc_timer_init_for_reply,
143152
rxrpc_timer_init_for_send_reply,
153+
rxrpc_timer_restart,
144154
rxrpc_timer_set_for_ack,
155+
rxrpc_timer_set_for_hard,
156+
rxrpc_timer_set_for_idle,
157+
rxrpc_timer_set_for_keepalive,
158+
rxrpc_timer_set_for_lost_ack,
159+
rxrpc_timer_set_for_normal,
145160
rxrpc_timer_set_for_ping,
146161
rxrpc_timer_set_for_resend,
147162
rxrpc_timer_set_for_send,
@@ -150,6 +165,7 @@ enum rxrpc_timer_trace {
150165
enum rxrpc_propose_ack_trace {
151166
rxrpc_propose_ack_client_tx_end,
152167
rxrpc_propose_ack_input_data,
168+
rxrpc_propose_ack_ping_for_keepalive,
153169
rxrpc_propose_ack_ping_for_lost_ack,
154170
rxrpc_propose_ack_ping_for_lost_reply,
155171
rxrpc_propose_ack_ping_for_params,
@@ -206,6 +222,7 @@ enum rxrpc_congest_change {
206222
EM(rxrpc_conn_put_client, "PTc") \
207223
EM(rxrpc_conn_put_service, "PTs") \
208224
EM(rxrpc_conn_queued, "QUE") \
225+
EM(rxrpc_conn_reap_service, "RPs") \
209226
E_(rxrpc_conn_seen, "SEE")
210227

211228
#define rxrpc_client_traces \
@@ -296,16 +313,31 @@ enum rxrpc_congest_change {
296313
#define rxrpc_timer_traces \
297314
EM(rxrpc_timer_begin, "Begin ") \
298315
EM(rxrpc_timer_expired, "*EXPR*") \
316+
EM(rxrpc_timer_exp_ack, "ExpAck") \
317+
EM(rxrpc_timer_exp_hard, "ExpHrd") \
318+
EM(rxrpc_timer_exp_idle, "ExpIdl") \
319+
EM(rxrpc_timer_exp_keepalive, "ExpKA ") \
320+
EM(rxrpc_timer_exp_lost_ack, "ExpLoA") \
321+
EM(rxrpc_timer_exp_normal, "ExpNml") \
322+
EM(rxrpc_timer_exp_ping, "ExpPng") \
323+
EM(rxrpc_timer_exp_resend, "ExpRsn") \
299324
EM(rxrpc_timer_init_for_reply, "IniRpl") \
300325
EM(rxrpc_timer_init_for_send_reply, "SndRpl") \
326+
EM(rxrpc_timer_restart, "Restrt") \
301327
EM(rxrpc_timer_set_for_ack, "SetAck") \
328+
EM(rxrpc_timer_set_for_hard, "SetHrd") \
329+
EM(rxrpc_timer_set_for_idle, "SetIdl") \
330+
EM(rxrpc_timer_set_for_keepalive, "KeepAl") \
331+
EM(rxrpc_timer_set_for_lost_ack, "SetLoA") \
332+
EM(rxrpc_timer_set_for_normal, "SetNml") \
302333
EM(rxrpc_timer_set_for_ping, "SetPng") \
303334
EM(rxrpc_timer_set_for_resend, "SetRTx") \
304-
E_(rxrpc_timer_set_for_send, "SetTx ")
335+
E_(rxrpc_timer_set_for_send, "SetSnd")
305336

306337
#define rxrpc_propose_ack_traces \
307338
EM(rxrpc_propose_ack_client_tx_end, "ClTxEnd") \
308339
EM(rxrpc_propose_ack_input_data, "DataIn ") \
340+
EM(rxrpc_propose_ack_ping_for_keepalive, "KeepAlv") \
309341
EM(rxrpc_propose_ack_ping_for_lost_ack, "LostAck") \
310342
EM(rxrpc_propose_ack_ping_for_lost_reply, "LostRpl") \
311343
EM(rxrpc_propose_ack_ping_for_params, "Params ") \
@@ -932,39 +964,47 @@ TRACE_EVENT(rxrpc_rtt_rx,
932964

933965
TRACE_EVENT(rxrpc_timer,
934966
TP_PROTO(struct rxrpc_call *call, enum rxrpc_timer_trace why,
935-
ktime_t now, unsigned long now_j),
967+
unsigned long now),
936968

937-
TP_ARGS(call, why, now, now_j),
969+
TP_ARGS(call, why, now),
938970

939971
TP_STRUCT__entry(
940972
__field(struct rxrpc_call *, call )
941973
__field(enum rxrpc_timer_trace, why )
942-
__field_struct(ktime_t, now )
943-
__field_struct(ktime_t, expire_at )
944-
__field_struct(ktime_t, ack_at )
945-
__field_struct(ktime_t, resend_at )
946-
__field(unsigned long, now_j )
947-
__field(unsigned long, timer )
974+
__field(long, now )
975+
__field(long, ack_at )
976+
__field(long, ack_lost_at )
977+
__field(long, resend_at )
978+
__field(long, ping_at )
979+
__field(long, expect_rx_by )
980+
__field(long, expect_req_by )
981+
__field(long, expect_term_by )
982+
__field(long, timer )
948983
),
949984

950985
TP_fast_assign(
951-
__entry->call = call;
952-
__entry->why = why;
953-
__entry->now = now;
954-
__entry->expire_at = call->expire_at;
955-
__entry->ack_at = call->ack_at;
956-
__entry->resend_at = call->resend_at;
957-
__entry->now_j = now_j;
958-
__entry->timer = call->timer.expires;
986+
__entry->call = call;
987+
__entry->why = why;
988+
__entry->now = now;
989+
__entry->ack_at = call->ack_at;
990+
__entry->ack_lost_at = call->ack_lost_at;
991+
__entry->resend_at = call->resend_at;
992+
__entry->expect_rx_by = call->expect_rx_by;
993+
__entry->expect_req_by = call->expect_req_by;
994+
__entry->expect_term_by = call->expect_term_by;
995+
__entry->timer = call->timer.expires;
959996
),
960997

961-
TP_printk("c=%p %s x=%lld a=%lld r=%lld t=%ld",
998+
TP_printk("c=%p %s a=%ld la=%ld r=%ld xr=%ld xq=%ld xt=%ld t=%ld",
962999
__entry->call,
9631000
__print_symbolic(__entry->why, rxrpc_timer_traces),
964-
ktime_to_ns(ktime_sub(__entry->expire_at, __entry->now)),
965-
ktime_to_ns(ktime_sub(__entry->ack_at, __entry->now)),
966-
ktime_to_ns(ktime_sub(__entry->resend_at, __entry->now)),
967-
__entry->timer - __entry->now_j)
1001+
__entry->ack_at - __entry->now,
1002+
__entry->ack_lost_at - __entry->now,
1003+
__entry->resend_at - __entry->now,
1004+
__entry->expect_rx_by - __entry->now,
1005+
__entry->expect_req_by - __entry->now,
1006+
__entry->expect_term_by - __entry->now,
1007+
__entry->timer - __entry->now)
9681008
);
9691009

9701010
TRACE_EVENT(rxrpc_rx_lose,
@@ -1080,7 +1120,7 @@ TRACE_EVENT(rxrpc_congest,
10801120
memcpy(&__entry->sum, summary, sizeof(__entry->sum));
10811121
),
10821122

1083-
TP_printk("c=%p %08x %s %08x %s cw=%u ss=%u nr=%u,%u nw=%u,%u r=%u b=%u u=%u d=%u l=%x%s%s%s",
1123+
TP_printk("c=%p r=%08x %s q=%08x %s cw=%u ss=%u nr=%u,%u nw=%u,%u r=%u b=%u u=%u d=%u l=%x%s%s%s",
10841124
__entry->call,
10851125
__entry->ack_serial,
10861126
__print_symbolic(__entry->sum.ack_reason, rxrpc_ack_names),

include/uapi/linux/rxrpc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ enum rxrpc_cmsg_type {
5959
RXRPC_EXCLUSIVE_CALL = 10, /* s-: Call should be on exclusive connection */
6060
RXRPC_UPGRADE_SERVICE = 11, /* s-: Request service upgrade for client call */
6161
RXRPC_TX_LENGTH = 12, /* s-: Total length of Tx data */
62+
RXRPC_SET_CALL_TIMEOUT = 13, /* s-: Set one or more call timeouts */
6263
RXRPC__SUPPORTED
6364
};
6465

net/rxrpc/af_rxrpc.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
285285
bool upgrade)
286286
{
287287
struct rxrpc_conn_parameters cp;
288+
struct rxrpc_call_params p;
288289
struct rxrpc_call *call;
289290
struct rxrpc_sock *rx = rxrpc_sk(sock->sk);
290291
int ret;
@@ -302,15 +303,18 @@ struct rxrpc_call *rxrpc_kernel_begin_call(struct socket *sock,
302303
if (key && !key->payload.data[0])
303304
key = NULL; /* a no-security key */
304305

306+
memset(&p, 0, sizeof(p));
307+
p.user_call_ID = user_call_ID;
308+
p.tx_total_len = tx_total_len;
309+
305310
memset(&cp, 0, sizeof(cp));
306311
cp.local = rx->local;
307312
cp.key = key;
308313
cp.security_level = 0;
309314
cp.exclusive = false;
310315
cp.upgrade = upgrade;
311316
cp.service_id = srx->srx_service;
312-
call = rxrpc_new_client_call(rx, &cp, srx, user_call_ID, tx_total_len,
313-
gfp);
317+
call = rxrpc_new_client_call(rx, &cp, srx, &p, gfp);
314318
/* The socket has been unlocked. */
315319
if (!IS_ERR(call)) {
316320
call->notify_rx = notify_rx;
@@ -863,6 +867,19 @@ static int rxrpc_release_sock(struct sock *sk)
863867
sock_orphan(sk);
864868
sk->sk_shutdown = SHUTDOWN_MASK;
865869

870+
/* We want to kill off all connections from a service socket
871+
* as fast as possible because we can't share these; client
872+
* sockets, on the other hand, can share an endpoint.
873+
*/
874+
switch (sk->sk_state) {
875+
case RXRPC_SERVER_BOUND:
876+
case RXRPC_SERVER_BOUND2:
877+
case RXRPC_SERVER_LISTENING:
878+
case RXRPC_SERVER_LISTEN_DISABLED:
879+
rx->local->service_closed = true;
880+
break;
881+
}
882+
866883
spin_lock_bh(&sk->sk_receive_queue.lock);
867884
sk->sk_state = RXRPC_CLOSE;
868885
spin_unlock_bh(&sk->sk_receive_queue.lock);
@@ -878,6 +895,8 @@ static int rxrpc_release_sock(struct sock *sk)
878895
rxrpc_release_calls_on_socket(rx);
879896
flush_workqueue(rxrpc_workqueue);
880897
rxrpc_purge_queue(&sk->sk_receive_queue);
898+
rxrpc_queue_work(&rx->local->rxnet->service_conn_reaper);
899+
rxrpc_queue_work(&rx->local->rxnet->client_conn_reaper);
881900

882901
rxrpc_put_local(rx->local);
883902
rx->local = NULL;

0 commit comments

Comments
 (0)