summaryrefslogtreecommitdiffstats
path: root/net/rxrpc
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2018-10-08 10:45:56 -0400
committerDavid Howells <dhowells@redhat.com>2018-10-08 10:45:56 -0400
commitbfd2821117a751763718f1b5e57216c0d9b19a49 (patch)
tree0a01e47ab2a026a33c483629e6a3bdef22dad02c /net/rxrpc
parent5271953cad31b97dea80f848c16e96ad66401199 (diff)
rxrpc: Don't need to take the RCU read lock in the packet receiver
We don't need to take the RCU read lock in the rxrpc packet receive function because it's held further up the stack in the IP input routine around the UDP receive routines. Fix this by dropping the RCU read lock calls from rxrpc_input_packet(). This simplifies the code. Fixes: 70790dbe3f66 ("rxrpc: Pass the last Tx packet marker in the annotation buffer") Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'net/rxrpc')
-rw-r--r--net/rxrpc/input.c41
1 files changed, 13 insertions, 28 deletions
diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c
index 1866aeef2284..2dcef482acf2 100644
--- a/net/rxrpc/input.c
+++ b/net/rxrpc/input.c
@@ -1120,6 +1120,8 @@ int rxrpc_extract_header(struct rxrpc_skb_priv *sp, struct sk_buff *skb)
1120 * The socket is locked by the caller and this prevents the socket from being 1120 * The socket is locked by the caller and this prevents the socket from being
1121 * shut down and the local endpoint from going away, thus sk_user_data will not 1121 * shut down and the local endpoint from going away, thus sk_user_data will not
1122 * be cleared until this function returns. 1122 * be cleared until this function returns.
1123 *
1124 * Called with the RCU read lock held from the IP layer via UDP.
1123 */ 1125 */
1124int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb) 1126int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1125{ 1127{
@@ -1215,8 +1217,6 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1215 if (sp->hdr.serviceId == 0) 1217 if (sp->hdr.serviceId == 0)
1216 goto bad_message; 1218 goto bad_message;
1217 1219
1218 rcu_read_lock();
1219
1220 if (rxrpc_to_server(sp)) { 1220 if (rxrpc_to_server(sp)) {
1221 /* Weed out packets to services we're not offering. Packets 1221 /* Weed out packets to services we're not offering. Packets
1222 * that would begin a call are explicitly rejected and the rest 1222 * that would begin a call are explicitly rejected and the rest
@@ -1228,7 +1228,7 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1228 if (sp->hdr.type == RXRPC_PACKET_TYPE_DATA && 1228 if (sp->hdr.type == RXRPC_PACKET_TYPE_DATA &&
1229 sp->hdr.seq == 1) 1229 sp->hdr.seq == 1)
1230 goto unsupported_service; 1230 goto unsupported_service;
1231 goto discard_unlock; 1231 goto discard;
1232 } 1232 }
1233 } 1233 }
1234 1234
@@ -1248,7 +1248,7 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1248 /* Connection-level packet */ 1248 /* Connection-level packet */
1249 _debug("CONN %p {%d}", conn, conn->debug_id); 1249 _debug("CONN %p {%d}", conn, conn->debug_id);
1250 rxrpc_post_packet_to_conn(conn, skb); 1250 rxrpc_post_packet_to_conn(conn, skb);
1251 goto out_unlock; 1251 goto out;
1252 } 1252 }
1253 1253
1254 /* Note the serial number skew here */ 1254 /* Note the serial number skew here */
@@ -1267,19 +1267,19 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1267 1267
1268 /* Ignore really old calls */ 1268 /* Ignore really old calls */
1269 if (sp->hdr.callNumber < chan->last_call) 1269 if (sp->hdr.callNumber < chan->last_call)
1270 goto discard_unlock; 1270 goto discard;
1271 1271
1272 if (sp->hdr.callNumber == chan->last_call) { 1272 if (sp->hdr.callNumber == chan->last_call) {
1273 if (chan->call || 1273 if (chan->call ||
1274 sp->hdr.type == RXRPC_PACKET_TYPE_ABORT) 1274 sp->hdr.type == RXRPC_PACKET_TYPE_ABORT)
1275 goto discard_unlock; 1275 goto discard;
1276 1276
1277 /* For the previous service call, if completed 1277 /* For the previous service call, if completed
1278 * successfully, we discard all further packets. 1278 * successfully, we discard all further packets.
1279 */ 1279 */
1280 if (rxrpc_conn_is_service(conn) && 1280 if (rxrpc_conn_is_service(conn) &&
1281 chan->last_type == RXRPC_PACKET_TYPE_ACK) 1281 chan->last_type == RXRPC_PACKET_TYPE_ACK)
1282 goto discard_unlock; 1282 goto discard;
1283 1283
1284 /* But otherwise we need to retransmit the final packet 1284 /* But otherwise we need to retransmit the final packet
1285 * from data cached in the connection record. 1285 * from data cached in the connection record.
@@ -1290,16 +1290,14 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1290 sp->hdr.serial, 1290 sp->hdr.serial,
1291 sp->hdr.flags, 0); 1291 sp->hdr.flags, 0);
1292 rxrpc_post_packet_to_conn(conn, skb); 1292 rxrpc_post_packet_to_conn(conn, skb);
1293 goto out_unlock; 1293 goto out;
1294 } 1294 }
1295 1295
1296 call = rcu_dereference(chan->call); 1296 call = rcu_dereference(chan->call);
1297 1297
1298 if (sp->hdr.callNumber > chan->call_id) { 1298 if (sp->hdr.callNumber > chan->call_id) {
1299 if (rxrpc_to_client(sp)) { 1299 if (rxrpc_to_client(sp))
1300 rcu_read_unlock();
1301 goto reject_packet; 1300 goto reject_packet;
1302 }
1303 if (call) 1301 if (call)
1304 rxrpc_input_implicit_end_call(conn, call); 1302 rxrpc_input_implicit_end_call(conn, call);
1305 call = NULL; 1303 call = NULL;
@@ -1318,55 +1316,42 @@ int rxrpc_input_packet(struct sock *udp_sk, struct sk_buff *skb)
1318 if (!call || atomic_read(&call->usage) == 0) { 1316 if (!call || atomic_read(&call->usage) == 0) {
1319 if (rxrpc_to_client(sp) || 1317 if (rxrpc_to_client(sp) ||
1320 sp->hdr.type != RXRPC_PACKET_TYPE_DATA) 1318 sp->hdr.type != RXRPC_PACKET_TYPE_DATA)
1321 goto bad_message_unlock; 1319 goto bad_message;
1322 if (sp->hdr.seq != 1) 1320 if (sp->hdr.seq != 1)
1323 goto discard_unlock; 1321 goto discard;
1324 call = rxrpc_new_incoming_call(local, rx, peer, conn, skb); 1322 call = rxrpc_new_incoming_call(local, rx, peer, conn, skb);
1325 if (!call) { 1323 if (!call)
1326 rcu_read_unlock();
1327 goto reject_packet; 1324 goto reject_packet;
1328 }
1329 rxrpc_send_ping(call, skb, skew); 1325 rxrpc_send_ping(call, skb, skew);
1330 mutex_unlock(&call->user_mutex); 1326 mutex_unlock(&call->user_mutex);
1331 } 1327 }
1332 1328
1333 rxrpc_input_call_packet(call, skb, skew); 1329 rxrpc_input_call_packet(call, skb, skew);
1334 goto discard_unlock; 1330 goto discard;
1335 1331
1336discard_unlock:
1337 rcu_read_unlock();
1338discard: 1332discard:
1339 rxrpc_free_skb(skb, rxrpc_skb_rx_freed); 1333 rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
1340out: 1334out:
1341 trace_rxrpc_rx_done(0, 0); 1335 trace_rxrpc_rx_done(0, 0);
1342 return 0; 1336 return 0;
1343 1337
1344out_unlock:
1345 rcu_read_unlock();
1346 goto out;
1347
1348wrong_security: 1338wrong_security:
1349 rcu_read_unlock();
1350 trace_rxrpc_abort(0, "SEC", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, 1339 trace_rxrpc_abort(0, "SEC", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq,
1351 RXKADINCONSISTENCY, EBADMSG); 1340 RXKADINCONSISTENCY, EBADMSG);
1352 skb->priority = RXKADINCONSISTENCY; 1341 skb->priority = RXKADINCONSISTENCY;
1353 goto post_abort; 1342 goto post_abort;
1354 1343
1355unsupported_service: 1344unsupported_service:
1356 rcu_read_unlock();
1357 trace_rxrpc_abort(0, "INV", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, 1345 trace_rxrpc_abort(0, "INV", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq,
1358 RX_INVALID_OPERATION, EOPNOTSUPP); 1346 RX_INVALID_OPERATION, EOPNOTSUPP);
1359 skb->priority = RX_INVALID_OPERATION; 1347 skb->priority = RX_INVALID_OPERATION;
1360 goto post_abort; 1348 goto post_abort;
1361 1349
1362reupgrade: 1350reupgrade:
1363 rcu_read_unlock();
1364 trace_rxrpc_abort(0, "UPG", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, 1351 trace_rxrpc_abort(0, "UPG", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq,
1365 RX_PROTOCOL_ERROR, EBADMSG); 1352 RX_PROTOCOL_ERROR, EBADMSG);
1366 goto protocol_error; 1353 goto protocol_error;
1367 1354
1368bad_message_unlock:
1369 rcu_read_unlock();
1370bad_message: 1355bad_message:
1371 trace_rxrpc_abort(0, "BAD", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq, 1356 trace_rxrpc_abort(0, "BAD", sp->hdr.cid, sp->hdr.callNumber, sp->hdr.seq,
1372 RX_PROTOCOL_ERROR, EBADMSG); 1357 RX_PROTOCOL_ERROR, EBADMSG);