mirror of
https://github.com/torvalds/linux.git
synced 2026-05-12 16:18:45 +02:00
tcp: return a drop_reason from tcp_add_backlog()
Part of a stack canary removal from tcp_v{4,6}_rcv().
Return a drop_reason instead of a boolean, so that we no longer
have to pass the address of a local variable.
$ scripts/bloat-o-meter -t vmlinux.old vmlinux.new
add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-37 (-37)
Function old new delta
tcp_v6_rcv 3133 3129 -4
tcp_v4_rcv 3206 3202 -4
tcp_add_backlog 1281 1252 -29
Total: Before=25567186, After=25567149, chg -0.00%
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260409101147.1642967-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
4431c239a3
commit
f5148298b0
|
|
@ -1680,8 +1680,7 @@ static inline bool tcp_checksum_complete(struct sk_buff *skb)
|
|||
__skb_checksum_complete(skb);
|
||||
}
|
||||
|
||||
bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
|
||||
enum skb_drop_reason *reason);
|
||||
enum skb_drop_reason tcp_add_backlog(struct sock *sk, struct sk_buff *skb);
|
||||
|
||||
static inline int tcp_filter(struct sock *sk, struct sk_buff *skb,
|
||||
enum skb_drop_reason *reason)
|
||||
|
|
|
|||
|
|
@ -1900,8 +1900,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
|
|||
}
|
||||
EXPORT_SYMBOL(tcp_v4_do_rcv);
|
||||
|
||||
bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
|
||||
enum skb_drop_reason *reason)
|
||||
enum skb_drop_reason tcp_add_backlog(struct sock *sk, struct sk_buff *skb)
|
||||
{
|
||||
u32 tail_gso_size, tail_gso_segs;
|
||||
struct skb_shared_info *shinfo;
|
||||
|
|
@ -1929,10 +1928,9 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
|
|||
if (unlikely(tcp_checksum_complete(skb))) {
|
||||
bh_unlock_sock(sk);
|
||||
trace_tcp_bad_csum(skb);
|
||||
*reason = SKB_DROP_REASON_TCP_CSUM;
|
||||
__TCP_INC_STATS(sock_net(sk), TCP_MIB_CSUMERRORS);
|
||||
__TCP_INC_STATS(sock_net(sk), TCP_MIB_INERRS);
|
||||
return true;
|
||||
return SKB_DROP_REASON_TCP_CSUM;
|
||||
}
|
||||
|
||||
/* Attempt coalescing to last skb in backlog, even if we are
|
||||
|
|
@ -2006,7 +2004,7 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
|
|||
__NET_INC_STATS(sock_net(sk),
|
||||
LINUX_MIB_TCPBACKLOGCOALESCE);
|
||||
kfree_skb_partial(skb, fragstolen);
|
||||
return false;
|
||||
return SKB_NOT_DROPPED_YET;
|
||||
}
|
||||
__skb_push(skb, hdrlen);
|
||||
|
||||
|
|
@ -2031,15 +2029,13 @@ bool tcp_add_backlog(struct sock *sk, struct sk_buff *skb,
|
|||
if (unlikely(err)) {
|
||||
bh_unlock_sock(sk);
|
||||
if (err == -ENOMEM) {
|
||||
*reason = SKB_DROP_REASON_PFMEMALLOC;
|
||||
__NET_INC_STATS(sock_net(sk), LINUX_MIB_PFMEMALLOCDROP);
|
||||
} else {
|
||||
*reason = SKB_DROP_REASON_SOCKET_BACKLOG;
|
||||
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP);
|
||||
return SKB_DROP_REASON_PFMEMALLOC;
|
||||
}
|
||||
return true;
|
||||
__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPBACKLOGDROP);
|
||||
return SKB_DROP_REASON_SOCKET_BACKLOG;
|
||||
}
|
||||
return false;
|
||||
return SKB_NOT_DROPPED_YET;
|
||||
}
|
||||
|
||||
static void tcp_v4_restore_cb(struct sk_buff *skb)
|
||||
|
|
@ -2247,7 +2243,8 @@ int tcp_v4_rcv(struct sk_buff *skb)
|
|||
if (!sock_owned_by_user(sk)) {
|
||||
ret = tcp_v4_do_rcv(sk, skb);
|
||||
} else {
|
||||
if (tcp_add_backlog(sk, skb, &drop_reason))
|
||||
drop_reason = tcp_add_backlog(sk, skb);
|
||||
if (drop_reason)
|
||||
goto discard_and_relse;
|
||||
}
|
||||
bh_unlock_sock(sk);
|
||||
|
|
|
|||
|
|
@ -1877,7 +1877,8 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
|
|||
if (!sock_owned_by_user(sk)) {
|
||||
ret = tcp_v6_do_rcv(sk, skb);
|
||||
} else {
|
||||
if (tcp_add_backlog(sk, skb, &drop_reason))
|
||||
drop_reason = tcp_add_backlog(sk, skb);
|
||||
if (drop_reason)
|
||||
goto discard_and_relse;
|
||||
}
|
||||
bh_unlock_sock(sk);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user