rxrpc: Cache the security index in the rxrpc_call struct
authorDavid Howells <dhowells@redhat.com>
Wed, 7 Sep 2016 14:19:25 +0000 (15:19 +0100)
committerDavid Howells <dhowells@redhat.com>
Wed, 7 Sep 2016 14:30:22 +0000 (15:30 +0100)
Cache the security index in the rxrpc_call struct so that we can get at it
even when the call has been disconnected and the connection pointer
cleared.

Signed-off-by: David Howells <dhowells@redhat.com>
net/rxrpc/ar-internal.h
net/rxrpc/call_object.c
net/rxrpc/conn_client.c
net/rxrpc/input.c
net/rxrpc/sendmsg.c

index 913255a53564ed0fa4fe292a8885e1ee5b84a037..e3dfc9da05fe286dd4e0cc0d712b251db60bd146 100644 (file)
@@ -475,6 +475,7 @@ struct rxrpc_call {
        atomic_t                skb_count;      /* Outstanding packets on this call */
        atomic_t                sequence;       /* Tx data packet sequence counter */
        u16                     service_id;     /* service ID */
+       u8                      security_ix;    /* Security type */
        u32                     call_id;        /* call ID on connection  */
        u32                     cid;            /* connection ID plus channel index */
        int                     debug_id;       /* debug ID for printks */
index 060ddc32a85ea1e1dd21d0cdb847a8bb962edd11..83019e489555ffac426b25b7711a345f6761a63b 100644 (file)
@@ -345,6 +345,7 @@ struct rxrpc_call *rxrpc_incoming_call(struct rxrpc_sock *rx,
        candidate->peer         = conn->params.peer;
        candidate->cid          = sp->hdr.cid;
        candidate->call_id      = sp->hdr.callNumber;
+       candidate->security_ix  = sp->hdr.securityIndex;
        candidate->rx_data_post = 0;
        candidate->state        = RXRPC_CALL_SERVER_ACCEPTING;
        candidate->flags        |= (1 << RXRPC_CALL_IS_SERVICE);
index 82de1aeaef214b145594dc1c453e47eb14802f4b..9344a8416ceb4cc4ca9a3682a2a3ce4e04c229f5 100644 (file)
@@ -348,6 +348,7 @@ static int rxrpc_get_client_conn(struct rxrpc_call *call,
 
        if (cp->exclusive) {
                call->conn = candidate;
+               call->security_ix = candidate->security_ix;
                _leave(" = 0 [exclusive %d]", candidate->debug_id);
                return 0;
        }
@@ -395,6 +396,7 @@ static int rxrpc_get_client_conn(struct rxrpc_call *call,
 candidate_published:
        set_bit(RXRPC_CONN_IN_CLIENT_CONNS, &candidate->flags);
        call->conn = candidate;
+       call->security_ix = candidate->security_ix;
        spin_unlock(&local->client_conns_lock);
        _leave(" = 0 [new %d]", candidate->debug_id);
        return 0;
@@ -412,6 +414,7 @@ found_extant_conn:
 
        spin_lock(&conn->channel_lock);
        call->conn = conn;
+       call->security_ix = conn->security_ix;
        list_add(&call->chan_wait_link, &conn->waiting_calls);
        spin_unlock(&conn->channel_lock);
        _leave(" = 0 [extant %d]", conn->debug_id);
index f7239a6f9181d4b19f7a2b7b65e45d4e29da9613..9242fefd7f40cb3c53c54b8bb28f2382fff523d7 100644 (file)
@@ -198,7 +198,7 @@ static int rxrpc_fast_process_data(struct rxrpc_call *call,
 
        /* if the packet need security things doing to it, then it goes down
         * the slow path */
-       if (call->conn->security_ix)
+       if (call->security_ix)
                goto enqueue_packet;
 
        sp->call = call;
index 803078bea507e4559a0a998d015357070af997e7..2439aff131c7a69be7f10fa4c5f5ee2acf50ef38 100644 (file)
@@ -322,7 +322,7 @@ static int rxrpc_send_data(struct rxrpc_sock *rx,
                        sp->hdr.serial  = atomic_inc_return(&conn->serial);
                        sp->hdr.type    = RXRPC_PACKET_TYPE_DATA;
                        sp->hdr.userStatus = 0;
-                       sp->hdr.securityIndex = conn->security_ix;
+                       sp->hdr.securityIndex = call->security_ix;
                        sp->hdr._rsvd   = 0;
                        sp->hdr.serviceId = call->service_id;