@@ -507,6 +507,7 @@ bool nft_pipapo_lookup(const struct net *net, const struct nft_set *set,
507
507
* @data: Key data to be matched against existing elements
508
508
* @genmask: If set, check that element is active in given genmask
509
509
* @tstamp: timestamp to check for expired elements
510
+ * @gfp: the type of memory to allocate (see kmalloc).
510
511
*
511
512
* This is essentially the same as the lookup function, except that it matches
512
513
* key data against the uncommitted copy and doesn't use preallocated maps for
@@ -517,7 +518,7 @@ bool nft_pipapo_lookup(const struct net *net, const struct nft_set *set,
517
518
static struct nft_pipapo_elem * pipapo_get (const struct net * net ,
518
519
const struct nft_set * set ,
519
520
const u8 * data , u8 genmask ,
520
- u64 tstamp )
521
+ u64 tstamp , gfp_t gfp )
521
522
{
522
523
struct nft_pipapo_elem * ret = ERR_PTR (- ENOENT );
523
524
struct nft_pipapo * priv = nft_set_priv (set );
@@ -530,13 +531,13 @@ static struct nft_pipapo_elem *pipapo_get(const struct net *net,
530
531
if (m -> bsize_max == 0 )
531
532
return ret ;
532
533
533
- res_map = kmalloc_array (m -> bsize_max , sizeof (* res_map ), GFP_ATOMIC );
534
+ res_map = kmalloc_array (m -> bsize_max , sizeof (* res_map ), gfp );
534
535
if (!res_map ) {
535
536
ret = ERR_PTR (- ENOMEM );
536
537
goto out ;
537
538
}
538
539
539
- fill_map = kcalloc (m -> bsize_max , sizeof (* res_map ), GFP_ATOMIC );
540
+ fill_map = kcalloc (m -> bsize_max , sizeof (* res_map ), gfp );
540
541
if (!fill_map ) {
541
542
ret = ERR_PTR (- ENOMEM );
542
543
goto out ;
@@ -614,7 +615,8 @@ nft_pipapo_get(const struct net *net, const struct nft_set *set,
614
615
struct nft_pipapo_elem * e ;
615
616
616
617
e = pipapo_get (net , set , (const u8 * )elem -> key .val .data ,
617
- nft_genmask_cur (net ), get_jiffies_64 ());
618
+ nft_genmask_cur (net ), get_jiffies_64 (),
619
+ GFP_ATOMIC );
618
620
if (IS_ERR (e ))
619
621
return ERR_CAST (e );
620
622
@@ -1275,7 +1277,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
1275
1277
else
1276
1278
end = start ;
1277
1279
1278
- dup = pipapo_get (net , set , start , genmask , tstamp );
1280
+ dup = pipapo_get (net , set , start , genmask , tstamp , GFP_KERNEL );
1279
1281
if (!IS_ERR (dup )) {
1280
1282
/* Check if we already have the same exact entry */
1281
1283
const struct nft_data * dup_key , * dup_end ;
@@ -1297,7 +1299,8 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
1297
1299
1298
1300
if (PTR_ERR (dup ) == - ENOENT ) {
1299
1301
/* Look for partially overlapping entries */
1300
- dup = pipapo_get (net , set , end , nft_genmask_next (net ), tstamp );
1302
+ dup = pipapo_get (net , set , end , nft_genmask_next (net ), tstamp ,
1303
+ GFP_KERNEL );
1301
1304
}
1302
1305
1303
1306
if (PTR_ERR (dup ) != - ENOENT ) {
@@ -1865,7 +1868,8 @@ static void *pipapo_deactivate(const struct net *net, const struct nft_set *set,
1865
1868
{
1866
1869
struct nft_pipapo_elem * e ;
1867
1870
1868
- e = pipapo_get (net , set , data , nft_genmask_next (net ), nft_net_tstamp (net ));
1871
+ e = pipapo_get (net , set , data , nft_genmask_next (net ),
1872
+ nft_net_tstamp (net ), GFP_KERNEL );
1869
1873
if (IS_ERR (e ))
1870
1874
return NULL ;
1871
1875
0 commit comments