diff mbox series

[net-next,7/9] net: tcp: add skb drop reasons to tcp connect requesting

Message ID 20220516034519.184876-8-imagedong@tencent.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: tcp: add skb drop reasons to tcp state change | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 5741 this patch: 5676
netdev/cc_maintainers warning 7 maintainers not CCed: gnault@redhat.com mathew.j.martineau@linux.intel.com mptcp@lists.linux.dev matthieu.baerts@tessares.net kuniyu@amazon.co.jp aahringo@redhat.com dccp@vger.kernel.org
netdev/build_clang fail Errors and warnings before: 1141 this patch: 1135
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 5887 this patch: 5824
netdev/checkpatch warning WARNING: line length of 100 exceeds 80 columns WARNING: line length of 92 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Menglong Dong May 16, 2022, 3:45 a.m. UTC
From: Menglong Dong <imagedong@tencent.com>

In order to get skb drop reasons during tcp connect requesting code path,
we have to pass the pointer of the 'reason' as a new function argument of
conn_request() in 'struct inet_connection_sock_af_ops'. As the return
value of conn_request() can be positive or negative or 0, it's not
flexible to make it return drop reasons.

As the return value of tcp_conn_request() is 0, so we can treat it as bool
and make it return the skb drop reasons.

The new drop reasons 'LISTENOVERFLOWS' and 'TCP_REQQFULLDROP' are added,
which are used for 'accept queue' and 'request queue' full.

Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
 include/linux/skbuff.h             | 10 ++++++++++
 include/net/inet_connection_sock.h |  3 ++-
 include/net/tcp.h                  |  9 +++++----
 net/dccp/input.c                   |  3 ++-
 net/dccp/ipv4.c                    |  3 ++-
 net/dccp/ipv6.c                    |  3 ++-
 net/ipv4/tcp_input.c               | 27 ++++++++++++++++++---------
 net/ipv4/tcp_ipv4.c                |  9 ++++++---
 net/ipv6/tcp_ipv6.c                | 12 ++++++++----
 net/mptcp/subflow.c                |  6 ++++--
 10 files changed, 59 insertions(+), 26 deletions(-)

Comments

kernel test robot May 16, 2022, 6:34 a.m. UTC | #1
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/menglong8-dong-gmail-com/net-tcp-add-skb-drop-reasons-to-tcp-state-change/20220516-114934
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git d9713088158b23973266e07fdc85ff7d68791a8c
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20220516/202205161441.bl8a0hGC-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/d93679590223760e685126e344dfddd7d7c08cc3
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review menglong8-dong-gmail-com/net-tcp-add-skb-drop-reasons-to-tcp-state-change/20220516-114934
        git checkout d93679590223760e685126e344dfddd7d7c08cc3
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=m68k SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> net/dccp/ipv4.c:584:5: error: conflicting types for 'dccp_v4_conn_request'; have 'int(struct sock *, struct sk_buff *, enum skb_drop_reason *)'
     584 | int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb,
         |     ^~~~~~~~~~~~~~~~~~~~
   In file included from net/dccp/ipv4.c:30:
   net/dccp/dccp.h:258:5: note: previous declaration of 'dccp_v4_conn_request' with type 'int(struct sock *, struct sk_buff *)'
     258 | int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
         |     ^~~~~~~~~~~~~~~~~~~~
   In file included from include/linux/linkage.h:7,
                    from include/linux/kernel.h:17,
                    from include/linux/uio.h:8,
                    from include/linux/socket.h:8,
                    from include/uapi/linux/in.h:24,
                    from include/linux/in.h:19,
                    from include/linux/dccp.h:6,
                    from net/dccp/ipv4.c:9:
   net/dccp/ipv4.c:660:19: error: conflicting types for 'dccp_v4_conn_request'; have 'int(struct sock *, struct sk_buff *, enum skb_drop_reason *)'
     660 | EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
         |                   ^~~~~~~~~~~~~~~~~~~~
   include/linux/export.h:98:28: note: in definition of macro '___EXPORT_SYMBOL'
      98 |         extern typeof(sym) sym;                                                 \
         |                            ^~~
   include/linux/export.h:160:41: note: in expansion of macro '__EXPORT_SYMBOL'
     160 | #define _EXPORT_SYMBOL(sym, sec)        __EXPORT_SYMBOL(sym, sec, "")
         |                                         ^~~~~~~~~~~~~~~
   include/linux/export.h:164:41: note: in expansion of macro '_EXPORT_SYMBOL'
     164 | #define EXPORT_SYMBOL_GPL(sym)          _EXPORT_SYMBOL(sym, "_gpl")
         |                                         ^~~~~~~~~~~~~~
   net/dccp/ipv4.c:660:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL'
     660 | EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
         | ^~~~~~~~~~~~~~~~~
   In file included from net/dccp/ipv4.c:30:
   net/dccp/dccp.h:258:5: note: previous declaration of 'dccp_v4_conn_request' with type 'int(struct sock *, struct sk_buff *)'
     258 | int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
         |     ^~~~~~~~~~~~~~~~~~~~
