@@ -1307,14 +1307,8 @@ static void xfrm_hash_grow_check(struct net *net, int have_hash_collision)
1307
1307
static void xfrm_state_look_at (struct xfrm_policy * pol , struct xfrm_state * x ,
1308
1308
const struct flowi * fl , unsigned short family ,
1309
1309
struct xfrm_state * * best , int * acq_in_progress ,
1310
- int * error )
1310
+ int * error , unsigned int pcpu_id )
1311
1311
{
1312
- /* We need the cpu id just as a lookup key,
1313
- * we don't require it to be stable.
1314
- */
1315
- unsigned int pcpu_id = get_cpu ();
1316
- put_cpu ();
1317
-
1318
1312
/* Resolution logic:
1319
1313
* 1. There is a valid state with matching selector. Done.
1320
1314
* 2. Valid state with inappropriate selector. Skip.
@@ -1381,14 +1375,15 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1381
1375
/* We need the cpu id just as a lookup key,
1382
1376
* we don't require it to be stable.
1383
1377
*/
1384
- pcpu_id = get_cpu ();
1385
- put_cpu ();
1378
+ pcpu_id = raw_smp_processor_id ();
1386
1379
1387
1380
to_put = NULL ;
1388
1381
1389
1382
sequence = read_seqcount_begin (& net -> xfrm .xfrm_state_hash_generation );
1390
1383
1391
1384
rcu_read_lock ();
1385
+ xfrm_hash_ptrs_get (net , & state_ptrs );
1386
+
1392
1387
hlist_for_each_entry_rcu (x , & pol -> state_cache_list , state_cache ) {
1393
1388
if (x -> props .family == encap_family &&
1394
1389
x -> props .reqid == tmpl -> reqid &&
@@ -1400,7 +1395,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1400
1395
tmpl -> id .proto == x -> id .proto &&
1401
1396
(tmpl -> id .spi == x -> id .spi || !tmpl -> id .spi ))
1402
1397
xfrm_state_look_at (pol , x , fl , encap_family ,
1403
- & best , & acquire_in_progress , & error );
1398
+ & best , & acquire_in_progress , & error , pcpu_id );
1404
1399
}
1405
1400
1406
1401
if (best )
@@ -1417,7 +1412,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1417
1412
tmpl -> id .proto == x -> id .proto &&
1418
1413
(tmpl -> id .spi == x -> id .spi || !tmpl -> id .spi ))
1419
1414
xfrm_state_look_at (pol , x , fl , family ,
1420
- & best , & acquire_in_progress , & error );
1415
+ & best , & acquire_in_progress , & error , pcpu_id );
1421
1416
}
1422
1417
1423
1418
cached :
@@ -1429,8 +1424,6 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1429
1424
else if (acquire_in_progress ) /* XXX: acquire_in_progress should not happen */
1430
1425
WARN_ON (1 );
1431
1426
1432
- xfrm_hash_ptrs_get (net , & state_ptrs );
1433
-
1434
1427
h = __xfrm_dst_hash (daddr , saddr , tmpl -> reqid , encap_family , state_ptrs .hmask );
1435
1428
hlist_for_each_entry_rcu (x , state_ptrs .bydst + h , bydst ) {
1436
1429
#ifdef CONFIG_XFRM_OFFLOAD
@@ -1460,7 +1453,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1460
1453
tmpl -> id .proto == x -> id .proto &&
1461
1454
(tmpl -> id .spi == x -> id .spi || !tmpl -> id .spi ))
1462
1455
xfrm_state_look_at (pol , x , fl , family ,
1463
- & best , & acquire_in_progress , & error );
1456
+ & best , & acquire_in_progress , & error , pcpu_id );
1464
1457
}
1465
1458
if (best || acquire_in_progress )
1466
1459
goto found ;
@@ -1495,7 +1488,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
1495
1488
tmpl -> id .proto == x -> id .proto &&
1496
1489
(tmpl -> id .spi == x -> id .spi || !tmpl -> id .spi ))
1497
1490
xfrm_state_look_at (pol , x , fl , family ,
1498
- & best , & acquire_in_progress , & error );
1491
+ & best , & acquire_in_progress , & error , pcpu_id );
1499
1492
}
1500
1493
1501
1494
found :
0 commit comments