Commit dda4d96a authored by Eric Dumazet's avatar Eric Dumazet Committed by Jakub Kicinski

tcp: move tcp_out_of_memory() to net/ipv4/tcp.c

tcp_out_of_memory() has a single caller: tcp_check_oom().

Following patch will also make sk_memory_allocated()
not anymore visible from <net/sock.h> and <net/tcp.h>

Add const qualifier to sock argument of tcp_out_of_memory()
and tcp_check_oom().
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240429134025.1233626-4-edumazet@google.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d480dc76
...@@ -296,14 +296,6 @@ static inline bool between(__u32 seq1, __u32 seq2, __u32 seq3) ...@@ -296,14 +296,6 @@ static inline bool between(__u32 seq1, __u32 seq2, __u32 seq3)
return seq3 - seq2 >= seq1 - seq2; return seq3 - seq2 >= seq1 - seq2;
} }
static inline bool tcp_out_of_memory(struct sock *sk)
{
if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2))
return true;
return false;
}
static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb) static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
{ {
sk_wmem_queued_add(sk, -skb->truesize); sk_wmem_queued_add(sk, -skb->truesize);
...@@ -316,7 +308,7 @@ static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb) ...@@ -316,7 +308,7 @@ static inline void tcp_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
void sk_forced_mem_schedule(struct sock *sk, int size); void sk_forced_mem_schedule(struct sock *sk, int size);
bool tcp_check_oom(struct sock *sk, int shift); bool tcp_check_oom(const struct sock *sk, int shift);
extern struct proto tcp_prot; extern struct proto tcp_prot;
......
...@@ -2752,7 +2752,15 @@ static bool tcp_too_many_orphans(int shift) ...@@ -2752,7 +2752,15 @@ static bool tcp_too_many_orphans(int shift)
READ_ONCE(sysctl_tcp_max_orphans); READ_ONCE(sysctl_tcp_max_orphans);
} }
bool tcp_check_oom(struct sock *sk, int shift) static bool tcp_out_of_memory(const struct sock *sk)
{
if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF &&
sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2))
return true;
return false;
}
bool tcp_check_oom(const struct sock *sk, int shift)
{ {
bool too_many_orphans, out_of_socket_memory; bool too_many_orphans, out_of_socket_memory;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment