add more drop reasons in tcp receive path
Subsystems (3)
cover add more drop reasons in tcp receive path
From: Jason Xing <[email protected]>
When I was debugging the reason about why the skb should be dropped in syn cookie mode, I found out that this NOT_SPECIFIED reason is too general. Thus I decided to refine it.
Jason Xing (2):
tcp: add more DROP REASONs in cookie check
tcp: add more DROP REASONS in child process
include/net/dropreason-core.h | 18 ++++++++++++++++++ include/net/tcp.h | 8 +++++--- net/ipv4/syncookies.c | 18 ++++++++++++++---- net/ipv4/tcp_input.c | 19 +++++++++++++++---- net/ipv4/tcp_ipv4.c | 13 +++++++------ net/ipv4/tcp_minisocks.c | 4 ++-- net/ipv6/tcp_ipv6.c | 6 +++--- 7 files changed, 64 insertions(+), 22 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/2 tcp: add more DROP REASONs in cookie check
From: Jason Xing <[email protected]>
Since the commit 8eba65fa5f06 ("net: tcp: use kfree_skb_reason() for tcp_v{4,6}_do_rcv()") introduced the drop reason mechanism, this function is always using NOT_SPECIFIED which is too general and unhelpful to us if we want to track this part.
--- include/net/dropreason-core.h | 12 ++++++++++++ include/net/tcp.h | 3 ++- net/ipv4/syncookies.c | 18 ++++++++++++++---- net/ipv4/tcp_ipv4.c | 7 ++++--- 4 files changed, 32 insertions(+), 8 deletions(-)
include/net/dropreason-core.h +12 -0
@@ -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) \
@@ -107,6 +111,8 @@ 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 */ +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 +249,8 @@ 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 */ + SKB_DROP_REASON_COOKIE_NOCHILD,/** * @SKB_DROP_REASON_TCP_ACK_UNSENT_DATA: TCP ACK for data we haven't * sent yet
@@ -254,6 +262,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 +281,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)
include/net/tcp.h +2 -1
@@ -492,7 +492,8 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,struct request_sock *req, struct dst_entry *dst);int __cookie_v4_check (const struct iphdr *iph,const struct tcphdr *th); -struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb); +struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *reason); struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk, struct sk_buff *skb, struct tcp_options_received *tcp_opt,
net/ipv4/syncookies.c +14 -4
@@ -395,7 +395,8 @@ static struct request_sock *cookie_tcp_check(struct net *net, struct sock *sk,* Output is listener if incoming packet would not create a child * NULL if memory could not be allocated. */ -struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb) +struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *reason) {struct ip_options *opt = &TCP_SKB_CB (skb)->header.h4.opt;const struct tcphdr *th =tcp_hdr (skb);
@@ -420,8 +421,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)if (IS_ERR (req)) goto out; } -if (!req) +if (!req) { + *reason =SKB_DROP_REASON_NO_REQSK_ALLOC ; goto out_drop; + } ireq =inet_rsk (req);
@@ -433,8 +436,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)*/ RCU_INIT_POINTER (ireq->ireq_opt,tcp_v4_save_options (net, skb)); -if (security_inet_conn_request (sk, skb, req)) +if (security_inet_conn_request (sk, skb, req)) { + *reason =SKB_DROP_REASON_SECURITY_HOOK ; goto out_free; + }tcp_ao_syncookie (sk, skb, req,AF_INET );
@@ -451,8 +456,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) ireq->ir_loc_addr, th->source, th->dest, sk->sk_uid);security_req_classify_flow (req,flowi4_to_flowi_common (&fl4)); rt =ip_route_output_key (net, &fl4); -if (IS_ERR (rt)) +if (IS_ERR (rt)) { + *reason =SKB_DROP_REASON_IP_ROUTEOUTPUTKEY ; goto out_free; + }/* Try to redo what tcp_v4_send_synack did. */ req->rsk_window_clamp = tp->window_clamp ? :dst_metric (&rt->dst,RTAX_WINDOW );
@@ -477,6 +484,9 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)*/ if (ret)inet_sk (ret)->cork.fl.u.ip4 = fl4; +else + *reason =SKB_DROP_REASON_COOKIE_NOCHILD ; + out:return ret; out_free:
net/ipv4/tcp_ipv4.c +4 -3
@@ -1846,13 +1846,14 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, }EXPORT_SYMBOL (tcp_v4_syn_recv_sock); -static struct sock *tcp_v4_cookie_check (struct sock *sk,struct sk_buff *skb) +static struct sock *tcp_v4_cookie_check (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *reason) {#ifdef CONFIG_SYN_COOKIES const struct tcphdr *th =tcp_hdr (skb);if (!th->syn) - sk =cookie_v4_check (sk, skb); + sk =cookie_v4_check (sk, skb, reason);#endif return sk; }
@@ -1912,7 +1913,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) goto csum_err;if (sk->sk_state ==TCP_LISTEN ) { -struct sock *nsk =tcp_v4_cookie_check (sk, skb); +struct sock *nsk =tcp_v4_cookie_check (sk, skb, &reason);if (!nsk) goto discard;
Signature · 1 line
2.37.3
PATCH 1/2 tcp: add more DROP REASONs in cookie check
In reply to Jason XingFrom: Jason Xing <[email protected]>
Since the commit 8eba65fa5f06 ("net: tcp: use kfree_skb_reason() for tcp_v{4,6}_do_rcv()") introduced the drop reason mechanism, this function is always using NOT_SPECIFIED which is too general and unhelpful to us if we want to track this part.
--- include/net/dropreason-core.h | 12 ++++++++++++ include/net/tcp.h | 3 ++- net/ipv4/syncookies.c | 18 ++++++++++++++---- net/ipv4/tcp_ipv4.c | 7 ++++--- 4 files changed, 32 insertions(+), 8 deletions(-)
include/net/dropreason-core.h +12 -0
@@ -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) \
@@ -107,6 +111,8 @@ 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 */ +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 +249,8 @@ 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 */ + SKB_DROP_REASON_COOKIE_NOCHILD,/** * @SKB_DROP_REASON_TCP_ACK_UNSENT_DATA: TCP ACK for data we haven't * sent yet
@@ -254,6 +262,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 +281,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)
include/net/tcp.h +2 -1
@@ -492,7 +492,8 @@ struct sock *tcp_get_cookie_sock(struct sock *sk, struct sk_buff *skb,struct request_sock *req, struct dst_entry *dst);int __cookie_v4_check (const struct iphdr *iph,const struct tcphdr *th); -struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb); +struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *reason); struct request_sock *cookie_tcp_reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk, struct sk_buff *skb, struct tcp_options_received *tcp_opt,
net/ipv4/syncookies.c +14 -4
@@ -395,7 +395,8 @@ static struct request_sock *cookie_tcp_check(struct net *net, struct sock *sk,* Output is listener if incoming packet would not create a child * NULL if memory could not be allocated. */ -struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb) +struct sock *cookie_v4_check (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *reason) {struct ip_options *opt = &TCP_SKB_CB (skb)->header.h4.opt;const struct tcphdr *th =tcp_hdr (skb);
@@ -420,8 +421,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)if (IS_ERR (req)) goto out; } -if (!req) +if (!req) { + *reason =SKB_DROP_REASON_NO_REQSK_ALLOC ; goto out_drop; + } ireq =inet_rsk (req);
@@ -433,8 +436,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)*/ RCU_INIT_POINTER (ireq->ireq_opt,tcp_v4_save_options (net, skb)); -if (security_inet_conn_request (sk, skb, req)) +if (security_inet_conn_request (sk, skb, req)) { + *reason =SKB_DROP_REASON_SECURITY_HOOK ; goto out_free; + }tcp_ao_syncookie (sk, skb, req,AF_INET );
@@ -451,8 +456,10 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb) ireq->ir_loc_addr, th->source, th->dest, sk->sk_uid);security_req_classify_flow (req,flowi4_to_flowi_common (&fl4)); rt =ip_route_output_key (net, &fl4); -if (IS_ERR (rt)) +if (IS_ERR (rt)) { + *reason =SKB_DROP_REASON_IP_ROUTEOUTPUTKEY ; goto out_free; + }/* Try to redo what tcp_v4_send_synack did. */ req->rsk_window_clamp = tp->window_clamp ? :dst_metric (&rt->dst,RTAX_WINDOW );
@@ -477,6 +484,9 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb)*/ if (ret)inet_sk (ret)->cork.fl.u.ip4 = fl4; +else + *reason =SKB_DROP_REASON_COOKIE_NOCHILD ; + out:return ret; out_free:
net/ipv4/tcp_ipv4.c +4 -3
@@ -1846,13 +1846,14 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, }EXPORT_SYMBOL (tcp_v4_syn_recv_sock); -static struct sock *tcp_v4_cookie_check (struct sock *sk,struct sk_buff *skb) +static struct sock *tcp_v4_cookie_check (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *reason) {#ifdef CONFIG_SYN_COOKIES const struct tcphdr *th =tcp_hdr (skb);if (!th->syn) - sk =cookie_v4_check (sk, skb); + sk =cookie_v4_check (sk, skb, reason);#endif return sk; }
@@ -1912,7 +1913,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) goto csum_err;if (sk->sk_state ==TCP_LISTEN ) { -struct sock *nsk =tcp_v4_cookie_check (sk, skb); +struct sock *nsk =tcp_v4_cookie_check (sk, skb, &reason);if (!nsk) goto discard;
Signature · 1 line
2.37.3
PATCH 2/2 tcp: add more DROP REASONS in child process
In reply to Jason XingFrom: Jason Xing <[email protected]>
As the title said, add more reasons to narrow down the range about why the skb should be dropped.
--- include/net/dropreason-core.h | 6 ++++++ include/net/tcp.h | 5 +++-- net/ipv4/tcp_input.c | 19 +++++++++++++++---- net/ipv4/tcp_ipv4.c | 6 +++--- net/ipv4/tcp_minisocks.c | 4 ++-- net/ipv6/tcp_ipv6.c | 6 +++--- 6 files changed, 32 insertions(+), 14 deletions(-)
include/net/dropreason-core.h +6 -0
@@ -31,6 +31,8 @@ FN(TCP_AOFAILURE) \ FN(SOCKET_BACKLOG) \ FN(TCP_FLAGS) \ + FN(TCP_CONNREQNOTACCEPTABLE) \ + FN(TCP_ABORTONDATA) \ FN(TCP_ZEROWINDOW) \ FN(TCP_OLD_DATA) \ FN(TCP_OVERWINDOW) \
@@ -203,6 +205,10 @@ enum skb_drop_reason {SKB_DROP_REASON_SOCKET_BACKLOG ,/** @SKB_DROP_REASON_TCP_FLAGS: TCP flags invalid */ SKB_DROP_REASON_TCP_FLAGS , +/** @SKB_DROP_REASON_TCP_CONNREQNOTACCEPTABLE: con req not acceptable */ +SKB_DROP_REASON_TCP_CONNREQNOTACCEPTABLE , +/** @SKB_DROP_REASON_TCP_ABORTONDATA: abort on data */ +SKB_DROP_REASON_TCP_ABORTONDATA ,/** * @SKB_DROP_REASON_TCP_ZEROWINDOW: TCP receive window size is zero, * see LINUX_MIB_TCPZEROWINDOWDROP
include/net/tcp.h +3 -2
@@ -348,7 +348,8 @@ void tcp_wfree(struct sk_buff *skb);void tcp_write_timer_handler (struct sock *sk);void tcp_delack_timer_handler (struct sock *sk);int tcp_ioctl (struct sock *sk,int cmd,int *karg); -int tcp_rcv_state_process (struct sock *sk,struct sk_buff *skb); +int tcp_rcv_state_process (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *drop_reason);void tcp_rcv_established (struct sock *sk,struct sk_buff *skb);void tcp_rcv_space_adjust (struct sock *sk);int tcp_twsk_unique (struct sock *sk,struct sock *sktw,void *twp);
@@ -397,7 +398,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, struct request_sock *req, bool fastopen, bool *lost_race);int tcp_child_process (struct sock *parent,struct sock *child, -struct sk_buff *skb); +struct sk_buff *skb,enum skb_drop_reason *reason);void tcp_enter_loss (struct sock *sk);void tcp_cwnd_reduction (struct sock *sk,int newly_acked_sacked,int newly_lost,int flag);void tcp_clear_retrans (struct tcp_sock *tp);
net/ipv4/tcp_input.c +15 -4
@@ -6616,7 +6616,8 @@ static void tcp_rcv_synrecv_state_fastopen(struct sock *sk)* address independent. */ -int tcp_rcv_state_process (struct sock *sk,struct sk_buff *skb) +int tcp_rcv_state_process (struct sock *sk,struct sk_buff *skb, +enum skb_drop_reason *drop_reason) {struct tcp_sock *tp =tcp_sk (sk);struct inet_connection_sock *icsk =inet_csk (sk);
@@ -6632,8 +6633,10 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) goto discard;case TCP_LISTEN : -if (th->ack) +if (th->ack) { +SKB_DR_SET (*drop_reason,TCP_FLAGS );return 1 ; + }if (th->rst) {SKB_DR_SET (reason,TCP_RESET );
@@ -6653,8 +6656,10 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)local_bh_enable ();rcu_read_unlock (); -if (!acceptable) +if (!acceptable) { +SKB_DR_SET (*drop_reason,TCP_CONNREQNOTACCEPTABLE );return 1 ; + }consume_skb (skb);return 0 ; }
@@ -6704,8 +6709,11 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) FLAG_NO_CHALLENGE_ACK);if ((int )reason <=0 ) { -if (sk->sk_state ==TCP_SYN_RECV ) +if (sk->sk_state ==TCP_SYN_RECV ) { +if ((int )reason <0 ) + *drop_reason = -reason;return 1 ;/* send one RST */ + }/* accept old ack during closing */ if ((int )reason <0 ) {tcp_send_challenge_ack (sk);
@@ -6781,6 +6789,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)if (READ_ONCE (tp->linger2) <0 ) {tcp_done (sk);NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPABORTONDATA ); +SKB_DR_SET (*drop_reason,TCP_ABORTONDATA );return 1 ; } if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
@@ -6790,6 +6799,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb)tcp_fastopen_active_disable (sk);tcp_done (sk);NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPABORTONDATA ); +SKB_DR_SET (*drop_reason,TCP_ABORTONDATA );return 1 ; }
@@ -6855,6 +6865,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb) after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) {NET_INC_STATS (sock_net (sk),LINUX_MIB_TCPABORTONDATA );tcp_reset (sk, skb); +SKB_DR_SET (*drop_reason,TCP_ABORTONDATA );return 1 ; } }
net/ipv4/tcp_ipv4.c +3 -3
@@ -1918,7 +1918,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)if (!nsk) goto discard;if (nsk != sk) { -if (tcp_child_process (sk, nsk, skb)) { +if (tcp_child_process (sk, nsk, skb, &reason)) { rsk = nsk; goto reset; }
@@ -1927,7 +1927,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) }else sock_rps_save_rxhash (sk, skb); -if (tcp_rcv_state_process (sk, skb)) { +if (tcp_rcv_state_process (sk, skb, &reason)) { rsk = sk; goto reset; }
@@ -2276,7 +2276,7 @@ int tcp_v4_rcv(struct sk_buff *skb)if (nsk == sk) {reqsk_put (req);tcp_v4_restore_cb (skb); - }else if (tcp_child_process (sk, nsk, skb)) { + }else if (tcp_child_process (sk, nsk, skb, &drop_reason)) {tcp_v4_send_reset (nsk, skb); goto discard_and_relse; }else {
net/ipv4/tcp_minisocks.c +2 -2
@@ -912,7 +912,7 @@ EXPORT_SYMBOL(tcp_check_req);*/ int tcp_child_process (struct sock *parent,struct sock *child, -struct sk_buff *skb) +struct sk_buff *skb,enum skb_drop_reason *reason) __releases(&((child)->sk_lock.slock)) {int ret =0 ;
@@ -923,7 +923,7 @@ int tcp_child_process(struct sock *parent, struct sock *child,tcp_segs_in (tcp_sk (child), skb);if (!sock_owned_by_user (child)) { - ret =tcp_rcv_state_process (child, skb); + ret =tcp_rcv_state_process (child, skb, reason);/* Wakeup parent, send SIGIO */ if (state ==TCP_SYN_RECV && child->sk_state != state) parent->sk_data_ready (parent);
net/ipv6/tcp_ipv6.c +3 -3
@@ -1657,7 +1657,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) goto discard;if (nsk != sk) { -if (tcp_child_process (sk, nsk, skb)) +if (tcp_child_process (sk, nsk, skb, &reason)) goto reset;if (opt_skb)__kfree_skb (opt_skb);
@@ -1666,7 +1666,7 @@ int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb) }else sock_rps_save_rxhash (sk, skb); -if (tcp_rcv_state_process (sk, skb)) +if (tcp_rcv_state_process (sk, skb, &reason)) goto reset;if (opt_skb) goto ipv6_pktoptions;
@@ -1856,7 +1856,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)if (nsk == sk) {reqsk_put (req);tcp_v6_restore_cb (skb); - }else if (tcp_child_process (sk, nsk, skb)) { + }else if (tcp_child_process (sk, nsk, skb, &drop_reason)) {tcp_v6_send_reset (nsk, skb); goto discard_and_relse; }else {
Signature · 1 line
2.37.3
Quoted 6 lines · Jason Xing
From: Jason Xing <[email protected]>
When I was debugging the reason about why the skb should be dropped in syn cookie mode, I found out that this
NOT_SPECIFIEDreason is too general. Thus I decided to refine it.
Hello, any suggestions? Those names in the patchset could be improper, but I've already tried to name them in English :S
Thanks,
Jason
Quoted 17 lines
Jason Xing (2):
tcp: add more DROP REASONs in cookie check
tcp: add more DROP REASONS in child processinclude/net/dropreason-core.h | 18 ++++++++++++++++++ include/net/tcp.h | 8 +++++--- net/ipv4/syncookies.c | 18 ++++++++++++++---- net/ipv4/tcp_input.c | 19 +++++++++++++++---- net/ipv4/tcp_ipv4.c | 13 +++++++------ net/ipv4/tcp_minisocks.c | 4 ++-- net/ipv6/tcp_ipv6.c | 6 +++--- 7 files changed, 64 insertions(+), 22 deletions(-)--
2.37.3
Jakub Kicinski
maintainerQuoted 3 lines · On Sun, 4 Feb 2024 18:45:58 +0800 Jason Xing wrote:
When I was debugging the reason about why the skb should be dropped in syn cookie mode, I found out that this
NOT_SPECIFIEDreason is too general. Thus I decided to refine it.
Please run checkpatch --strict on the patches, post v2 with warnings fixed.
Quoted 12 lines · Jason Xing
Quoted 6 lines · Jason Xing
From: Jason Xing <[email protected]>
When I was debugging the reason about why the skb should be dropped in syn cookie mode, I found out that this
NOT_SPECIFIEDreason is too general. Thus I decided to refine it.Hello, any suggestions? Those names in the patchset could be improper, but I've already tried to name them in English :S
Adding &drop_reason parameters all over the places adds more code for CONFIG_STACKPROTECTOR=y builds,
because of added canary checks.
Please make sure not to slow down the TCP fast path, while we work hard in the opposite direction.
Also, sending patch series over weekends increases the chance for them being lost, just my personal opinion...
Quoted 20 lines
Thanks,
JasonQuoted 17 lines
Jason Xing (2):
tcp: add more DROP REASONs in cookie check
tcp: add more DROP REASONS in child processinclude/net/dropreason-core.h | 18 ++++++++++++++++++ include/net/tcp.h | 8 +++++--- net/ipv4/syncookies.c | 18 ++++++++++++++---- net/ipv4/tcp_input.c | 19 +++++++++++++++---- net/ipv4/tcp_ipv4.c | 13 +++++++------ net/ipv4/tcp_minisocks.c | 4 ++-- net/ipv6/tcp_ipv6.c | 6 +++--- 7 files changed, 64 insertions(+), 22 deletions(-)--
2.37.3
Quoted 8 lines · Jakub Kicinski
Quoted 3 lines · On Sun, 4 Feb 2024 18:45:58 +0800 Jason Xing wrote:
When I was debugging the reason about why the skb should be dropped in syn cookie mode, I found out that this
NOT_SPECIFIEDreason is too general. Thus I decided to refine it.Please run checkpatch --strict on the patches, post v2 with warnings fixed.
Thanks, I'll do that.
Quoted 11 lines · Eric Dumazet
Quoted 9 lines · Jason Xing
Quoted 6 lines · Jason Xing
From: Jason Xing <[email protected]>
When I was debugging the reason about why the skb should be dropped in syn cookie mode, I found out that this
NOT_SPECIFIEDreason is too general. Thus I decided to refine it.
Quoted 7 lines
Quoted 3 lines
Hello, any suggestions? Those names in the patchset could be improper, but I've already tried to name them in English :S
Adding
&drop_reasonparameters all over the places adds more code forCONFIG_STACKPROTECTOR=ybuilds,
because of added canary checks.
Indeed.
It took me some while to consider whether I should add more reasons into the fast path.
But for now the NOT_SPECIFIED fake reason does not work if we really want to know some useful hints.
What do you think? Should I give up this patch series or come up with other better ideas?
Quoted 3 lines
Please make sure not to slow down the TCP fast path, while we work hard in the opposite direction.
I tested some times by using netperf, it's not that easy to observe the obvious differences before/after this patch applied.
Quoted 3 lines
Also, sending patch series over weekends increases the chance for them being lost, just my personal opinion...
Oh, I see :S
Thanks,
Jason
Quoted 22 lines
Quoted 22 lines
Thanks,
JasonQuoted 17 lines
Jason Xing (2):
tcp: add more DROP REASONs in cookie check
tcp: add more DROP REASONS in child processinclude/net/dropreason-core.h | 18 ++++++++++++++++++ include/net/tcp.h | 8 +++++--- net/ipv4/syncookies.c | 18 ++++++++++++++---- net/ipv4/tcp_input.c | 19 +++++++++++++++---- net/ipv4/tcp_ipv4.c | 13 +++++++------ net/ipv4/tcp_minisocks.c | 4 ++-- net/ipv6/tcp_ipv6.c | 6 +++--- 7 files changed, 64 insertions(+), 22 deletions(-)--
2.37.3
Quoted 11 lines · Jason Xing
Indeed.
It took me some while to consider whether I should add more reasons into the fast path.
But for now the
NOT_SPECIFIEDfake reason does not work if we really want to know some useful hints.
What do you think? Should I give up this patch series or come up with other better ideas?
Perhaps find a way to reuse return values from functions to carry a drop_reason.
Quoted 7 lines
Quoted 4 lines
Please make sure not to slow down the TCP fast path, while we work hard in the opposite direction.
I tested some times by using netperf, it's not that easy to observe the obvious differences before/after this patch applied.
Sure, the difference is only noticeable on moderate load, when a cpu receives one packet in a while.
icache pressure, something hard to measure with synthetic benchmarks, but visible in real workloads in the long term.
At Google, we definitely see an increase of network cpu costs releases after releases.
Quoted 9 lines · Eric Dumazet
Quoted 7 lines · Jason Xing
Indeed.
It took me some while to consider whether I should add more reasons into the fast path.
Quoted 6 lines
Quoted 4 lines
But for now the
NOT_SPECIFIEDfake reason does not work if we really want to know some useful hints.
What do you think? Should I give up this patch series or come up with other better ideas?Perhaps find a way to reuse return values from functions to carry a
drop_reason.
It seems feasible to reuse return values, let me work on it :)
Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Please make sure not to slow down the TCP fast path, while we work hard in the opposite direction.
I tested some times by using netperf, it's not that easy to observe the obvious differences before/after this patch applied.
Quoted 8 lines
Sure, the difference is only noticeable on moderate load, when a cpu receives one packet in a while.
icache pressure, something hard to measure with synthetic benchmarks, but visible in real workloads in the long term.
At Google, we definitely see an increase of network cpu costs releases after releases.
Thanks for your explanations.
Thanks,
Jason