Skip to content

Commit 6c2728b

Browse files
menglongdongdavem330
authored andcommitted
net: dev: use kfree_skb_reason() for __netif_receive_skb_core()
Add reason for skb drops to __netif_receive_skb_core() when packet_type not found to handle the skb. For this purpose, the drop reason SKB_DROP_REASON_PTYPE_ABSENT is introduced. Take ether packets for example, this case mainly happens when L3 protocol is not supported. Signed-off-by: Menglong Dong <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a568aff commit 6c2728b

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

include/linux/skbuff.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,11 @@ enum skb_drop_reason {
407407
*/
408408
SKB_DROP_REASON_XDP, /* dropped by XDP in input path */
409409
SKB_DROP_REASON_TC_INGRESS, /* dropped in TC ingress HOOK */
410+
SKB_DROP_REASON_PTYPE_ABSENT, /* not packet_type found to handle
411+
* the skb. For an etner packet,
412+
* this means that L3 protocol is
413+
* not supported
414+
*/
410415
SKB_DROP_REASON_MAX,
411416
};
412417

include/trace/events/skb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \
5151
EM(SKB_DROP_REASON_XDP, XDP) \
5252
EM(SKB_DROP_REASON_TC_INGRESS, TC_INGRESS) \
53+
EM(SKB_DROP_REASON_PTYPE_ABSENT, PTYPE_ABSENT) \
5354
EMe(SKB_DROP_REASON_MAX, MAX)
5455

5556
#undef EM

net/core/dev.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,11 +5358,13 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc,
53585358
*ppt_prev = pt_prev;
53595359
} else {
53605360
drop:
5361-
if (!deliver_exact)
5361+
if (!deliver_exact) {
53625362
atomic_long_inc(&skb->dev->rx_dropped);
5363-
else
5363+
kfree_skb_reason(skb, SKB_DROP_REASON_PTYPE_ABSENT);
5364+
} else {
53645365
atomic_long_inc(&skb->dev->rx_nohandler);
5365-
kfree_skb(skb);
5366+
kfree_skb(skb);
5367+
}
53665368
/* Jamal, now you will not able to escape explaining
53675369
* me how you were going to use this. :-)
53685370
*/

0 commit comments

Comments
 (0)