Commit a5736edd authored by Menglong Dong's avatar Menglong Dong Committed by David S. Miller

net: neigh: use kfree_skb_reason() for __neigh_event_send()

Replace kfree_skb() used in __neigh_event_send() with
kfree_skb_reason(). Following drop reasons are added:

SKB_DROP_REASON_NEIGH_FAILED
SKB_DROP_REASON_NEIGH_QUEUEFULL
SKB_DROP_REASON_NEIGH_DEAD

The first two reasons above should be the hot path that skb drops
in neighbour subsystem.
Reviewed-by: default avatarMengen Sun <mengensun@tencent.com>
Reviewed-by: default avatarHao Peng <flyingpeng@tencent.com>
Signed-off-by: default avatarMenglong Dong <imagedong@tencent.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5e187189
...@@ -389,6 +389,11 @@ enum skb_drop_reason { ...@@ -389,6 +389,11 @@ enum skb_drop_reason {
SKB_DROP_REASON_NEIGH_CREATEFAIL, /* failed to create neigh SKB_DROP_REASON_NEIGH_CREATEFAIL, /* failed to create neigh
* entry * entry
*/ */
SKB_DROP_REASON_NEIGH_FAILED, /* neigh entry in failed state */
SKB_DROP_REASON_NEIGH_QUEUEFULL, /* arp_queue for neigh
* entry is full
*/
SKB_DROP_REASON_NEIGH_DEAD, /* neigh entry is dead */
SKB_DROP_REASON_MAX, SKB_DROP_REASON_MAX,
}; };
......
...@@ -42,6 +42,9 @@ ...@@ -42,6 +42,9 @@
BPF_CGROUP_EGRESS) \ BPF_CGROUP_EGRESS) \
EM(SKB_DROP_REASON_IPV6DISABLED, IPV6DISABLED) \ EM(SKB_DROP_REASON_IPV6DISABLED, IPV6DISABLED) \
EM(SKB_DROP_REASON_NEIGH_CREATEFAIL, NEIGH_CREATEFAIL) \ EM(SKB_DROP_REASON_NEIGH_CREATEFAIL, NEIGH_CREATEFAIL) \
EM(SKB_DROP_REASON_NEIGH_FAILED, NEIGH_FAILED) \
EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL) \
EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \
EMe(SKB_DROP_REASON_MAX, MAX) EMe(SKB_DROP_REASON_MAX, MAX)
#undef EM #undef EM
......
...@@ -1171,7 +1171,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb, ...@@ -1171,7 +1171,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb,
neigh->updated = jiffies; neigh->updated = jiffies;
write_unlock_bh(&neigh->lock); write_unlock_bh(&neigh->lock);
kfree_skb(skb); kfree_skb_reason(skb, SKB_DROP_REASON_NEIGH_FAILED);
return 1; return 1;
} }
} else if (neigh->nud_state & NUD_STALE) { } else if (neigh->nud_state & NUD_STALE) {
...@@ -1193,7 +1193,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb, ...@@ -1193,7 +1193,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb,
if (!buff) if (!buff)
break; break;
neigh->arp_queue_len_bytes -= buff->truesize; neigh->arp_queue_len_bytes -= buff->truesize;
kfree_skb(buff); kfree_skb_reason(buff, SKB_DROP_REASON_NEIGH_QUEUEFULL);
NEIGH_CACHE_STAT_INC(neigh->tbl, unres_discards); NEIGH_CACHE_STAT_INC(neigh->tbl, unres_discards);
} }
skb_dst_force(skb); skb_dst_force(skb);
...@@ -1215,7 +1215,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb, ...@@ -1215,7 +1215,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb,
if (neigh->nud_state & NUD_STALE) if (neigh->nud_state & NUD_STALE)
goto out_unlock_bh; goto out_unlock_bh;
write_unlock_bh(&neigh->lock); write_unlock_bh(&neigh->lock);
kfree_skb(skb); kfree_skb_reason(skb, SKB_DROP_REASON_NEIGH_DEAD);
trace_neigh_event_send_dead(neigh, 1); trace_neigh_event_send_dead(neigh, 1);
return 1; return 1;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment