Skip to content

Commit 7bac762

Browse files
committed
Merge tag 'rxrpc-fixes-20190809' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
David Howells says: ==================== Here's a couple of fixes for rxrpc: (1) Fix refcounting of the local endpoint. (2) Don't calculate or report packet skew information. This has been obsolete since AFS 3.1 and so is a waste of resources. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents 8c25d08 + e8c3af6 commit 7bac762

7 files changed

Lines changed: 100 additions & 83 deletions

File tree

‎net/rxrpc/af_rxrpc.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static int rxrpc_bind(struct socket *sock, struct sockaddr *saddr, int len)
193193

194194
service_in_use:
195195
write_unlock(&local->services_lock);
196-
rxrpc_put_local(local);
196+
rxrpc_unuse_local(local);
197197
ret = -EADDRINUSE;
198198
error_unlock:
199199
release_sock(&rx->sk);
@@ -402,7 +402,7 @@ EXPORT_SYMBOL(rxrpc_kernel_check_life);
402402
*/
403403
void rxrpc_kernel_probe_life(struct socket *sock, struct rxrpc_call *call)
404404
{
405-
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, 0, true, false,
405+
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, true, false,
406406
rxrpc_propose_ack_ping_for_check_life);
407407
rxrpc_send_ack_packet(call, true, NULL);
408408
}
@@ -901,7 +901,7 @@ static int rxrpc_release_sock(struct sock *sk)
901901
rxrpc_queue_work(&rxnet->service_conn_reaper);
902902
rxrpc_queue_work(&rxnet->client_conn_reaper);
903903

904-
rxrpc_put_local(rx->local);
904+
rxrpc_unuse_local(rx->local);
905905
rx->local = NULL;
906906
key_put(rx->key);
907907
rx->key = NULL;