--
   net/mptcp/subflow.c: In function 'subflow_v6_conn_request':
>> net/mptcp/subflow.c:568:24: error: too few arguments to function 'subflow_v4_conn_request'
     568 |                 return subflow_v4_conn_request(sk, skb);
         |                        ^~~~~~~~~~~~~~~~~~~~~~~
   net/mptcp/subflow.c:535:12: note: declared here
     535 | static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb,
         |            ^~~~~~~~~~~~~~~~~~~~~~~


vim +584 net/dccp/ipv4.c

   583	
 > 584	int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb,
   585				 enum skb_drop_reason *reason)
   586	{
   587		struct inet_request_sock *ireq;
   588		struct request_sock *req;
   589		struct dccp_request_sock *dreq;
   590		const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
   591		struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
   592	
   593		/* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
   594		if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
   595			return 0;	/* discard, don't send a reset here */
   596	
   597		if (dccp_bad_service_code(sk, service)) {
   598			dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
   599			goto drop;
   600		}
   601		/*
   602		 * TW buckets are converted to open requests without
   603		 * limitations, they conserve resources and peer is
   604		 * evidently real one.
   605		 */
   606		dcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;
   607		if (inet_csk_reqsk_queue_is_full(sk))
   608			goto drop;
   609	
   610		if (sk_acceptq_is_full(sk))
   611			goto drop;
   612	
   613		req = inet_reqsk_alloc(&dccp_request_sock_ops, sk, true);
   614		if (req == NULL)
   615			goto drop;
   616	
   617		if (dccp_reqsk_init(req, dccp_sk(sk), skb))
   618			goto drop_and_free;
   619	
   620		dreq = dccp_rsk(req);
   621		if (dccp_parse_options(sk, dreq, skb))
   622			goto drop_and_free;
   623	
   624		if (security_inet_conn_request(sk, skb, req))
   625			goto drop_and_free;
   626	
   627		ireq = inet_rsk(req);
   628		sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
   629		sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
   630		ireq->ir_mark = inet_request_mark(sk, skb);
   631		ireq->ireq_family = AF_INET;
   632		ireq->ir_iif = sk->sk_bound_dev_if;
   633	
   634		/*
   635		 * Step 3: Process LISTEN state
   636		 *
   637		 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
   638		 *
   639		 * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child().
   640		 */
   641		dreq->dreq_isr	   = dcb->dccpd_seq;
   642		dreq->dreq_gsr	   = dreq->dreq_isr;
   643		dreq->dreq_iss	   = dccp_v4_init_sequence(skb);
   644		dreq->dreq_gss     = dreq->dreq_iss;
   645		dreq->dreq_service = service;
   646	
   647		if (dccp_v4_send_response(sk, req))
   648			goto drop_and_free;
   649	
   650		inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
   651		reqsk_put(req);
   652		return 0;
   653	
   654	drop_and_free:
   655		reqsk_free(req);
   656	drop:
   657		__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);
   658		return -1;
   659	}
   660	EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
   661
