hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/net/rxrpc/conn_service.c
....@@ -1,16 +1,18 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* Service connection management
23 *
34 * Copyright (C) 2016 Red Hat, Inc. All Rights Reserved.
45 * Written by David Howells (dhowells@redhat.com)
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public Licence
8
- * as published by the Free Software Foundation; either version
9
- * 2 of the Licence, or (at your option) any later version.
106 */
117
128 #include <linux/slab.h>
139 #include "ar-internal.h"
10
+
11
+static struct rxrpc_bundle rxrpc_service_dummy_bundle = {
12
+ .ref = REFCOUNT_INIT(1),
13
+ .debug_id = UINT_MAX,
14
+ .channel_lock = __SPIN_LOCK_UNLOCKED(&rxrpc_service_dummy_bundle.channel_lock),
15
+};
1416
1517 /*
1618 * Find a service connection under RCU conditions.
....@@ -97,7 +99,7 @@
9799 return;
98100
99101 found_extant_conn:
100
- if (atomic_read(&cursor->usage) == 0)
102
+ if (refcount_read(&cursor->ref) == 0)
101103 goto replace_old_connection;
102104 write_sequnlock_bh(&peer->service_conn_lock);
103105 /* We should not be able to get here. rxrpc_incoming_connection() is
....@@ -130,7 +132,8 @@
130132 * the rxrpc_connections list.
131133 */
132134 conn->state = RXRPC_CONN_SERVICE_PREALLOC;
133
- atomic_set(&conn->usage, 2);
135
+ refcount_set(&conn->ref, 2);
136
+ conn->bundle = rxrpc_get_bundle(&rxrpc_service_dummy_bundle);
134137
135138 atomic_inc(&rxnet->nr_conns);
136139 write_lock(&rxnet->conn_lock);
....@@ -139,7 +142,7 @@
139142 write_unlock(&rxnet->conn_lock);
140143
141144 trace_rxrpc_conn(conn->debug_id, rxrpc_conn_new_service,
142
- atomic_read(&conn->usage),
145
+ refcount_read(&conn->ref),
143146 __builtin_return_address(0));
144147 }
145148
....@@ -152,6 +155,8 @@
152155 */
153156 void rxrpc_new_incoming_connection(struct rxrpc_sock *rx,
154157 struct rxrpc_connection *conn,
158
+ const struct rxrpc_security *sec,
159
+ struct key *key,
155160 struct sk_buff *skb)
156161 {
157162 struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
....@@ -164,6 +169,8 @@
164169 conn->service_id = sp->hdr.serviceId;
165170 conn->security_ix = sp->hdr.securityIndex;
166171 conn->out_clientflag = 0;
172
+ conn->security = sec;
173
+ conn->server_key = key_get(key);
167174 if (conn->security_ix)
168175 conn->state = RXRPC_CONN_SERVICE_UNSECURED;
169176 else