aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2015-10-02 11:43:23 -0700
committerDavid S. Miller <davem@davemloft.net>2015-10-03 04:32:36 -0700
commitfff1f3001cc58b5064a0f1154a7ac09b76f29c44 (patch)
tree910fe6f27dc9b9b7c6a0a56a9442ee264c9a6667 /include
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (diff)
downloadlinux-dev-fff1f3001cc58b5064a0f1154a7ac09b76f29c44.tar.xz
linux-dev-fff1f3001cc58b5064a0f1154a7ac09b76f29c44.zip
tcp: add a spinlock to protect struct request_sock_queue
struct request_sock_queue fields are currently protected by the listener 'lock' (not a real spinlock) We need to add a private spinlock instead, so that softirq handlers creating children do not have to worry with backlog notion that the listener 'lock' carries. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/request_sock.h37
1 files changed, 18 insertions, 19 deletions
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index d2544de329bd..202e36163ae3 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -176,9 +176,11 @@ struct fastopen_queue {
*
*/
struct request_sock_queue {
+ spinlock_t rskq_lock;
+ u8 rskq_defer_accept;
+
struct request_sock *rskq_accept_head;
struct request_sock *rskq_accept_tail;
- u8 rskq_defer_accept;
struct listen_sock *listen_opt;
struct fastopen_queue fastopenq; /* Check max_qlen != 0 to determine
* if TFO is enabled.
@@ -196,16 +198,7 @@ void reqsk_queue_destroy(struct request_sock_queue *queue);
void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req,
bool reset);
-static inline struct request_sock *
- reqsk_queue_yank_acceptq(struct request_sock_queue *queue)
-{
- struct request_sock *req = queue->rskq_accept_head;
-
- queue->rskq_accept_head = NULL;
- return req;
-}
-
-static inline int reqsk_queue_empty(struct request_sock_queue *queue)
+static inline bool reqsk_queue_empty(const struct request_sock_queue *queue)
{
return queue->rskq_accept_head == NULL;
}
@@ -215,6 +208,7 @@ static inline void reqsk_queue_add(struct request_sock_queue *queue,
struct sock *parent,
struct sock *child)
{
+ spin_lock(&queue->rskq_lock);
req->sk = child;
sk_acceptq_added(parent);
@@ -225,18 +219,23 @@ static inline void reqsk_queue_add(struct request_sock_queue *queue,
queue->rskq_accept_tail = req;
req->dl_next = NULL;
+ spin_unlock(&queue->rskq_lock);
}
-static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue *queue)
+static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue *queue,
+ struct sock *parent)
{
- struct request_sock *req = queue->rskq_accept_head;
-
- WARN_ON(req == NULL);
-
- queue->rskq_accept_head = req->dl_next;
- if (queue->rskq_accept_head == NULL)
- queue->rskq_accept_tail = NULL;
+ struct request_sock *req;
+ spin_lock_bh(&queue->rskq_lock);
+ req = queue->rskq_accept_head;
+ if (req) {
+ sk_acceptq_removed(parent);
+ queue->rskq_accept_head = req->dl_next;
+ if (queue->rskq_accept_head == NULL)
+ queue->rskq_accept_tail = NULL;
+ }
+ spin_unlock_bh(&queue->rskq_lock);
return req;
}