Commit 7fa9446b authored by Vikram Narayanan's avatar Vikram Narayanan

tcp: Support priv_alloc for tcp packets

If enabled, allocate skb's for TCP packets from our private pool.
Signed-off-by: Vikram Narayanan's avatarVikram Narayanan <vikram186@gmail.com>
parent 3795fb03
......@@ -806,6 +806,7 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
bool force_schedule)
{
struct sk_buff *skb;
unsigned alloc_sz;
/* The TCP header must be at least 32-bit aligned. */
size = ALIGN(size, 4);
......@@ -813,7 +814,15 @@ struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp,
if (unlikely(tcp_under_memory_pressure(sk)))
sk_mem_reclaim_partial(sk);
skb = alloc_skb_fclone(size + sk->sk_prot->max_header, gfp);
if (sk->sk_dst_cache && sk->sk_dst_cache->dev &&
(sk->sk_dst_cache->dev->features &
NETIF_F_PRIV_DATA_POOL))
alloc_sz = (size + sk->sk_prot->max_header)
| SKB_DATA_PRIV_POOL;
else
alloc_sz = size + sk->sk_prot->max_header;
skb = alloc_skb_fclone(alloc_sz, gfp);
if (likely(skb)) {
bool mem_scheduled;
......
......@@ -2895,7 +2895,13 @@ coalesce:
return;
}
} else {
skb = alloc_skb_fclone(MAX_TCP_HEADER, sk->sk_allocation);
u32 size = MAX_TCP_HEADER;
if (sk->sk_dst_cache && sk->sk_dst_cache->dev &&
(sk->sk_dst_cache->dev->features & NETIF_F_PRIV_DATA_POOL))
size |= SKB_DATA_PRIV_POOL;
skb = alloc_skb_fclone(size, sk->sk_allocation);
if (unlikely(!skb)) {
if (tskb)
goto coalesce;
......@@ -3394,6 +3400,7 @@ void tcp_send_delayed_ack(struct sock *sk)
void tcp_send_ack(struct sock *sk)
{
struct sk_buff *buff;
unsigned size;
/* If we have been reset, we may not send again. */
if (sk->sk_state == TCP_CLOSE)
......@@ -3405,7 +3412,13 @@ void tcp_send_ack(struct sock *sk)
* tcp_transmit_skb() will set the ownership to this
* sock.
*/
buff = alloc_skb(MAX_TCP_HEADER,
size = MAX_TCP_HEADER;
if (sk->sk_dst_cache && sk->sk_dst_cache->dev &&
(sk->sk_dst_cache->dev->features &
NETIF_F_PRIV_DATA_POOL))
size |= SKB_DATA_PRIV_POOL;
buff = alloc_skb(size,
sk_gfp_mask(sk, GFP_ATOMIC | __GFP_NOWARN));
if (unlikely(!buff)) {
inet_csk_schedule_ack(sk);
......
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