diff mbox series

[net-next,v4,1/5] tcp: add dropreasons definitions and prepare for cookie check

Message ID 20240213134205.8705-2-kerneljasonxing@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series introduce drop reasons for cookie check | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 6001 this patch: 6001
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 2130 this patch: 2130
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 6317 this patch: 6317
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 79 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-13--21-00 (tests: 1437)

Commit Message

Jason Xing Feb. 13, 2024, 1:42 p.m. UTC
From: Jason Xing <kernelxing@tencent.com>

Only add five drop reasons to detect the condition of skb dropped
in cookie check for later use.

Signed-off-by: Jason Xing <kernelxing@tencent.com>
--
v2
Link: https://lore.kernel.org/netdev/20240212172302.3f95e454@kernel.org/
1. fix misspelled name in kdoc as Jakub said
---
 include/net/dropreason-core.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Eric Dumazet Feb. 13, 2024, 3:23 p.m. UTC | #1
On Tue, Feb 13, 2024 at 2:42 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
>
> From: Jason Xing <kernelxing@tencent.com>
>
> Only add five drop reasons to detect the condition of skb dropped
> in cookie check for later use.
>
> Signed-off-by: Jason Xing <kernelxing@tencent.com>
> --
> v2
> Link: https://lore.kernel.org/netdev/20240212172302.3f95e454@kernel.org/
> 1. fix misspelled name in kdoc as Jakub said
> ---
>  include/net/dropreason-core.h | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
> index 6d3a20163260..065caba42b0b 100644
> --- a/include/net/dropreason-core.h
> +++ b/include/net/dropreason-core.h
> @@ -6,6 +6,7 @@
>  #define DEFINE_DROP_REASON(FN, FNe)    \
>         FN(NOT_SPECIFIED)               \
>         FN(NO_SOCKET)                   \
> +       FN(NO_REQSK_ALLOC)              \
>         FN(PKT_TOO_SMALL)               \
>         FN(TCP_CSUM)                    \
>         FN(SOCKET_FILTER)               \
> @@ -43,10 +44,12 @@
>         FN(TCP_FASTOPEN)                \
>         FN(TCP_OLD_ACK)                 \
>         FN(TCP_TOO_OLD_ACK)             \
> +       FN(COOKIE_NOCHILD)              \
>         FN(TCP_ACK_UNSENT_DATA)         \
>         FN(TCP_OFO_QUEUE_PRUNE)         \
>         FN(TCP_OFO_DROP)                \
>         FN(IP_OUTNOROUTES)              \
> +       FN(IP_ROUTEOUTPUTKEY)           \
>         FN(BPF_CGROUP_EGRESS)           \
>         FN(IPV6DISABLED)                \
>         FN(NEIGH_CREATEFAIL)            \
> @@ -54,6 +57,7 @@
>         FN(NEIGH_QUEUEFULL)             \
>         FN(NEIGH_DEAD)                  \
>         FN(TC_EGRESS)                   \
> +       FN(SECURITY_HOOK)               \
>         FN(QDISC_DROP)                  \
>         FN(CPU_BACKLOG)                 \
>         FN(XDP)                         \
> @@ -71,6 +75,7 @@
>         FN(TAP_TXFILTER)                \
>         FN(ICMP_CSUM)                   \
>         FN(INVALID_PROTO)               \
> +       FN(INVALID_DST)                 \

We already have  SKB_DROP_REASON_IP_OUTNOROUTES ?