kernel test robot May 16, 2022, 12:54 p.m. UTC | #2
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/menglong8-dong-gmail-com/net-tcp-add-skb-drop-reasons-to-tcp-state-change/20220516-114934
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git d9713088158b23973266e07fdc85ff7d68791a8c
config: mips-mtx1_defconfig (https://download.01.org/0day-ci/archive/20220516/202205162057.owcP29LO-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 853fa8ee225edf2d0de94b0dcbd31bea916e825e)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install mips cross compiling tool for clang build
        # apt-get install binutils-mips-linux-gnu
        # https://github.com/intel-lab-lkp/linux/commit/d93679590223760e685126e344dfddd7d7c08cc3
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review menglong8-dong-gmail-com/net-tcp-add-skb-drop-reasons-to-tcp-state-change/20220516-114934
        git checkout d93679590223760e685126e344dfddd7d7c08cc3
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=mips SHELL=/bin/bash net/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> net/dccp/ipv4.c:584:5: error: conflicting types for 'dccp_v4_conn_request'
   int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb,
       ^
   net/dccp/dccp.h:258:5: note: previous declaration is here
   int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
       ^
>> net/dccp/ipv4.c:921:21: error: incompatible function pointer types initializing 'int (*)(struct sock *, struct sk_buff *, enum skb_drop_reason *)' with an expression of type 'int (struct sock *, struct sk_buff *)' [-Werror,-Wincompatible-function-pointer-types]
           .conn_request      = dccp_v4_conn_request,
                                ^~~~~~~~~~~~~~~~~~~~
   2 errors generated.


vim +/dccp_v4_conn_request +584 net/dccp/ipv4.c

   583	
 > 584	int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb,
   585				 enum skb_drop_reason *reason)
   586	{
   587		struct inet_request_sock *ireq;
   588		struct request_sock *req;
   589		struct dccp_request_sock *dreq;
   590		const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
   591		struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
   592	
   593		/* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
   594		if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
   595			return 0;	/* discard, don't send a reset here */
   596	
   597		if (dccp_bad_service_code(sk, service)) {
   598			dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE;
   599			goto drop;
   600		}
   601		/*
   602		 * TW buckets are converted to open requests without
   603		 * limitations, they conserve resources and peer is
   604		 * evidently real one.
   605		 */
   606		dcb->dccpd_reset_code = DCCP_RESET_CODE_TOO_BUSY;
   607		if (inet_csk_reqsk_queue_is_full(sk))
   608			goto drop;
   609	
   610		if (sk_acceptq_is_full(sk))
   611			goto drop;
   612	
   613		req = inet_reqsk_alloc(&dccp_request_sock_ops, sk, true);
   614		if (req == NULL)
   615			goto drop;
   616	
   617		if (dccp_reqsk_init(req, dccp_sk(sk), skb))
   618			goto drop_and_free;
   619	
   620		dreq = dccp_rsk(req);
   621		if (dccp_parse_options(sk, dreq, skb))
   622			goto drop_and_free;
   623	
   624		if (security_inet_conn_request(sk, skb, req))
   625			goto drop_and_free;
   626	
   627		ireq = inet_rsk(req);
   628		sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr);
   629		sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr);
   630		ireq->ir_mark = inet_request_mark(sk, skb);
   631		ireq->ireq_family = AF_INET;
   632		ireq->ir_iif = sk->sk_bound_dev_if;
   633	
   634		/*
   635		 * Step 3: Process LISTEN state
   636		 *
   637		 * Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
   638		 *
   639		 * Setting S.SWL/S.SWH to is deferred to dccp_create_openreq_child().
   640		 */
   641		dreq->dreq_isr	   = dcb->dccpd_seq;
   642		dreq->dreq_gsr	   = dreq->dreq_isr;
   643		dreq->dreq_iss	   = dccp_v4_init_sequence(skb);
   644		dreq->dreq_gss     = dreq->dreq_iss;
   645		dreq->dreq_service = service;
   646	
   647		if (dccp_v4_send_response(sk, req))
   648			goto drop_and_free;
   649	
   650		inet_csk_reqsk_queue_hash_add(sk, req, DCCP_TIMEOUT_INIT);
   651		reqsk_put(req);
   652		return 0;
   653	
   654	drop_and_free:
   655		reqsk_free(req);
   656	drop:
   657		__DCCP_INC_STATS(DCCP_MIB_ATTEMPTFAILS);
   658		return -1;
   659	}
   660	EXPORT_SYMBOL_GPL(dccp_v4_conn_request);
   661
