Skip to content

Commit

Permalink
[NET]: Introduce inet_connection_sock
Browse files Browse the repository at this point in the history
This creates struct inet_connection_sock, moving members out of struct
tcp_sock that are shareable with other INET connection oriented
protocols, such as DCCP, that in my private tree already uses most of
these members.

The functions that operate on these members were renamed, using a
inet_csk_ prefix while not being moved yet to a new file, so as to
ease the review of these changes.

Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Arnaldo Carvalho de Melo authored and David S. Miller committed Aug 29, 2005
1 parent 87d11ce commit 463c84b
Show file tree
Hide file tree
Showing 21 changed files with 685 additions and 581 deletions.
2 changes: 0 additions & 2 deletions include/linux/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk)
return (struct inet_request_sock *)sk;
}

struct inet_bind_bucket;
struct ipv6_pinfo;

struct inet_sock {
Expand Down Expand Up @@ -158,7 +157,6 @@ struct inet_sock {
int mc_index; /* Multicast device index */
__u32 mc_addr;
struct ip_mc_socklist *mc_list; /* Group array */
struct inet_bind_bucket *bind_hash;
/*
* Following members are used to retain the infomation to build
* an ip header on each ip fragmentation while the socket is corked.
Expand Down
8 changes: 4 additions & 4 deletions include/linux/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,15 @@ static inline struct in6_addr *tcp_v6_rcv_saddr(const struct sock *sk)
return sk->sk_family == AF_INET6 ? __tcp_v6_rcv_saddr(sk) : NULL;
}

static inline int tcp_twsk_ipv6only(const struct sock *sk)
static inline int inet_twsk_ipv6only(const struct sock *sk)
{
return inet_twsk(sk)->tw_ipv6only;
}

static inline int tcp_v6_ipv6only(const struct sock *sk)
static inline int inet_v6_ipv6only(const struct sock *sk)
{
return likely(sk->sk_state != TCP_TIME_WAIT) ?
ipv6_only_sock(sk) : tcp_twsk_ipv6only(sk);
ipv6_only_sock(sk) : inet_twsk_ipv6only(sk);
}
#else
#define __ipv6_only_sock(sk) 0
Expand All @@ -360,7 +360,7 @@ static inline struct raw6_sock *raw6_sk(const struct sock *sk)
#define __tcp_v6_rcv_saddr(__sk) NULL
#define tcp_v6_rcv_saddr(__sk) NULL
#define tcp_twsk_ipv6only(__sk) 0
#define tcp_v6_ipv6only(__sk) 0
#define inet_v6_ipv6only(__sk) 0
#endif /* defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */

#define INET6_MATCH(__sk, __saddr, __daddr, __ports, __dif) \
Expand Down
39 changes: 7 additions & 32 deletions include/linux/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ struct tcp_info

#include <linux/config.h>
#include <linux/skbuff.h>
#include <linux/ip.h>
#include <net/sock.h>
#include <net/inet_connection_sock.h>
#include <net/inet_timewait_sock.h>

/* This defines a selective acknowledgement block. */
Expand Down Expand Up @@ -219,8 +219,8 @@ static inline struct tcp_request_sock *tcp_rsk(const struct request_sock *req)
}

struct tcp_sock {
/* inet_sock has to be the first member of tcp_sock */
struct inet_sock inet;
/* inet_connection_sock has to be the first member of tcp_sock */
struct inet_connection_sock inet_conn;
int tcp_header_len; /* Bytes of tcp header to send */

/*
Expand All @@ -241,18 +241,6 @@ struct tcp_sock {
__u32 snd_sml; /* Last byte of the most recently transmitted small packet */
__u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */
__u32 lsndtime; /* timestamp of last sent data packet (for restart window) */
/* Delayed ACK control data */
struct {
__u8 pending; /* ACK is pending */
__u8 quick; /* Scheduled number of quick acks */
__u8 pingpong; /* The session is interactive */
__u8 blocked; /* Delayed ACK was blocked by socket lock*/
__u32 ato; /* Predicted tick of soft clock */
unsigned long timeout; /* Currently scheduled timeout */
__u32 lrcvtime; /* timestamp of last received data packet*/
__u16 last_seg_size; /* Size of last incoming segment */
__u16 rcv_mss; /* MSS used for delayed ACK decisions */
} ack;

/* Data for direct copy to user */
struct {
Expand All @@ -271,8 +259,8 @@ struct tcp_sock {
__u16 xmit_size_goal; /* Goal for segmenting output packets */
__u16 ext_header_len; /* Network protocol overhead (IP/IPv6 options) */
__u8 ca_state; /* State of fast-retransmit machine */
__u8 retransmits; /* Number of unrecovered RTO timeouts. */

__u8 keepalive_probes; /* num of allowed keep alive probes */
__u16 advmss; /* Advertised MSS */
__u32 window_clamp; /* Maximal window to advertise */
__u32 rcv_ssthresh; /* Current window clamp */
Expand All @@ -281,7 +269,7 @@ struct tcp_sock {
__u8 reordering; /* Packet reordering metric. */
__u8 frto_counter; /* Number of new acks after RTO */

__u8 unused;
__u8 nonagle; /* Disable Nagle algorithm? */
__u8 defer_accept; /* User waits for some data after accept() */

/* RTT measurement */
Expand All @@ -290,19 +278,13 @@ struct tcp_sock {
__u32 mdev_max; /* maximal mdev for the last rtt period */
__u32 rttvar; /* smoothed mdev_max */
__u32 rtt_seq; /* sequence number to update rttvar */
__u32 rto; /* retransmit timeout */

__u32 packets_out; /* Packets which are "in flight" */
__u32 left_out; /* Packets which leaved network */
__u32 retrans_out; /* Retransmitted packets out */
__u8 backoff; /* backoff */
/*
* Options received (usually on last packet, some only on SYN packets).
*/
__u8 nonagle; /* Disable Nagle algorithm? */
__u8 keepalive_probes; /* num of allowed keep alive probes */

__u8 probes_out; /* unanswered 0 window probes */
struct tcp_options_received rx_opt;

/*
Expand All @@ -315,11 +297,6 @@ struct tcp_sock {
__u32 snd_cwnd_used;
__u32 snd_cwnd_stamp;

/* Two commonly used timers in both sender and receiver paths. */
unsigned long timeout;
struct timer_list retransmit_timer; /* Resend (no ack) */
struct timer_list delack_timer; /* Ack delay */

struct sk_buff_head out_of_order_queue; /* Out of order segments go here */

struct tcp_func *af_specific; /* Operations which are AF_INET{4,6} specific */
Expand All @@ -334,7 +311,7 @@ struct tcp_sock {
struct tcp_sack_block duplicate_sack[1]; /* D-SACK block */
struct tcp_sack_block selective_acks[4]; /* The SACKS themselves*/

__u8 syn_retries; /* num of allowed syn retries */
__u8 probes_out; /* unanswered 0 window probes */
__u8 ecn_flags; /* ECN status bits. */
__u16 prior_ssthresh; /* ssthresh saved at recovery start */
__u32 lost_out; /* Lost packets */
Expand All @@ -349,14 +326,12 @@ struct tcp_sock {
int undo_retrans; /* number of undoable retransmissions. */
__u32 urg_seq; /* Seq of received urgent pointer */
__u16 urg_data; /* Saved octet of OOB data and control flags */
__u8 pending; /* Scheduled timer event */
__u8 urg_mode; /* In urgent mode */
/* ONE BYTE HOLE, TRY TO PACK! */
__u32 snd_up; /* Urgent pointer */

__u32 total_retrans; /* Total retransmits for entire connection */

struct request_sock_queue accept_queue; /* FIFO of established children */

unsigned int keepalive_time; /* time before keep alive takes place */
unsigned int keepalive_intvl; /* time interval between keep alive probes */
int linger2;
Expand Down
86 changes: 86 additions & 0 deletions include/net/inet_connection_sock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* NET Generic infrastructure for INET connection oriented protocols.
*
* Definitions for inet_connection_sock
*
* Authors: Many people, see the TCP sources
*
* From code originally in TCP
*
* 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 _INET_CONNECTION_SOCK_H
#define _INET_CONNECTION_SOCK_H

#include <linux/ip.h>
#include <linux/timer.h>
#include <net/request_sock.h>

struct inet_bind_bucket;
struct inet_hashinfo;

/** inet_connection_sock - INET connection oriented sock
*
* @icsk_accept_queue: FIFO of established children
* @icsk_bind_hash: Bind node
* @icsk_timeout: Timeout
* @icsk_retransmit_timer: Resend (no ack)
* @icsk_rto: Retransmit timeout
* @icsk_retransmits: Number of unrecovered [RTO] timeouts
* @icsk_pending: Scheduled timer event
* @icsk_backoff: Backoff
* @icsk_syn_retries: Number of allowed SYN (or equivalent) retries
* @icsk_ack: Delayed ACK control data
*/
struct inet_connection_sock {
/* inet_sock has to be the first member! */
struct inet_sock icsk_inet;
struct request_sock_queue icsk_accept_queue;
struct inet_bind_bucket *icsk_bind_hash;
unsigned long icsk_timeout;
struct timer_list icsk_retransmit_timer;
struct timer_list icsk_delack_timer;
__u32 icsk_rto;
__u8 icsk_retransmits;
__u8 icsk_pending;
__u8 icsk_backoff;
__u8 icsk_syn_retries;
struct {
__u8 pending; /* ACK is pending */
__u8 quick; /* Scheduled number of quick acks */
__u8 pingpong; /* The session is interactive */
__u8 blocked; /* Delayed ACK was blocked by socket lock */
__u32 ato; /* Predicted tick of soft clock */
unsigned long timeout; /* Currently scheduled timeout */
__u32 lrcvtime; /* timestamp of last received data packet */
__u16 last_seg_size; /* Size of last incoming segment */
__u16 rcv_mss; /* MSS used for delayed ACK decisions */
} icsk_ack;
};

static inline struct inet_connection_sock *inet_csk(const struct sock *sk)
{
return (struct inet_connection_sock *)sk;
}

extern void inet_csk_init_xmit_timers(struct sock *sk,
void (*retransmit_handler)(unsigned long),
void (*delack_handler)(unsigned long),
void (*keepalive_handler)(unsigned long));
extern void inet_csk_clear_xmit_timers(struct sock *sk);

extern struct request_sock *inet_csk_search_req(const struct sock *sk,
struct request_sock ***prevp,
const __u16 rport,
const __u32 raddr,
const __u32 laddr);
extern int inet_csk_get_port(struct inet_hashinfo *hashinfo,
struct sock *sk, unsigned short snum);

extern struct dst_entry* inet_csk_route_req(struct sock *sk,
const struct request_sock *req);

#endif /* _INET_CONNECTION_SOCK_H */
6 changes: 3 additions & 3 deletions include/net/inet_hashtables.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <linux/config.h>

#include <linux/interrupt.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/list.h>
#include <linux/slab.h>
Expand All @@ -26,6 +25,7 @@
#include <linux/types.h>
#include <linux/wait.h>

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

Expand Down Expand Up @@ -185,9 +185,9 @@ static inline void __inet_inherit_port(struct inet_hashinfo *table,
struct inet_bind_bucket *tb;

spin_lock(&head->lock);
tb = inet_sk(sk)->bind_hash;
tb = inet_csk(sk)->icsk_bind_hash;
sk_add_bind_node(child, &tb->owners);
inet_sk(child)->bind_hash = tb;
inet_csk(child)->icsk_bind_hash = tb;
spin_unlock(&head->lock);
}

Expand Down
6 changes: 3 additions & 3 deletions include/net/request_sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,17 @@ static inline int reqsk_queue_added(struct request_sock_queue *queue)
return prev_qlen;
}

static inline int reqsk_queue_len(struct request_sock_queue *queue)
static inline int reqsk_queue_len(const struct request_sock_queue *queue)
{
return queue->listen_opt != NULL ? queue->listen_opt->qlen : 0;
}

static inline int reqsk_queue_len_young(struct request_sock_queue *queue)
static inline int reqsk_queue_len_young(const struct request_sock_queue *queue)
{
return queue->listen_opt->qlen_young;
}

static inline int reqsk_queue_is_full(struct request_sock_queue *queue)
static inline int reqsk_queue_is_full(const struct request_sock_queue *queue)
{
return queue->listen_opt->qlen >> queue->listen_opt->max_qlen_log;
}
Expand Down
3 changes: 0 additions & 3 deletions include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,6 @@ extern int sk_wait_data(struct sock *sk, long *timeo);

struct request_sock_ops;

/* Here is the right place to enable sock refcounting debugging */
//#define SOCK_REFCNT_DEBUG

/* Networking protocol blocks we attach to sockets.
* socket layer -> transport layer interface
* transport -> network interface is defined by struct inet_proto
Expand Down
Loading

0 comments on commit 463c84b

Please sign in to comment.