[Devel] [PATCH RHEL9 COMMIT] net: netfilter: use kfree_drop_reason() for NF_DROP
Konstantin Khorenko
khorenko at virtuozzo.com
Mon Jan 16 20:56:39 MSK 2023
The commit is pushed to "branch-rh9-5.14.0-162.6.1.vz9.18.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-162.6.1.vz9.18.2
------>
commit 27c4b2b6f1f5eed32517a5924d1757f7af8c9f8c
Author: Menglong Dong <imagedong at tencent.com>
Date: Tue Jan 3 17:38:57 2023 +0200
net: netfilter: use kfree_drop_reason() for NF_DROP
Replace kfree_skb() with kfree_skb_reason() in nf_hook_slow() when
skb is dropped by reason of NF_DROP. Following new drop reasons
are introduced:
SKB_DROP_REASON_NETFILTER_DROP
Signed-off-by: Menglong Dong <imagedong at tencent.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
Acked-by: Nikolay Borisov <nborisov at suse.com>
Signed-off-by: Nikolay Borisov <nikolay.borisov at virtuozzo.com>
======
Patchset description:
ms/net: Annotate skb free sites with reason
This series backports most of the patches that add a reason to skb free sites.
https://jira.sw.ru/browse/PSBM-143302
Feature: net: improve verbosity of dropped packets reporting
---
include/linux/skbuff.h | 1 +
include/trace/events/skb.h | 1 +
net/netfilter/core.c | 2 +-
3 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 62dc2930d1ce..629296082a9b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -318,6 +318,7 @@ enum skb_drop_reason {
SKB_DROP_REASON_TCP_CSUM,
SKB_DROP_REASON_TCP_FILTER,
SKB_DROP_REASON_UDP_CSUM,
+ SKB_DROP_REASON_NETFILTER_DROP, /* dropped by netfilter */
SKB_DROP_REASON_MAX,
};
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 3e042ca2cedb..beed7bb2bc0e 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -16,6 +16,7 @@
EM(SKB_DROP_REASON_TCP_CSUM, TCP_CSUM) \
EM(SKB_DROP_REASON_TCP_FILTER, TCP_FILTER) \
EM(SKB_DROP_REASON_UDP_CSUM, UDP_CSUM) \
+ EM(SKB_DROP_REASON_NETFILTER_DROP, NETFILTER_DROP) \
EMe(SKB_DROP_REASON_MAX, MAX)
#undef EM
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 6ef43e59400d..6fc51a07ba4f 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -593,7 +593,7 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
case NF_ACCEPT:
break;
case NF_DROP:
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_NETFILTER_DROP);
ret = NF_DROP_GETERR(verdict);
if (ret == 0)
ret = -EPERM;
More information about the Devel
mailing list