>         FN(IP_INADDRERRORS)             \
>         FN(IP_INNOROUTES)               \
>         FN(PKT_TOO_BIG)                 \
> @@ -107,6 +112,11 @@ enum skb_drop_reason {
>         SKB_DROP_REASON_NOT_SPECIFIED,
>         /** @SKB_DROP_REASON_NO_SOCKET: socket not found */
>         SKB_DROP_REASON_NO_SOCKET,
> +       /**
> +        * @SKB_DROP_REASON_NO_REQSK_ALLOC: request socket allocation failed
> +        * probably because of no available memory for now
> +        */

We have SKB_DROP_REASON_NOMEM, I do not think we need to be very precise.
REQSK are implementation details.

> +       SKB_DROP_REASON_NO_REQSK_ALLOC,
>         /** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */
>         SKB_DROP_REASON_PKT_TOO_SMALL,
>         /** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */
> @@ -243,6 +253,11 @@ enum skb_drop_reason {
>         SKB_DROP_REASON_TCP_OLD_ACK,
>         /** @SKB_DROP_REASON_TCP_TOO_OLD_ACK: TCP ACK is too old */
>         SKB_DROP_REASON_TCP_TOO_OLD_ACK,
> +       /**
> +        * @SKB_DROP_REASON_COOKIE_NOCHILD: no child socket in cookie mode
> +        * reason could be the failure of child socket allocation

This makes no sense to me. There are many reasons for this.

Either the reason is deterministic, or just reuse a generic and
existing drop_reason that can be augmented later.

You are adding weak or duplicate drop_reasons, we already have them.
Jason Xing Feb. 13, 2024, 5:16 p.m. UTC | #2
On Tue, Feb 13, 2024 at 11:24 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Tue, Feb 13, 2024 at 2:42 PM Jason Xing <kerneljasonxing@gmail.com> wrote:
> >
> > From: Jason Xing <kernelxing@tencent.com>
> >
> > Only add five drop reasons to detect the condition of skb dropped
> > in cookie check for later use.
> >
> > Signed-off-by: Jason Xing <kernelxing@tencent.com>
> > --
> > v2
> > Link: https://lore.kernel.org/netdev/20240212172302.3f95e454@kernel.org/
> > 1. fix misspelled name in kdoc as Jakub said
> > ---
> >  include/net/dropreason-core.h | 21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >
> > diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
> > index 6d3a20163260..065caba42b0b 100644
> > --- a/include/net/dropreason-core.h
> > +++ b/include/net/dropreason-core.h
> > @@ -6,6 +6,7 @@
> >  #define DEFINE_DROP_REASON(FN, FNe)    \
> >         FN(NOT_SPECIFIED)               \
> >         FN(NO_SOCKET)                   \
> > +       FN(NO_REQSK_ALLOC)              \
> >         FN(PKT_TOO_SMALL)               \
> >         FN(TCP_CSUM)                    \
> >         FN(SOCKET_FILTER)               \
> > @@ -43,10 +44,12 @@
> >         FN(TCP_FASTOPEN)                \
> >         FN(TCP_OLD_ACK)                 \
> >         FN(TCP_TOO_OLD_ACK)             \
> > +       FN(COOKIE_NOCHILD)              \
> >         FN(TCP_ACK_UNSENT_DATA)         \
> >         FN(TCP_OFO_QUEUE_PRUNE)         \
> >         FN(TCP_OFO_DROP)                \
> >         FN(IP_OUTNOROUTES)              \
> > +       FN(IP_ROUTEOUTPUTKEY)           \
> >         FN(BPF_CGROUP_EGRESS)           \
> >         FN(IPV6DISABLED)                \
> >         FN(NEIGH_CREATEFAIL)            \
> > @@ -54,6 +57,7 @@
> >         FN(NEIGH_QUEUEFULL)             \
> >         FN(NEIGH_DEAD)                  \
> >         FN(TC_EGRESS)                   \
> > +       FN(SECURITY_HOOK)               \
> >         FN(QDISC_DROP)                  \
> >         FN(CPU_BACKLOG)                 \
> >         FN(XDP)                         \
> > @@ -71,6 +75,7 @@
> >         FN(TAP_TXFILTER)                \
> >         FN(ICMP_CSUM)                   \
> >         FN(INVALID_PROTO)               \
> > +       FN(INVALID_DST)                 \
>
> We already have  SKB_DROP_REASON_IP_OUTNOROUTES ?

Oh right, I will reuse it.

>
> >         FN(IP_INADDRERRORS)             \
> >         FN(IP_INNOROUTES)               \
> >         FN(PKT_TOO_BIG)                 \
> > @@ -107,6 +112,11 @@ enum skb_drop_reason {
> >         SKB_DROP_REASON_NOT_SPECIFIED,
> >         /** @SKB_DROP_REASON_NO_SOCKET: socket not found */
> >         SKB_DROP_REASON_NO_SOCKET,
> > +       /**
> > +        * @SKB_DROP_REASON_NO_REQSK_ALLOC: request socket allocation failed
> > +        * probably because of no available memory for now
> > +        */
>
> We have SKB_DROP_REASON_NOMEM, I do not think we need to be very precise.
> REQSK are implementation details.

You're right about this.

>
> > +       SKB_DROP_REASON_NO_REQSK_ALLOC,
> >         /** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */
> >         SKB_DROP_REASON_PKT_TOO_SMALL,
> >         /** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */
> > @@ -243,6 +253,11 @@ enum skb_drop_reason {
> >         SKB_DROP_REASON_TCP_OLD_ACK,
> >         /** @SKB_DROP_REASON_TCP_TOO_OLD_ACK: TCP ACK is too old */
> >         SKB_DROP_REASON_TCP_TOO_OLD_ACK,
> > +       /**
> > +        * @SKB_DROP_REASON_COOKIE_NOCHILD: no child socket in cookie mode
> > +        * reason could be the failure of child socket allocation
>
> This makes no sense to me. There are many reasons for this.

Let me think about a proper new name.

>
> Either the reason is deterministic, or just reuse a generic and
> existing drop_reason that can be augmented later.

I learned that.

Thanks,
Jason

>
> You are adding weak or duplicate drop_reasons, we already have them.
diff mbox series

Patch

diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index 6d3a20163260..065caba42b0b 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -6,6 +6,7 @@ 
 #define DEFINE_DROP_REASON(FN, FNe)	\
 	FN(NOT_SPECIFIED)		\
 	FN(NO_SOCKET)			\
+	FN(NO_REQSK_ALLOC)		\
 	FN(PKT_TOO_SMALL)		\
 	FN(TCP_CSUM)			\
 	FN(SOCKET_FILTER)		\
@@ -43,10 +44,12 @@ 
 	FN(TCP_FASTOPEN)		\
 	FN(TCP_OLD_ACK)			\
 	FN(TCP_TOO_OLD_ACK)		\
+	FN(COOKIE_NOCHILD)		\
 	FN(TCP_ACK_UNSENT_DATA)		\
 	FN(TCP_OFO_QUEUE_PRUNE)		\
 	FN(TCP_OFO_DROP)		\
 	FN(IP_OUTNOROUTES)		\
+	FN(IP_ROUTEOUTPUTKEY)		\
 	FN(BPF_CGROUP_EGRESS)		\
 	FN(IPV6DISABLED)		\
 	FN(NEIGH_CREATEFAIL)		\
@@ -54,6 +57,7 @@ 
 	FN(NEIGH_QUEUEFULL)		\
 	FN(NEIGH_DEAD)			\
 	FN(TC_EGRESS)			\
+	FN(SECURITY_HOOK)		\
 	FN(QDISC_DROP)			\
 	FN(CPU_BACKLOG)			\
 	FN(XDP)				\
@@ -71,6 +75,7 @@ 
 	FN(TAP_TXFILTER)		\
 	FN(ICMP_CSUM)			\
 	FN(INVALID_PROTO)		\
+	FN(INVALID_DST)			\
 	FN(IP_INADDRERRORS)		\
 	FN(IP_INNOROUTES)		\
 	FN(PKT_TOO_BIG)			\
@@ -107,6 +112,11 @@  enum skb_drop_reason {
 	SKB_DROP_REASON_NOT_SPECIFIED,
 	/** @SKB_DROP_REASON_NO_SOCKET: socket not found */
 	SKB_DROP_REASON_NO_SOCKET,
+	/**
+	 * @SKB_DROP_REASON_NO_REQSK_ALLOC: request socket allocation failed
+	 * probably because of no available memory for now
+	 */
+	SKB_DROP_REASON_NO_REQSK_ALLOC,
 	/** @SKB_DROP_REASON_PKT_TOO_SMALL: packet size is too small */
 	SKB_DROP_REASON_PKT_TOO_SMALL,
 	/** @SKB_DROP_REASON_TCP_CSUM: TCP checksum error */
@@ -243,6 +253,11 @@  enum skb_drop_reason {
 	SKB_DROP_REASON_TCP_OLD_ACK,
 	/** @SKB_DROP_REASON_TCP_TOO_OLD_ACK: TCP ACK is too old */
 	SKB_DROP_REASON_TCP_TOO_OLD_ACK,
+	/**
+	 * @SKB_DROP_REASON_COOKIE_NOCHILD: no child socket in cookie mode
+	 * reason could be the failure of child socket allocation
+	 */
+	SKB_DROP_REASON_COOKIE_NOCHILD,
 	/**
 	 * @SKB_DROP_REASON_TCP_ACK_UNSENT_DATA: TCP ACK for data we haven't
 	 * sent yet
@@ -254,6 +269,8 @@  enum skb_drop_reason {
 	SKB_DROP_REASON_TCP_OFO_DROP,
 	/** @SKB_DROP_REASON_IP_OUTNOROUTES: route lookup failed */
 	SKB_DROP_REASON_IP_OUTNOROUTES,
+	/** @SKB_DROP_REASON_IP_ROUTEOUTPUTKEY: route output key failed */
+	SKB_DROP_REASON_IP_ROUTEOUTPUTKEY,
 	/**
 	 * @SKB_DROP_REASON_BPF_CGROUP_EGRESS: dropped by BPF_PROG_TYPE_CGROUP_SKB
 	 * eBPF program
@@ -271,6 +288,8 @@  enum skb_drop_reason {
 	SKB_DROP_REASON_NEIGH_DEAD,
 	/** @SKB_DROP_REASON_TC_EGRESS: dropped in TC egress HOOK */
 	SKB_DROP_REASON_TC_EGRESS,
+	/** @SKB_DROP_REASON_SECURITY_HOOK: dropped due to security HOOK */
+	SKB_DROP_REASON_SECURITY_HOOK,
 	/**
 	 * @SKB_DROP_REASON_QDISC_DROP: dropped by qdisc when packet outputting (
 	 * failed to enqueue to current qdisc)
@@ -333,6 +352,8 @@  enum skb_drop_reason {
 	 * such as a broadcasts ICMP_TIMESTAMP
 	 */
 	SKB_DROP_REASON_INVALID_PROTO,
+	/** @SKB_DROP_REASON_INVALID_DST: look-up dst entry error */
+	SKB_DROP_REASON_INVALID_DST,
 	/**
 	 * @SKB_DROP_REASON_IP_INADDRERRORS: host unreachable, corresponding to
 	 * IPSTATS_MIB_INADDRERRORS