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

Commit 6d6ee43e authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo Committed by David S. Miller
Browse files

[TWSK]: Introduce struct timewait_sock_ops



So that we can share several timewait sockets related functions and
make the timewait mini sockets infrastructure closer to the request
mini sockets one.

Next changesets will take advantage of this, moving more code out of
TCP and DCCP v4 and v6 to common infrastructure.

Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fc44b980
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -360,7 +360,8 @@ struct tcp6_timewait_sock {


static inline u16 inet6_tw_offset(const struct proto *prot)
static inline u16 inet6_tw_offset(const struct proto *prot)
{
{
	return prot->twsk_obj_size - sizeof(struct inet6_timewait_sock);
	return prot->twsk_prot->twsk_obj_size -
			sizeof(struct inet6_timewait_sock);
}
}


static inline struct inet6_timewait_sock *inet6_twsk(const struct sock *sk)
static inline struct inet6_timewait_sock *inet6_twsk(const struct sock *sk)
+2 −1
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@


#include <net/sock.h>
#include <net/sock.h>
#include <net/tcp_states.h>
#include <net/tcp_states.h>
#include <net/timewait_sock.h>


#include <asm/atomic.h>
#include <asm/atomic.h>


@@ -200,7 +201,7 @@ static inline void inet_twsk_put(struct inet_timewait_sock *tw)
		printk(KERN_DEBUG "%s timewait_sock %p released\n",
		printk(KERN_DEBUG "%s timewait_sock %p released\n",
		       tw->tw_prot->name, tw);
		       tw->tw_prot->name, tw);
#endif
#endif
		kmem_cache_free(tw->tw_prot->twsk_slab, tw);
		kmem_cache_free(tw->tw_prot->twsk_prot->twsk_slab, tw);
		module_put(owner);
		module_put(owner);
	}
	}
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -493,6 +493,7 @@ extern void sk_stream_kill_queues(struct sock *sk);
extern int sk_wait_data(struct sock *sk, long *timeo);
extern int sk_wait_data(struct sock *sk, long *timeo);


struct request_sock_ops;
struct request_sock_ops;
struct timewait_sock_ops;


/* Networking protocol blocks we attach to sockets.
/* Networking protocol blocks we attach to sockets.
 * socket layer -> transport layer interface
 * socket layer -> transport layer interface
@@ -557,11 +558,10 @@ struct proto {
	kmem_cache_t		*slab;
	kmem_cache_t		*slab;
	unsigned int		obj_size;
	unsigned int		obj_size;


	kmem_cache_t		*twsk_slab;
	unsigned int		twsk_obj_size;
	atomic_t		*orphan_count;
	atomic_t		*orphan_count;


	struct request_sock_ops	*rsk_prot;
	struct request_sock_ops	*rsk_prot;
	struct timewait_sock_ops *twsk_prot;


	struct module		*owner;
	struct module		*owner;


+3 −0
Original line number Original line Diff line number Diff line
@@ -287,6 +287,9 @@ extern int tcp_rcv_established(struct sock *sk,


extern void			tcp_rcv_space_adjust(struct sock *sk);
extern void			tcp_rcv_space_adjust(struct sock *sk);


extern int			tcp_twsk_unique(struct sock *sk,
						struct sock *sktw, void *twp);

static inline void tcp_dec_quickack_mode(struct sock *sk,
static inline void tcp_dec_quickack_mode(struct sock *sk,
					 const unsigned int pkts)
					 const unsigned int pkts)
{
{
+31 −0
Original line number Original line Diff line number Diff line
/*
 * NET		Generic infrastructure for Network protocols.
 *
 * Authors:	Arnaldo Carvalho de Melo <acme@conectiva.com.br>
 *
 *		This program is free software; you can redistribute it and/or
 *		modify it under the terms of the GNU General Public License
 *		as published by the Free Software Foundation; either version
 *		2 of the License, or (at your option) any later version.
 */
#ifndef _TIMEWAIT_SOCK_H
#define _TIMEWAIT_SOCK_H

#include <linux/slab.h>
#include <net/sock.h>

struct timewait_sock_ops {
	kmem_cache_t	*twsk_slab;
	unsigned int	twsk_obj_size;
	int		(*twsk_unique)(struct sock *sk,
				       struct sock *sktw, void *twp);
};

static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp)
{
	if (sk->sk_prot->twsk_prot->twsk_unique != NULL)
		return sk->sk_prot->twsk_prot->twsk_unique(sk, sktw, twp);
	return 0;
}

#endif /* _TIMEWAIT_SOCK_H */
Loading