‎net/rxrpc/ar-internal.h‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ struct rxrpc_security {
254254
*/
255255
struct rxrpc_local {
256256
struct rcu_head rcu;
257-
atomic_t usage;
257+
atomic_t active_users; /* Number of users of the local endpoint */
258+
atomic_t usage; /* Number of references to the structure */
258259
struct rxrpc_net *rxnet; /* The network ns in which this resides */
259260
struct list_head link;
260261
struct socket *socket; /* my UDP socket */
@@ -649,7 +650,6 @@ struct rxrpc_call {
649650

650651
/* receive-phase ACK management */
651652
u8 ackr_reason; /* reason to ACK */
652-
u16 ackr_skew; /* skew on packet being ACK'd */
653653
rxrpc_serial_t ackr_serial; /* serial of packet being ACK'd */
654654
rxrpc_serial_t ackr_first_seq; /* first sequence number received */
655655
rxrpc_seq_t ackr_prev_seq; /* previous sequence number received */
@@ -743,7 +743,7 @@ int rxrpc_reject_call(struct rxrpc_sock *);
743743
/*
744744
* call_event.c
745745
*/
746-
void rxrpc_propose_ACK(struct rxrpc_call *, u8, u16, u32, bool, bool,
746+
void rxrpc_propose_ACK(struct rxrpc_call *, u8, u32, bool, bool,
747747
enum rxrpc_propose_ack_trace);
748748
void rxrpc_process_call(struct work_struct *);
749749

@@ -1002,6 +1002,8 @@ struct rxrpc_local *rxrpc_lookup_local(struct net *, const struct sockaddr_rxrpc
10021002
struct rxrpc_local *rxrpc_get_local(struct rxrpc_local *);
10031003
struct rxrpc_local *rxrpc_get_local_maybe(struct rxrpc_local *);
10041004
void rxrpc_put_local(struct rxrpc_local *);
1005+
struct rxrpc_local *rxrpc_use_local(struct rxrpc_local *);
1006+
void rxrpc_unuse_local(struct rxrpc_local *);
10051007
void rxrpc_queue_local(struct rxrpc_local *);
10061008
void rxrpc_destroy_all_locals(struct rxrpc_net *);
10071009

‎net/rxrpc/call_event.c‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ static void rxrpc_propose_ping(struct rxrpc_call *call,
4343
* propose an ACK be sent
4444
*/
4545
static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
46-
u16 skew, u32 serial, bool immediate,
47-
bool background,
46+
u32 serial, bool immediate, bool background,
4847
enum rxrpc_propose_ack_trace why)
4948
{
5049
enum rxrpc_propose_ack_outcome outcome = rxrpc_propose_ack_use;
@@ -69,14 +68,12 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
6968
if (RXRPC_ACK_UPDATEABLE & (1 << ack_reason)) {
7069
outcome = rxrpc_propose_ack_update;
7170
call->ackr_serial = serial;
72-
call->ackr_skew = skew;
7371
}
7472
if (!immediate)
7573
goto trace;
7674
} else if (prior > rxrpc_ack_priority[call->ackr_reason]) {
7775
call->ackr_reason = ack_reason;
7876
call->ackr_serial = serial;
79-
call->ackr_skew = skew;
8077
} else {
8178
outcome = rxrpc_propose_ack_subsume;
8279
}
@@ -137,11 +134,11 @@ static void __rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
137134
* propose an ACK be sent, locking the call structure
138135
*/
139136
void rxrpc_propose_ACK(struct rxrpc_call *call, u8 ack_reason,
140-
u16 skew, u32 serial, bool immediate, bool background,
137+
u32 serial, bool immediate, bool background,
141138
enum rxrpc_propose_ack_trace why)
142139
{
143140
spin_lock_bh(&call->lock);
144-
__rxrpc_propose_ACK(call, ack_reason, skew, serial,
141+
__rxrpc_propose_ACK(call, ack_reason, serial,
145142
immediate, background, why);
146143
spin_unlock_bh(&call->lock);
147144
}
@@ -239,7 +236,7 @@ static void rxrpc_resend(struct rxrpc_call *call, unsigned long now_j)
239236
ack_ts = ktime_sub(now, call->acks_latest_ts);
240237
if (ktime_to_ns(ack_ts) < call->peer->rtt)
241238
goto out;
242-
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, 0, true, false,
239+
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, true, false,
243240
rxrpc_propose_ack_ping_for_lost_ack);
244241
rxrpc_send_ack_packet(call, true, NULL);
245242
goto out;
@@ -372,7 +369,7 @@ void rxrpc_process_call(struct work_struct *work)
372369
if (time_after_eq(now, t)) {
373370
trace_rxrpc_timer(call, rxrpc_timer_exp_keepalive, now);
374371
cmpxchg(&call->keepalive_at, t, now + MAX_JIFFY_OFFSET);
375-
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, 0, true, true,
372+
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, true, true,
376373
rxrpc_propose_ack_ping_for_keepalive);
377374
set_bit(RXRPC_CALL_EV_PING, &call->events);
378375
}
@@ -407,7 +404,7 @@ void rxrpc_process_call(struct work_struct *work)
407404
send_ack = NULL;
408405
if (test_and_clear_bit(RXRPC_CALL_EV_ACK_LOST, &call->events)) {
409406
call->acks_lost_top = call->tx_top;
410-
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, 0, true, false,
407+
rxrpc_propose_ACK(call, RXRPC_ACK_PING, 0, true, false,
411408
rxrpc_propose_ack_ping_for_lost_ack);
412409
send_ack = &call->acks_lost_ping;
413410
}

‎net/rxrpc/input.c‎

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -196,15 +196,14 @@ static void rxrpc_congestion_management(struct rxrpc_call *call,
196196
* Ping the other end to fill our RTT cache and to retrieve the rwind
197197
* and MTU parameters.
198198
*/
199-
static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb,
200-
int skew)
199+
static void rxrpc_send_ping(struct rxrpc_call *call, struct sk_buff *skb)
201200
{
202201
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
203202
ktime_t now = skb->tstamp;
204203

205204
if (call->peer->rtt_usage < 3 ||
206205
ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000), now))
207-
rxrpc_propose_ACK(call, RXRPC_ACK_PING, skew, sp->hdr.serial,
206+
rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,
208207
true, true,
209208
rxrpc_propose_ack_ping_for_params);
210209
}
@@ -419,8 +418,7 @@ static void rxrpc_input_dup_data(struct rxrpc_call *call, rxrpc_seq_t seq,
419418
/*
420419
* Process a DATA packet, adding the packet to the Rx ring.
421420
*/
422-
static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb,
423-
u16 skew)
421+
static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb)
424422
{
425423
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
426424
enum rxrpc_call_state state;
@@ -600,11 +598,11 @@ static void rxrpc_input_data(struct rxrpc_call *call, struct sk_buff *skb,
600598

601599
ack:
602600
if (ack)
603-
rxrpc_propose_ACK(call, ack, skew, ack_serial,
601+
rxrpc_propose_ACK(call, ack, ack_serial,
604602
immediate_ack, true,
605603
rxrpc_propose_ack_input_data);
606604
else
607-
rxrpc_propose_ACK(call, RXRPC_ACK_DELAY, skew, serial,
605+
rxrpc_propose_ACK(call, RXRPC_ACK_DELAY, serial,
608606
false, true,
609607
rxrpc_propose_ack_input_data);
610608

@@ -822,8 +820,7 @@ static void rxrpc_input_soft_acks(struct rxrpc_call *call, u8 *acks,
822820
* soft-ACK means that the packet may be discarded and retransmission
823821
* requested. A phase is complete when all packets are hard-ACK'd.
824822
*/
825-
static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
826-
u16 skew)
823+
static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb)
827824
{
828825
struct rxrpc_ack_summary summary = { 0 };
829826
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
@@ -867,11 +864,11 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
867864
if (buf.ack.reason == RXRPC_ACK_PING) {
868865
_proto("Rx ACK %%%u PING Request", sp->hdr.serial);
869866
rxrpc_propose_ACK(call, RXRPC_ACK_PING_RESPONSE,
870-
skew, sp->hdr.serial, true, true,
867+
sp->hdr.serial, true, true,
871868
rxrpc_propose_ack_respond_to_ping);
872869
} else if (sp->hdr.flags & RXRPC_REQUEST_ACK) {
873870
rxrpc_propose_ACK(call, RXRPC_ACK_REQUESTED,
874-
skew, sp->hdr.serial, true, true,
871+
sp->hdr.serial, true, true,
875872
rxrpc_propose_ack_respond_to_ack);
876873
}
877874

@@ -948,7 +945,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb,
948945
RXRPC_TX_ANNO_LAST &&
949946
summary.nr_acks == call->tx_top - hard_ack &&
950947
rxrpc_is_client_call(call))
951-
rxrpc_propose_ACK(call, RXRPC_ACK_PING, skew, sp->hdr.serial,
948+
rxrpc_propose_ACK(call, RXRPC_ACK_PING, sp->hdr.serial,
952949
false, true,
953950
rxrpc_propose_ack_ping_for_lost_reply);
954951

@@ -1004,7 +1001,7 @@ static void rxrpc_input_abort(struct rxrpc_call *call, struct sk_buff *skb)
10041001
* Process an incoming call packet.
10051002
*/
10061003
static void rxrpc_input_call_packet(struct rxrpc_call *call,
1007-
struct sk_buff *skb, u16 skew)
1004+
struct sk_buff *skb)
10081005
{
10091006
struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
10101007
unsigned long timo;
@@ -1023,11 +1020,11 @@ static void rxrpc_input_call_packet(struct rxrpc_call *call,
10231020

10241021
switch (sp->hdr.type) {
10251022
case RXRPC_PACKET_TYPE_DATA:
1026-
rxrpc_input_data(call, skb, skew);
1023+
rxrpc_input_data(call, skb);
10271024
break;
10281025

10291026
case RXRPC_PACKET_TYPE_ACK:
1030-
rxrpc_input_ack(call, skb, skew);
1027+
rxrpc_input_ack(call, skb);
10311028
break;
10321029

10331030
case RXRPC_PACKET_TYPE_BUSY:
@@ -1108,8 +1105,12 @@ static void rxrpc_post_packet_to_local(struct rxrpc_local *local,
11081105
{
11091106
_enter("%p,%p", local, skb);
11101107

1111-
skb_queue_tail(&local->event_queue, skb);
1112-
rxrpc_queue_local(local);
1108+
if (rxrpc_get_local_maybe(local)) {
1109+
skb_queue_tail(&local->event_queue, skb);
1110+
rxrpc_queue_local(local);
1111+
} else {
1112+
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
1113+
}
11131114
}
11141115

11151116
/*
@@ -1119,8 +1120,12 @@ static void rxrpc_reject_packet(struct rxrpc_local *local, struct sk_buff *skb)
11191120
{
11201121
CHECK_SLAB_OKAY(&local->usage);
11211122

1122-
skb_queue_tail(&local->reject_queue, skb);
1123-
rxrpc_queue_local(local);
1123+
if (rxrpc_get_local_maybe(local)) {
1124+
skb_queue_tail(&local->reject_queue, skb);
1125+
rxrpc_queue_local(local);
1126+
} else {
1127+
rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
1128+
}
11241129
}
11251130

11261131
/*
@@ -1173,7 +1178,6 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
11731178
struct rxrpc_peer *peer = NULL;
11741179
struct rxrpc_sock *rx = NULL;
11751180
unsigned int channel;
1176-
int skew = 0;
11771181

11781182
_enter("%p", udp_sk);
11791183

@@ -1301,15 +1305,8 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
13011305
goto out;
13021306
}
13031307

1304-
/* Note the serial number skew here */
1305-
skew = (int)sp->hdr.serial - (int)conn->hi_serial;
1306-
if (skew >= 0) {
1307-
if (skew > 0)
1308-
conn->hi_serial = sp->hdr.serial;
1309-
} else {
1310-
skew = -skew;
1311-
skew = min(skew, 65535);
1312-
}
1308+
if ((int)sp->hdr.serial - (int)conn->hi_serial > 0)
1309+
conn->hi_serial = sp->hdr.serial;
13131310

13141311
/* Call-bound packets are routed by connection channel. */
13151312
channel = sp->hdr.cid & RXRPC_CHANNELMASK;
@@ -1372,11 +1369,11 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
13721369
call = rxrpc_new_incoming_call(local, rx, skb);
13731370
if (!call)
13741371
goto reject_packet;
1375-
rxrpc_send_ping(call, skb, skew);
1372+
rxrpc_send_ping(call, skb);
13761373
mutex_unlock(&call->user_mutex);
13771374
}
13781375

1379-
rxrpc_input_call_packet(call, skb, skew);
1376+
rxrpc_input_call_packet(call, skb);
13801377
goto discard;
13811378

13821379
discard:

0 commit comments

Comments
 (0)