diff mbox series

Patch

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 736899cc6a13..4578bbab5a3e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -552,6 +552,14 @@  struct sk_buff;
  * SKB_DROP_REASON_SOCKET_DESTROYED
  *	socket is destroyed and the skb in its receive or send queue
  *	are all dropped
+ *
+ * SKB_DROP_REASON_LISTENOVERFLOWS
+ *	accept queue of the listen socket is full, corresponding to
+ *	LINUX_MIB_LISTENOVERFLOWS
+ *
+ * SKB_DROP_REASON_TCP_REQQFULLDROP
+ *	request queue of the listen socket is full, corresponding to
+ *	LINUX_MIB_TCPREQQFULLDROP
  */
 #define __DEFINE_SKB_DROP_REASON(FN)	\
 	FN(NOT_SPECIFIED)		\
@@ -621,6 +629,8 @@  struct sk_buff;
 	FN(SOCKET_DESTROYED)		\
 	FN(TCP_PAWSACTIVEREJECTED)	\
 	FN(TCP_ABORTONDATA)		\
+	FN(LISTENOVERFLOWS)		\
+	FN(TCP_REQQFULLDROP)		\
 	FN(MAX)
 
 /* The reason of skb drop, which is used in kfree_skb_reason().
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
index 3908296d103f..0600280f308e 100644
--- a/include/net/inet_connection_sock.h
+++ b/include/net/inet_connection_sock.h
@@ -36,7 +36,8 @@  struct inet_connection_sock_af_ops {
 	void	    (*send_check)(struct sock *sk, struct sk_buff *skb);
 	int	    (*rebuild_header)(struct sock *sk);
 	void	    (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb);
-	int	    (*conn_request)(struct sock *sk, struct sk_buff *skb);
+	int	    (*conn_request)(struct sock *sk, struct sk_buff *skb,
+				    enum skb_drop_reason *reason);
 	struct sock *(*syn_recv_sock)(const struct sock *sk, struct sk_buff *skb,
 				      struct request_sock *req,
 				      struct dst_entry *dst,
diff --git a/include/net/tcp.h b/include/net/tcp.h
index ea0eb2d4a743..082dd0627e2e 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -445,7 +445,8 @@  void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
 void tcp_v4_mtu_reduced(struct sock *sk);
 void tcp_req_err(struct sock *sk, u32 seq, bool abort);
 void tcp_ld_RTO_revert(struct sock *sk, u32 seq);
-int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb);
+int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb,
+			enum skb_drop_reason *reason);
 struct sock *tcp_create_openreq_child(const struct sock *sk,
 				      struct request_sock *req,
 				      struct sk_buff *skb);
@@ -2036,9 +2037,9 @@  void tcp4_proc_exit(void);
 #endif
 
 int tcp_rtx_synack(const struct sock *sk, struct request_sock *req);
-int tcp_conn_request(struct request_sock_ops *rsk_ops,
-		     const struct tcp_request_sock_ops *af_ops,
-		     struct sock *sk, struct sk_buff *skb);
+enum skb_drop_reason tcp_conn_request(struct request_sock_ops *rsk_ops,
+				      const struct tcp_request_sock_ops *af_ops,
+				      struct sock *sk, struct sk_buff *skb);
 
 /* TCP af-specific functions */
 struct tcp_sock_af_ops {
diff --git a/net/dccp/input.c b/net/dccp/input.c
index 2cbb757a894f..e12baa56ca59 100644
--- a/net/dccp/input.c
+++ b/net/dccp/input.c
@@ -576,6 +576,7 @@  int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
 	const int old_state = sk->sk_state;
 	bool acceptable;
 	int queued = 0;
+	SKB_DR(reason);
 
 	/*
 	 *  Step 3: Process LISTEN state
@@ -606,7 +607,7 @@  int dccp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
 			 */
 			rcu_read_lock();
 			local_bh_disable();
-			acceptable = inet_csk(sk)->icsk_af_ops->conn_request(sk, skb) >= 0;
+			acceptable = inet_csk(sk)->icsk_af_ops->conn_request(sk, skb, &reason) >= 0;
 			local_bh_enable();
 			rcu_read_unlock();
 			if (!acceptable)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 82696ab86f74..c689385229f0 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -581,7 +581,8 @@  static struct request_sock_ops dccp_request_sock_ops __read_mostly = {
 	.syn_ack_timeout = dccp_syn_ack_timeout,
 };
 
-int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
+int dccp_v4_conn_request(struct sock *sk, struct sk_buff *skb,
+			 enum skb_drop_reason *reason)
 {
 	struct inet_request_sock *ireq;
 	struct request_sock *req;
diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c
index 4d95b6400915..abc82dda4b5b 100644
--- a/net/dccp/ipv6.c
+++ b/net/dccp/ipv6.c
@@ -314,7 +314,8 @@  static struct request_sock_ops dccp6_request_sock_ops = {
 	.syn_ack_timeout = dccp_syn_ack_timeout,
 };
 
-static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
+static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb,
+				enum skb_drop_reason *reason)
 {
 	struct request_sock *req;
 	struct dccp_request_sock *dreq;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 4717af0eaea7..be6275c56b59 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -6455,13 +6455,17 @@  enum skb_drop_reason tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)
 			 */
 			rcu_read_lock();
 			local_bh_disable();
-			acceptable = icsk->icsk_af_ops->conn_request(sk, skb) >= 0;
+			reason = SKB_NOT_DROPPED_YET;
+			acceptable = icsk->icsk_af_ops->conn_request(sk, skb, &reason) >= 0;
 			local_bh_enable();
 			rcu_read_unlock();
 
 			if (!acceptable)
-				return SKB_DROP_REASON_NOT_SPECIFIED;
-			consume_skb(skb);
+				return reason ?: SKB_DROP_REASON_NOT_SPECIFIED;
+			if (reason)
+				kfree_skb_reason(skb, reason);
+			else
+				consume_skb(skb);
 			return SKB_NOT_DROPPED_YET;
 		}
 		SKB_DR_SET(reason, TCP_FLAGS);
