@@ -839,7 +839,7 @@ static void skb_clone_fraglist(struct sk_buff *skb)
839
839
skb_get (list );
840
840
}
841
841
842
- static bool skb_pp_recycle (struct sk_buff * skb , void * data )
842
+ static bool skb_pp_recycle (struct sk_buff * skb , void * data , bool napi_safe )
843
843
{
844
844
if (!IS_ENABLED (CONFIG_PAGE_POOL ) || !skb -> pp_recycle )
845
845
return false;
@@ -856,20 +856,21 @@ static void skb_kfree_head(void *head, unsigned int end_offset)
856
856
kfree (head );
857
857
}
858
858
859
- static void skb_free_head (struct sk_buff * skb )
859
+ static void skb_free_head (struct sk_buff * skb , bool napi_safe )
860
860
{
861
861
unsigned char * head = skb -> head ;
862
862
863
863
if (skb -> head_frag ) {
864
- if (skb_pp_recycle (skb , head ))
864
+ if (skb_pp_recycle (skb , head , napi_safe ))
865
865
return ;
866
866
skb_free_frag (head );
867
867
} else {
868
868
skb_kfree_head (head , skb_end_offset (skb ));
869
869
}
870
870
}
871
871
872
- static void skb_release_data (struct sk_buff * skb , enum skb_drop_reason reason )
872
+ static void skb_release_data (struct sk_buff * skb , enum skb_drop_reason reason ,
873
+ bool napi_safe )
873
874
{
874
875
struct skb_shared_info * shinfo = skb_shinfo (skb );
875
876
int i ;
@@ -894,7 +895,7 @@ static void skb_release_data(struct sk_buff *skb, enum skb_drop_reason reason)
894
895
if (shinfo -> frag_list )
895
896
kfree_skb_list_reason (shinfo -> frag_list , reason );
896
897
897
- skb_free_head (skb );
898
+ skb_free_head (skb , napi_safe );
898
899
exit :
899
900
/* When we clone an SKB we copy the reycling bit. The pp_recycle
900
901
* bit is only set on the head though, so in order to avoid races
@@ -955,11 +956,12 @@ void skb_release_head_state(struct sk_buff *skb)
955
956
}
956
957
957
958
/* Free everything but the sk_buff shell. */
958
- static void skb_release_all (struct sk_buff * skb , enum skb_drop_reason reason )
959
+ static void skb_release_all (struct sk_buff * skb , enum skb_drop_reason reason ,
960
+ bool napi_safe )
959
961
{
960
962
skb_release_head_state (skb );
961
963
if (likely (skb -> head ))
962
- skb_release_data (skb , reason );
964
+ skb_release_data (skb , reason , napi_safe );
963
965
}
964
966
965
967
/**
@@ -973,7 +975,7 @@ static void skb_release_all(struct sk_buff *skb, enum skb_drop_reason reason)
973
975
974
976
void __kfree_skb (struct sk_buff * skb )
975
977
{
976
- skb_release_all (skb , SKB_DROP_REASON_NOT_SPECIFIED );
978
+ skb_release_all (skb , SKB_DROP_REASON_NOT_SPECIFIED , false );
977
979
kfree_skbmem (skb );
978
980
}
979
981
EXPORT_SYMBOL (__kfree_skb );
@@ -1027,7 +1029,7 @@ static void kfree_skb_add_bulk(struct sk_buff *skb,
1027
1029
return ;
1028
1030
}
1029
1031
1030
- skb_release_all (skb , reason );
1032
+ skb_release_all (skb , reason , false );
1031
1033
sa -> skb_array [sa -> skb_count ++ ] = skb ;
1032
1034
1033
1035
if (unlikely (sa -> skb_count == KFREE_SKB_BULK_SIZE )) {
@@ -1201,7 +1203,7 @@ EXPORT_SYMBOL(consume_skb);
1201
1203
void __consume_stateless_skb (struct sk_buff * skb )
1202
1204
{
1203
1205
trace_consume_skb (skb , __builtin_return_address (0 ));
1204
- skb_release_data (skb , SKB_CONSUMED );
1206
+ skb_release_data (skb , SKB_CONSUMED , false );
1205
1207
kfree_skbmem (skb );
1206
1208
}
1207
1209
@@ -1226,7 +1228,7 @@ static void napi_skb_cache_put(struct sk_buff *skb)
1226
1228
1227
1229
void __kfree_skb_defer (struct sk_buff * skb )
1228
1230
{
1229
- skb_release_all (skb , SKB_DROP_REASON_NOT_SPECIFIED );
1231
+ skb_release_all (skb , SKB_DROP_REASON_NOT_SPECIFIED , true );
1230
1232
napi_skb_cache_put (skb );
1231
1233
}
1232
1234
@@ -1264,7 +1266,7 @@ void napi_consume_skb(struct sk_buff *skb, int budget)
1264
1266
return ;
1265
1267
}
1266
1268
1267
- skb_release_all (skb , SKB_CONSUMED );
1269
+ skb_release_all (skb , SKB_CONSUMED , !! budget );
1268
1270
napi_skb_cache_put (skb );
1269
1271
}
1270
1272
EXPORT_SYMBOL (napi_consume_skb );
@@ -1395,7 +1397,7 @@ EXPORT_SYMBOL_GPL(alloc_skb_for_msg);
1395
1397
*/
1396
1398
struct sk_buff * skb_morph (struct sk_buff * dst , struct sk_buff * src )
1397
1399
{
1398
- skb_release_all (dst , SKB_CONSUMED );
1400
+ skb_release_all (dst , SKB_CONSUMED , false );
1399
1401
return __skb_clone (dst , src );
1400
1402
}
1401
1403
EXPORT_SYMBOL_GPL (skb_morph );
@@ -2018,9 +2020,9 @@ int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail,
2018
2020
if (skb_has_frag_list (skb ))
2019
2021
skb_clone_fraglist (skb );
2020
2022
2021
- skb_release_data (skb , SKB_CONSUMED );
2023
+ skb_release_data (skb , SKB_CONSUMED , false );
2022
2024
} else {
2023
- skb_free_head (skb );
2025
+ skb_free_head (skb , false );
2024
2026
}
2025
2027
off = (data + nhead ) - skb -> head ;
2026
2028
@@ -6389,12 +6391,12 @@ static int pskb_carve_inside_header(struct sk_buff *skb, const u32 off,
6389
6391
skb_frag_ref (skb , i );
6390
6392
if (skb_has_frag_list (skb ))
6391
6393
skb_clone_fraglist (skb );
6392
- skb_release_data (skb , SKB_CONSUMED );
6394
+ skb_release_data (skb , SKB_CONSUMED , false );
6393
6395
} else {
6394
6396
/* we can reuse existing recount- all we did was
6395
6397
* relocate values
6396
6398
*/
6397
- skb_free_head (skb );
6399
+ skb_free_head (skb , false );
6398
6400
}
6399
6401
6400
6402
skb -> head = data ;
@@ -6529,7 +6531,7 @@ static int pskb_carve_inside_nonlinear(struct sk_buff *skb, const u32 off,
6529
6531
skb_kfree_head (data , size );
6530
6532
return - ENOMEM ;
6531
6533
}
6532
- skb_release_data (skb , SKB_CONSUMED );
6534
+ skb_release_data (skb , SKB_CONSUMED , false );
6533
6535
6534
6536
skb -> head = data ;
6535
6537
skb -> head_frag = 0 ;
0 commit comments