diff --git a/include/net/sock.h b/include/net/sock.h index e329d05f79953a2cdc731c6a6a7a1a643eb44183..7d500a825e4ebd331c1dd45c8e239471d2d0b5db 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -1192,33 +1192,8 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk) } } -static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, - int size, int mem, - gfp_t gfp) -{ - struct sk_buff *skb; - - /* The TCP header must be at least 32-bit aligned. */ - size = ALIGN(size, 4); - - skb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp); - if (skb) { - skb->truesize += mem; - if (sk_stream_wmem_schedule(sk, skb->truesize)) { - /* - * Make sure that we have exactly size bytes - * available to the caller, no more, no less. - */ - skb_reserve(skb, skb_tailroom(skb) - size); - return skb; - } - __kfree_skb(skb); - } else { - sk->sk_prot->enter_memory_pressure(); - sk_stream_moderate_sndbuf(sk); - } - return NULL; -} +struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, + int size, int mem, gfp_t gfp); static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index e055f25876dfae248e0b84c6d64c44357fb21382..6b35ab841db2a5523a9e76af0817101b491913b5 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -629,6 +629,33 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos, return ret; } +struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, + int size, int mem, gfp_t gfp) +{ + struct sk_buff *skb; + + /* The TCP header must be at least 32-bit aligned. */ + size = ALIGN(size, 4); + + skb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp); + if (skb) { + skb->truesize += mem; + if (sk_stream_wmem_schedule(sk, skb->truesize)) { + /* + * Make sure that we have exactly size bytes + * available to the caller, no more, no less. + */ + skb_reserve(skb, skb_tailroom(skb) - size); + return skb; + } + __kfree_skb(skb); + } else { + sk->sk_prot->enter_memory_pressure(); + sk_stream_moderate_sndbuf(sk); + } + return NULL; +} + static ssize_t do_tcp_sendpages(struct sock *sk, struct page **pages, int poffset, size_t psize, int flags) {