Commit b7155403 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by Arnaldo Carvalho de Melo

[NET] generalise tcp_eat_skb into sk_eat_skb

It was already generic, so reflect this in the naming.

Later patches will make it be used in other network families.
parent 8bb48a17
...@@ -1040,6 +1040,20 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) ...@@ -1040,6 +1040,20 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
sk->sk_stamp = *stamp; sk->sk_stamp = *stamp;
} }
/**
* sk_eat_skb - Release a skb if it is no longer needed
* @sk - socket to eat this skb from
* @skb - socket buffer to eat
*
* This routine must be called with interrupts disabled or with the socket
* locked so that the sk_buff queue operation is ok.
*/
static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb)
{
__skb_unlink(skb, &sk->sk_receive_queue);
__kfree_skb(skb);
}
extern atomic_t netstamp_needed; extern atomic_t netstamp_needed;
extern void sock_enable_timestamp(struct sock *sk); extern void sock_enable_timestamp(struct sock *sk);
extern void sock_disable_timestamp(struct sock *sk); extern void sock_disable_timestamp(struct sock *sk);
......
...@@ -1296,18 +1296,6 @@ static int tcp_recv_urg(struct sock *sk, long timeo, ...@@ -1296,18 +1296,6 @@ static int tcp_recv_urg(struct sock *sk, long timeo,
return -EAGAIN; return -EAGAIN;
} }
/*
* Release a skb if it is no longer needed. This routine
* must be called with interrupts disabled or with the
* socket locked so that the sk_buff queue operation is ok.
*/
static inline void tcp_eat_skb(struct sock *sk, struct sk_buff *skb)
{
__skb_unlink(skb, &sk->sk_receive_queue);
__kfree_skb(skb);
}
/* Clean up the receive buffer for full frames taken by the user, /* Clean up the receive buffer for full frames taken by the user,
* then send an ACK if necessary. COPIED is the number of bytes * then send an ACK if necessary. COPIED is the number of bytes
* tcp_recvmsg has given to the user so far, it speeds up the * tcp_recvmsg has given to the user so far, it speeds up the
...@@ -1473,11 +1461,11 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, ...@@ -1473,11 +1461,11 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
break; break;
} }
if (skb->h.th->fin) { if (skb->h.th->fin) {
tcp_eat_skb(sk, skb); sk_eat_skb(sk, skb);
++seq; ++seq;
break; break;
} }
tcp_eat_skb(sk, skb); sk_eat_skb(sk, skb);
if (!desc->count) if (!desc->count)
break; break;
} }
...@@ -1758,14 +1746,14 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, ...@@ -1758,14 +1746,14 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
if (skb->h.th->fin) if (skb->h.th->fin)
goto found_fin_ok; goto found_fin_ok;
if (!(flags & MSG_PEEK)) if (!(flags & MSG_PEEK))
tcp_eat_skb(sk, skb); sk_eat_skb(sk, skb);
continue; continue;
found_fin_ok: found_fin_ok:
/* Process the FIN. */ /* Process the FIN. */
++*seq; ++*seq;
if (!(flags & MSG_PEEK)) if (!(flags & MSG_PEEK))
tcp_eat_skb(sk, skb); sk_eat_skb(sk, skb);
break; break;
} while (len > 0); } while (len > 0);
......
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