Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78217
b: refs/heads/master
c: f561d0f
h: refs/heads/master
i:
  78215: 7f12b26
v: v3
  • Loading branch information
Pavel Emelyanov authored and David S. Miller committed Jan 28, 2008
1 parent c5741b3 commit 618b32c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3015a347dcd470fcc8becf1f84b0502391a3c0e0
refs/heads/master: f561d0f27d6283c49359bb96048f8ac3728c812c
29 changes: 2 additions & 27 deletions trunk/include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
27 changes: 27 additions & 0 deletions trunk/net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 618b32c

Please sign in to comment.