@@ -6881,9 +6885,9 @@  u16 tcp_get_syncookie_mss(struct request_sock_ops *rsk_ops,
 }
 EXPORT_SYMBOL_GPL(tcp_get_syncookie_mss);
 
-int tcp_conn_request(struct request_sock_ops *rsk_ops,
-		     const struct tcp_request_sock_ops *af_ops,
-		     struct sock *sk, struct sk_buff *skb)
+enum skb_drop_reason tcp_conn_request(struct request_sock_ops *rsk_ops,
+				      const struct tcp_request_sock_ops *af_ops,
+				      struct sock *sk, struct sk_buff *skb)
 {
 	struct tcp_fastopen_cookie foc = { .len = -1 };
 	__u32 isn = TCP_SKB_CB(skb)->tcp_tw_isn;
@@ -6895,6 +6899,7 @@  int tcp_conn_request(struct request_sock_ops *rsk_ops,
 	bool want_cookie = false;
 	struct dst_entry *dst;
 	struct flowi fl;
+	SKB_DR(reason);
 
 	/* TW buckets are converted to open requests without
 	 * limitations, they conserve resources and peer is
@@ -6903,12 +6908,15 @@  int tcp_conn_request(struct request_sock_ops *rsk_ops,
 	if ((net->ipv4.sysctl_tcp_syncookies == 2 ||
 	     inet_csk_reqsk_queue_is_full(sk)) && !isn) {
 		want_cookie = tcp_syn_flood_action(sk, rsk_ops->slab_name);
-		if (!want_cookie)
+		if (!want_cookie) {
+			SKB_DR_SET(reason, TCP_REQQFULLDROP);
 			goto drop;
+		}
 	}
 
 	if (sk_acceptq_is_full(sk)) {
 		NET_INC_STATS(sock_net(sk), LINUX_MIB_LISTENOVERFLOWS);
+		SKB_DR_SET(reason, LISTENOVERFLOWS);
 		goto drop;
 	}
 
@@ -6964,6 +6972,7 @@  int tcp_conn_request(struct request_sock_ops *rsk_ops,
 			 */
 			pr_drop_req(req, ntohs(tcp_hdr(skb)->source),
 				    rsk_ops->family);
+			SKB_DR_SET(reason, TCP_REQQFULLDROP);
 			goto drop_and_release;
 		}
 
@@ -7016,7 +7025,7 @@  int tcp_conn_request(struct request_sock_ops *rsk_ops,
 		}
 	}
 	reqsk_put(req);
