Skip to content

Commit 40bbae5

Browse files
Eric Dumazetkuba-moo
authored andcommitted
net: remove enum skb_free_reason
enum skb_drop_reason is more generic, we can adopt it instead. Provide dev_kfree_skb_irq_reason() and dev_kfree_skb_any_reason(). This means drivers can use more precise drop reasons if they want to. Signed-off-by: Eric Dumazet <[email protected]> Reviewed-by: Simon Horman <[email protected]> Reviewed-by: Yunsheng Lin <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0194b64 commit 40bbae5

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

include/linux/netdevice.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#include <linux/rbtree.h>
5353
#include <net/net_trackers.h>
5454
#include <net/net_debug.h>
55+
#include <net/dropreason.h>
5556

5657
struct netpoll_info;
5758
struct device;
@@ -3804,13 +3805,8 @@ static inline unsigned int get_netdev_rx_queue_index(
38043805

38053806
int netif_get_num_default_rss_queues(void);
38063807

3807-
enum skb_free_reason {
3808-
SKB_REASON_CONSUMED,
3809-
SKB_REASON_DROPPED,
3810-
};
3811-
3812-
void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason);
3813-
void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason);
3808+
void dev_kfree_skb_irq_reason(struct sk_buff *skb, enum skb_drop_reason reason);
3809+
void dev_kfree_skb_any_reason(struct sk_buff *skb, enum skb_drop_reason reason);
38143810

38153811
/*
38163812
* It is not allowed to call kfree_skb() or consume_skb() from hardware
@@ -3833,22 +3829,22 @@ void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason);
38333829
*/
38343830
static inline void dev_kfree_skb_irq(struct sk_buff *skb)
38353831
{
3836-
__dev_kfree_skb_irq(skb, SKB_REASON_DROPPED);
3832+
dev_kfree_skb_irq_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
38373833
}
38383834

38393835
static inline void dev_consume_skb_irq(struct sk_buff *skb)
38403836
{
3841-
__dev_kfree_skb_irq(skb, SKB_REASON_CONSUMED);
3837+
dev_kfree_skb_irq_reason(skb, SKB_CONSUMED);
38423838
}
38433839

38443840
static inline void dev_kfree_skb_any(struct sk_buff *skb)
38453841
{
3846-
__dev_kfree_skb_any(skb, SKB_REASON_DROPPED);
3842+
dev_kfree_skb_any_reason(skb, SKB_DROP_REASON_NOT_SPECIFIED);
38473843
}
38483844

38493845
static inline void dev_consume_skb_any(struct sk_buff *skb)
38503846
{
3851-
__dev_kfree_skb_any(skb, SKB_REASON_CONSUMED);
3847+
dev_kfree_skb_any_reason(skb, SKB_CONSUMED);
38523848
}
38533849

38543850
u32 bpf_prog_run_generic_xdp(struct sk_buff *skb, struct xdp_buff *xdp,

net/core/dev.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,7 +3075,7 @@ void __netif_schedule(struct Qdisc *q)
30753075
EXPORT_SYMBOL(__netif_schedule);
30763076

30773077
struct dev_kfree_skb_cb {
3078-
enum skb_free_reason reason;
3078+
enum skb_drop_reason reason;
30793079
};
30803080

30813081
static struct dev_kfree_skb_cb *get_kfree_skb_cb(const struct sk_buff *skb)
@@ -3108,7 +3108,7 @@ void netif_tx_wake_queue(struct netdev_queue *dev_queue)
31083108
}
31093109
EXPORT_SYMBOL(netif_tx_wake_queue);
31103110

3111-
void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason)
3111+
void dev_kfree_skb_irq_reason(struct sk_buff *skb, enum skb_drop_reason reason)
31123112
{
31133113
unsigned long flags;
31143114

@@ -3128,18 +3128,16 @@ void __dev_kfree_skb_irq(struct sk_buff *skb, enum skb_free_reason reason)
31283128
raise_softirq_irqoff(NET_TX_SOFTIRQ);
31293129
local_irq_restore(flags);
31303130
}
3131-
EXPORT_SYMBOL(__dev_kfree_skb_irq);
3131+
EXPORT_SYMBOL(dev_kfree_skb_irq_reason);
31323132

3133-
void __dev_kfree_skb_any(struct sk_buff *skb, enum skb_free_reason reason)
3133+
void dev_kfree_skb_any_reason(struct sk_buff *skb, enum skb_drop_reason reason)
31343134
{
31353135
if (in_hardirq() || irqs_disabled())
3136-
__dev_kfree_skb_irq(skb, reason);
3137-
else if (unlikely(reason == SKB_REASON_DROPPED))
3138-
kfree_skb(skb);
3136+
dev_kfree_skb_irq_reason(skb, reason);
31393137
else
3140-
consume_skb(skb);
3138+
kfree_skb_reason(skb, reason);
31413139
}
3142-
EXPORT_SYMBOL(__dev_kfree_skb_any);
3140+
EXPORT_SYMBOL(dev_kfree_skb_any_reason);
31433141

31443142

31453143
/**
@@ -5020,11 +5018,11 @@ static __latent_entropy void net_tx_action(struct softirq_action *h)
50205018
clist = clist->next;
50215019

50225020
WARN_ON(refcount_read(&skb->users));
5023-
if (likely(get_kfree_skb_cb(skb)->reason == SKB_REASON_CONSUMED))
5021+
if (likely(get_kfree_skb_cb(skb)->reason == SKB_CONSUMED))
50245022
trace_consume_skb(skb, net_tx_action);
50255023
else
50265024
trace_kfree_skb(skb, net_tx_action,
5027-
SKB_DROP_REASON_NOT_SPECIFIED);
5025+
get_kfree_skb_cb(skb)->reason);
50285026

50295027
if (skb->fclone != SKB_FCLONE_UNAVAILABLE)
50305028
__kfree_skb(skb);

0 commit comments

Comments
 (0)