[PATCH net-next v4 4/8] net: inet: add skb drop reason to inet_csk_destroy_sock()

menglong8.dong
2022-06-17T10:06:24Z

skb dropping in inet_csk_destroy_sock() seems to be a common case. Add
the new drop reason 'SKB_DROP_REASON_SOCKET_DESTROIED' and apply it to
inet_csk_destroy_sock() to stop confusing users with 'NOT_SPECIFIED'.

Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
include/net/dropreason.h | 5 +++++
net/ipv4/inet_connection_sock.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/net/dropreason.h b/include/net/dropreason.h
index fae9b40e54fa..3c6f1e299c35 100644
--- a/include/net/dropreason.h
+++ b/include/net/dropreason.h
@@ -231,6 +231,11 @@ enum skb_drop_reason {
* MTU)
*/
SKB_DROP_REASON_PKT_TOO_BIG,
+ /**
+ * @SKB_DROP_REASON_SOCKET_DESTROYED: socket is destroyed and the
+ * skb in its receive or send queue are all dropped
+ */
+ SKB_DROP_REASON_SOCKET_DESTROYED,
/**
* @SKB_DROP_REASON_MAX: the maximum of drop reason, which shouldn't be
* used as a real 'reason'
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index c0b7e6c21360..1812060f24cb 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -1129,7 +1129,7 @@ void inet_csk_destroy_sock(struct sock *sk)

sk->sk_prot->destroy(sk);

- sk_stream_kill_queues(sk);
+ sk_stream_kill_queues_reason(sk, SKB_DROP_REASON_SOCKET_DESTROYED);

xfrm_sk_free_policy(sk);

--
2.36.1