diff options
Diffstat (limited to 'include/net/sock.h')
-rw-r--r-- | include/net/sock.h | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/include/net/sock.h b/include/net/sock.h index d0b5fdee50a2..b9f2b095b1ab 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -746,11 +746,6 @@ static inline int sk_stream_wspace(const struct sock *sk) | |||
746 | 746 | ||
747 | extern void sk_stream_write_space(struct sock *sk); | 747 | extern void sk_stream_write_space(struct sock *sk); |
748 | 748 | ||
749 | static inline bool sk_stream_memory_free(const struct sock *sk) | ||
750 | { | ||
751 | return sk->sk_wmem_queued < sk->sk_sndbuf; | ||
752 | } | ||
753 | |||
754 | /* OOB backlog add */ | 749 | /* OOB backlog add */ |
755 | static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb) | 750 | static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb) |
756 | { | 751 | { |
@@ -950,6 +945,7 @@ struct proto { | |||
950 | unsigned int inuse_idx; | 945 | unsigned int inuse_idx; |
951 | #endif | 946 | #endif |
952 | 947 | ||
948 | bool (*stream_memory_free)(const struct sock *sk); | ||
953 | /* Memory pressure */ | 949 | /* Memory pressure */ |
954 | void (*enter_memory_pressure)(struct sock *sk); | 950 | void (*enter_memory_pressure)(struct sock *sk); |
955 | atomic_long_t *memory_allocated; /* Current allocated memory. */ | 951 | atomic_long_t *memory_allocated; /* Current allocated memory. */ |
@@ -1088,11 +1084,22 @@ static inline struct cg_proto *parent_cg_proto(struct proto *proto, | |||
1088 | } | 1084 | } |
1089 | #endif | 1085 | #endif |
1090 | 1086 | ||
1087 | static inline bool sk_stream_memory_free(const struct sock *sk) | ||
1088 | { | ||
1089 | if (sk->sk_wmem_queued >= sk->sk_sndbuf) | ||
1090 | return false; | ||
1091 | |||
1092 | return sk->sk_prot->stream_memory_free ? | ||
1093 | sk->sk_prot->stream_memory_free(sk) : true; | ||
1094 | } | ||
1095 | |||
1091 | static inline bool sk_stream_is_writeable(const struct sock *sk) | 1096 | static inline bool sk_stream_is_writeable(const struct sock *sk) |
1092 | { | 1097 | { |
1093 | return sk_stream_wspace(sk) >= sk_stream_min_wspace(sk); | 1098 | return sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) && |
1099 | sk_stream_memory_free(sk); | ||
1094 | } | 1100 | } |
1095 | 1101 | ||
1102 | |||
1096 | static inline bool sk_has_memory_pressure(const struct sock *sk) | 1103 | static inline bool sk_has_memory_pressure(const struct sock *sk) |
1097 | { | 1104 | { |
1098 | return sk->sk_prot->memory_pressure != NULL; | 1105 | return sk->sk_prot->memory_pressure != NULL; |