[NET] generalise tcp_free_skb, renaming it to sk_stream_free_skb

Will be used by the poor cousins
Signed-of-by: default avatarArnaldo Carvalho de Melo <acme@conectiva.com.br>
parent 217a7b20
......@@ -262,8 +262,8 @@ struct tcp_opt {
__u32 frto_highmark; /* snd_nxt when RTO occurred */
__u8 unused_pad;
__u8 queue_shrunk; /* Write queue has been shrunk recently.*/
__u8 defer_accept; /* User waits for some data after accept() */
/* one byte hole, try to pack */
/* RTT measurement */
__u8 backoff; /* backoff */
......
......@@ -168,6 +168,7 @@ struct sock_common {
* @sk_user_data - RPC layer private data
* @sk_owner - module that owns this socket
* @sk_write_pending - a write to stream socket waits to start
* @sk_queue_shrunk - write queue has been shrunk recently
* @sk_state_change - callback to indicate change in the state of the sock
* @sk_data_ready - callback to indicate there is data to be processed
* @sk_write_space - callback to indicate there is bf sending space available
......@@ -250,6 +251,8 @@ struct sock {
struct module *sk_owner;
int sk_write_pending;
void *sk_security;
__u8 sk_queue_shrunk;
/* three bytes hole, try to pack */
void (*sk_state_change)(struct sock *sk);
void (*sk_data_ready)(struct sock *sk, int bytes);
void (*sk_write_space)(struct sock *sk);
......@@ -446,6 +449,14 @@ static inline void sk_stream_set_owner_r(struct sk_buff *skb, struct sock *sk)
sk->sk_forward_alloc -= skb->truesize;
}
static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb)
{
sk->sk_queue_shrunk = 1;
sk->sk_wmem_queued -= skb->truesize;
sk->sk_forward_alloc += skb->truesize;
__kfree_skb(skb);
}
/* The per-socket spinlock must be held here. */
#define sk_add_backlog(__sk, __skb) \
do { if (!(__sk)->sk_backlog.tail) { \
......
......@@ -1876,14 +1876,6 @@ static __inline__ void tcp_openreq_init(struct open_request *req,
#define TCP_MEM_QUANTUM ((int)PAGE_SIZE)
static inline void tcp_free_skb(struct sock *sk, struct sk_buff *skb)
{
tcp_sk(sk)->queue_shrunk = 1;
sk->sk_wmem_queued -= skb->truesize;
sk->sk_forward_alloc += skb->truesize;
__kfree_skb(skb);
}
extern void __tcp_mem_reclaim(struct sock *sk);
extern int tcp_mem_schedule(struct sock *sk, int size, int kind);
......@@ -1951,7 +1943,7 @@ static inline void tcp_writequeue_purge(struct sock *sk)
struct sk_buff *skb;
while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL)
tcp_free_skb(sk, skb);
sk_stream_free_skb(sk, skb);
tcp_mem_reclaim(sk);
}
......
......@@ -1038,7 +1038,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if (tp->send_head == skb)
tp->send_head = NULL;
__skb_unlink(skb, skb->list);
tcp_free_skb(sk, skb);
sk_stream_free_skb(sk, skb);
}
do_error:
......
......@@ -2368,7 +2368,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
tp->fackets_out--;
tp->packets_out--;
__skb_unlink(skb, skb->list);
tcp_free_skb(sk, skb);
sk_stream_free_skb(sk, skb);
}
if (acked&FLAG_ACKED) {
......@@ -3829,7 +3829,7 @@ void tcp_cwnd_application_limited(struct sock *sk)
/* When incoming ACK allowed to free some skb from write_queue,
* we remember this event in flag tp->queue_shrunk and wake up socket
* we remember this event in flag sk->sk_queue_shrunk and wake up socket
* on the exit from tcp input handler.
*
* PROBLEM: sndbuf expansion does not work well with largesend.
......@@ -3857,10 +3857,8 @@ static void tcp_new_space(struct sock *sk)
static inline void tcp_check_space(struct sock *sk)
{
struct tcp_opt *tp = tcp_sk(sk);
if (tp->queue_shrunk) {
tp->queue_shrunk = 0;
if (sk->sk_queue_shrunk) {
sk->sk_queue_shrunk = 0;
if (sk->sk_socket &&
test_bit(SOCK_NOSPACE, &sk->sk_socket->flags))
tcp_new_space(sk);
......
......@@ -763,7 +763,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
*/
if (tp->fackets_out)
tp->fackets_out--;
tcp_free_skb(sk, next_skb);
sk_stream_free_skb(sk, next_skb);
tp->packets_out--;
}
}
......@@ -1104,7 +1104,7 @@ int tcp_send_synack(struct sock *sk)
return -ENOMEM;
__skb_unlink(skb, &sk->sk_write_queue);
__skb_queue_head(&sk->sk_write_queue, nskb);
tcp_free_skb(sk, skb);
sk_stream_free_skb(sk, skb);
sk_charge_skb(sk, nskb);
skb = nskb;
}
......
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