Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b35f504a authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'listener_refactor'



Eric Dumazet says:

====================
inet: tcp listener refactoring, part 10

We are getting close to the point where request sockets will be hashed
into generic hash table. Some followups are needed for netfilter and
will be handled in next patch series.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents f00bbd21 13854e5a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -275,6 +275,11 @@ static inline void inet_csk_reqsk_queue_add(struct sock *sk,
					    struct sock *child)
{
	reqsk_queue_add(&inet_csk(sk)->icsk_accept_queue, req, sk, child);
	/* before letting lookups find us, make sure all req fields
	 * are committed to memory.
	 */
	smp_wmb();
	atomic_set(&req->rsk_refcnt, 1);
}

void inet_csk_reqsk_queue_hash_add(struct sock *sk, struct request_sock *req,
+5 −0
Original line number Diff line number Diff line
@@ -255,6 +255,11 @@ static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops
		ireq->opt = NULL;
		atomic64_set(&ireq->ir_cookie, 0);
		ireq->ireq_state = TCP_NEW_SYN_RECV;

		/* Following is temporary. It is coupled with debugging
		 * helpers in reqsk_put() & reqsk_free()
		 */
		atomic_set(&ireq->ireq_refcnt, 0);
	}

	return req;
+7 −6
Original line number Diff line number Diff line
@@ -82,19 +82,20 @@ static inline struct request_sock *inet_reqsk(struct sock *sk)
	return (struct request_sock *)sk;
}

static inline void __reqsk_free(struct request_sock *req)
{
	kmem_cache_free(req->rsk_ops->slab, req);
}

static inline void reqsk_free(struct request_sock *req)
{
	/* temporary debugging */
	WARN_ON_ONCE(atomic_read(&req->rsk_refcnt) != 0);

	req->rsk_ops->destructor(req);
	__reqsk_free(req);
	kmem_cache_free(req->rsk_ops->slab, req);
}

static inline void reqsk_put(struct request_sock *req)
{
	/* temporary debugging, until req sock are put into ehash table */
	WARN_ON_ONCE(atomic_read(&req->rsk_refcnt) != 1);

	if (atomic_dec_and_test(&req->rsk_refcnt))
		reqsk_free(req);
}
+9 −0
Original line number Diff line number Diff line
@@ -67,6 +67,7 @@
#include <linux/atomic.h>
#include <net/dst.h>
#include <net/checksum.h>
#include <net/tcp_states.h>
#include <linux/net_tstamp.h>

struct cgroup;
@@ -2218,6 +2219,14 @@ static inline struct sock *skb_steal_sock(struct sk_buff *skb)
	return NULL;
}

/* This helper checks if a socket is a full socket,
 * ie _not_ a timewait or request socket.
 */
static inline bool sk_fullsock(const struct sock *sk)
{
	return (1 << sk->sk_state) & ~(TCPF_TIME_WAIT | TCPF_NEW_SYN_RECV);
}

void sock_enable_timestamp(struct sock *sk, int flag);
int sock_get_timestamp(struct sock *, struct timeval __user *);
int sock_get_timestampns(struct sock *, struct timespec __user *);
+2 −2
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@ void reqsk_queue_destroy(struct request_sock_queue *queue)
			while ((req = lopt->syn_table[i]) != NULL) {
				lopt->syn_table[i] = req->dl_next;
				lopt->qlen--;
				reqsk_free(req);
				reqsk_put(req);
			}
		}
	}
@@ -180,7 +180,7 @@ void reqsk_fastopen_remove(struct sock *sk, struct request_sock *req,
		 */
		spin_unlock_bh(&fastopenq->lock);
		sock_put(lsk);
		reqsk_free(req);
		reqsk_put(req);
		return;
	}
	/* Wait for 60secs before removing a req that has triggered RST.
Loading