-	return 0;
+	return SKB_NOT_DROPPED_YET;
 
 drop_and_release:
 	dst_release(dst);
@@ -7024,6 +7033,6 @@  int tcp_conn_request(struct request_sock_ops *rsk_ops,
 	__reqsk_free(req);
 drop:
 	tcp_listendrop(sk);
-	return 0;
+	return reason;
 }
 EXPORT_SYMBOL(tcp_conn_request);
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 12a18c5035f4..708f92b03f42 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1458,17 +1458,20 @@  const struct tcp_request_sock_ops tcp_request_sock_ipv4_ops = {
 	.send_synack	=	tcp_v4_send_synack,
 };
 
-int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)
+int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb,
+			enum skb_drop_reason *reason)
 {
 	/* Never answer to SYNs send to broadcast or multicast */
 	if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST))
 		goto drop;
 
-	return tcp_conn_request(&tcp_request_sock_ops,
-				&tcp_request_sock_ipv4_ops, sk, skb);
+	*reason = tcp_conn_request(&tcp_request_sock_ops,
+				   &tcp_request_sock_ipv4_ops, sk, skb);
+	return *reason;
 
 drop:
 	tcp_listendrop(sk);
+	*reason = SKB_DROP_REASON_IP_INADDRERRORS;
 	return 0;
 }
 EXPORT_SYMBOL(tcp_v4_conn_request);
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index d8236d51dd47..27c51991bd54 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1148,24 +1148,28 @@  u16 tcp_v6_get_syncookie(struct sock *sk, struct ipv6hdr *iph,
 	return mss;
 }
 
-static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)
+static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb,
+			       enum skb_drop_reason *reason)
 {
 	if (skb->protocol == htons(ETH_P_IP))
-		return tcp_v4_conn_request(sk, skb);
+		return tcp_v4_conn_request(sk, skb, reason);
 
 	if (!ipv6_unicast_destination(skb))
 		goto drop;
 
 	if (ipv6_addr_v4mapped(&ipv6_hdr(skb)->saddr)) {
 		__IP6_INC_STATS(sock_net(sk), NULL, IPSTATS_MIB_INHDRERRORS);
+		*reason = SKB_DROP_REASON_IP_INADDRERRORS;
 		return 0;
 	}
 
-	return tcp_conn_request(&tcp6_request_sock_ops,
-				&tcp_request_sock_ipv6_ops, sk, skb);
+	*reason = tcp_conn_request(&tcp6_request_sock_ops,
+				   &tcp_request_sock_ipv6_ops, sk, skb);
+	return *reason;
 
 drop:
 	tcp_listendrop(sk);
+	*reason = SKB_DROP_REASON_IP_INADDRERRORS;
 	return 0; /* don't send reset */
 }
 
diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
index 6d59336a8e1e..267f4e47236a 100644
--- a/net/mptcp/subflow.c
+++ b/net/mptcp/subflow.c
@@ -532,7 +532,8 @@  static int subflow_v6_rebuild_header(struct sock *sk)
 struct request_sock_ops mptcp_subflow_request_sock_ops;
 static struct tcp_request_sock_ops subflow_request_sock_ipv4_ops __ro_after_init;
 
-static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb)
+static int subflow_v4_conn_request(struct sock *sk, struct sk_buff *skb,
+				   enum skb_drop_reason *reason)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);
 
@@ -556,7 +557,8 @@  static struct inet_connection_sock_af_ops subflow_v6_specific __ro_after_init;
 static struct inet_connection_sock_af_ops subflow_v6m_specific __ro_after_init;
 static struct proto tcpv6_prot_override;
 
-static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb)
+static int subflow_v6_conn_request(struct sock *sk, struct sk_buff *skb,
+				   enum skb_drop_reason *reason)
 {
 	struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk);