rxrpc: Fix received abort handling
authorDavid Howells <dhowells@redhat.com>
Tue, 6 Feb 2018 16:44:12 +0000 (16:44 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 8 Feb 2018 02:47:10 +0000 (21:47 -0500)
AF_RXRPC is incorrectly sending back to the server any abort it receives
for a client connection.  This is due to the final-ACK offload to the
connection event processor patch.  The abort code is copied into the
last-call information on the connection channel and then the event
processor is set.

Instead, the following should be done:

 (1) In the case of a final-ACK for a successful call, the ACK should be
     scheduled as before.

 (2) In the case of a locally generated ABORT, the ABORT details should be
     cached for sending in response to further packets related to that
     call and no further action scheduled at call disconnect time.

 (3) In the case of an ACK received from the peer, the call should be
     considered dead, no ABORT should be transmitted at this time.  In
     response to further non-ABORT packets from the peer relating to this
     call, an RX_USER_ABORT ABORT should be transmitted.

 (4) In the case of a call killed due to network error, an RX_USER_ABORT
     ABORT should be cached for transmission in response to further
     packets, but no ABORT should be sent at this time.

Fixes: 3136ef49a14c ("rxrpc: Delay terminal ACK transmission on a client call")
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/rxrpc/conn_client.c
net/rxrpc/conn_object.c

index 7f74ca3059f8f45a70dd1960335415eee343b003..06417506805933368dba2ae4f0bd0e7635496a1d 100644 (file)
@@ -834,7 +834,8 @@ void rxrpc_disconnect_client_call(struct rxrpc_call *call)
         * can be skipped if we find a follow-on call.  The first DATA packet
         * of the follow on call will implicitly ACK this call.
         */
-       if (test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
+       if (call->completion == RXRPC_CALL_SUCCEEDED &&
+           test_bit(RXRPC_CALL_EXPOSED, &call->flags)) {
                unsigned long final_ack_at = jiffies + 2;
 
                WRITE_ONCE(chan->final_ack_at, final_ack_at);
index c628351eb9008da7059102f48dad7f605343de5b..ccbac190add1fa07bb35fe399572f2e7d3fdb015 100644 (file)
@@ -177,13 +177,21 @@ void __rxrpc_disconnect_call(struct rxrpc_connection *conn,
                 * through the channel, whilst disposing of the actual call record.
                 */
                trace_rxrpc_disconnect_call(call);
-               if (call->abort_code) {
-                       chan->last_abort = call->abort_code;
-                       chan->last_type = RXRPC_PACKET_TYPE_ABORT;
-               } else {
+               switch (call->completion) {
+               case RXRPC_CALL_SUCCEEDED:
                        chan->last_seq = call->rx_hard_ack;
                        chan->last_type = RXRPC_PACKET_TYPE_ACK;
+                       break;
+               case RXRPC_CALL_LOCALLY_ABORTED:
+                       chan->last_abort = call->abort_code;
+                       chan->last_type = RXRPC_PACKET_TYPE_ABORT;
+                       break;
+               default:
+                       chan->last_abort = RX_USER_ABORT;
+                       chan->last_type = RXRPC_PACKET_TYPE_ABORT;
+                       break;
                }
+
                /* Sync with rxrpc_conn_retransmit(). */
                smp_wmb();
                chan->last_call = chan->call_id;