forked from mirrors/linux
		
	[TCP]: Move code from tcp_ecn.h to tcp*.c and tcp.h & remove it
No other users exist for tcp_ecn.h. Very few things remain in tcp.h, for most TCP ECN functions callers reside within a single .c file and can be placed there. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									539d243fdd
								
							
						
					
					
						commit
						bdf1ee5d3b
					
				
					 5 changed files with 118 additions and 132 deletions
				
			
		|  | @ -39,6 +39,7 @@ | ||||||
| #include <net/snmp.h> | #include <net/snmp.h> | ||||||
| #include <net/ip.h> | #include <net/ip.h> | ||||||
| #include <net/tcp_states.h> | #include <net/tcp_states.h> | ||||||
|  | #include <net/inet_ecn.h> | ||||||
| 
 | 
 | ||||||
| #include <linux/seq_file.h> | #include <linux/seq_file.h> | ||||||
| 
 | 
 | ||||||
|  | @ -330,6 +331,17 @@ static inline void tcp_clear_options(struct tcp_options_received *rx_opt) | ||||||
|  	rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; |  	rx_opt->tstamp_ok = rx_opt->sack_ok = rx_opt->wscale_ok = rx_opt->snd_wscale = 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | #define	TCP_ECN_OK		1 | ||||||
|  | #define	TCP_ECN_QUEUE_CWR	2 | ||||||
|  | #define	TCP_ECN_DEMAND_CWR	4 | ||||||
|  | 
 | ||||||
|  | static __inline__ void | ||||||
|  | TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) | ||||||
|  | { | ||||||
|  | 	if (sysctl_tcp_ecn && th->ece && th->cwr) | ||||||
|  | 		inet_rsk(req)->ecn_ok = 1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| enum tcp_tw_status | enum tcp_tw_status | ||||||
| { | { | ||||||
| 	TCP_TW_SUCCESS = 0, | 	TCP_TW_SUCCESS = 0, | ||||||
|  | @ -573,8 +585,6 @@ struct tcp_skb_cb { | ||||||
| 
 | 
 | ||||||
| #define TCP_SKB_CB(__skb)	((struct tcp_skb_cb *)&((__skb)->cb[0])) | #define TCP_SKB_CB(__skb)	((struct tcp_skb_cb *)&((__skb)->cb[0])) | ||||||
| 
 | 
 | ||||||
| #include <net/tcp_ecn.h> |  | ||||||
| 
 |  | ||||||
| /* Due to TSO, an SKB can be composed of multiple actual
 | /* Due to TSO, an SKB can be composed of multiple actual
 | ||||||
|  * packets.  To keep these tracked properly, we use this. |  * packets.  To keep these tracked properly, we use this. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
|  | @ -1,130 +0,0 @@ | ||||||
| #ifndef _NET_TCP_ECN_H_ |  | ||||||
| #define _NET_TCP_ECN_H_ 1 |  | ||||||
| 
 |  | ||||||
| #include <net/inet_ecn.h> |  | ||||||
| #include <net/request_sock.h> |  | ||||||
| 
 |  | ||||||
| #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)) |  | ||||||
| 
 |  | ||||||
| #define	TCP_ECN_OK		1 |  | ||||||
| #define TCP_ECN_QUEUE_CWR	2 |  | ||||||
| #define TCP_ECN_DEMAND_CWR	4 |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp) |  | ||||||
| { |  | ||||||
| 	if (tp->ecn_flags&TCP_ECN_OK) |  | ||||||
| 		tp->ecn_flags |= TCP_ECN_QUEUE_CWR; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| /* Output functions */ |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_send_synack(struct tcp_sock *tp, |  | ||||||
| 				       struct sk_buff *skb) |  | ||||||
| { |  | ||||||
| 	TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR; |  | ||||||
| 	if (!(tp->ecn_flags&TCP_ECN_OK)) |  | ||||||
| 		TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb) |  | ||||||
| { |  | ||||||
| 	struct tcp_sock *tp = tcp_sk(sk); |  | ||||||
| 
 |  | ||||||
| 	tp->ecn_flags = 0; |  | ||||||
| 	if (sysctl_tcp_ecn) { |  | ||||||
| 		TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR; |  | ||||||
| 		tp->ecn_flags = TCP_ECN_OK; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static __inline__ void |  | ||||||
| TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th) |  | ||||||
| { |  | ||||||
| 	if (inet_rsk(req)->ecn_ok) |  | ||||||
| 		th->ece = 1; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb, |  | ||||||
| 				int tcp_header_len) |  | ||||||
| { |  | ||||||
| 	struct tcp_sock *tp = tcp_sk(sk); |  | ||||||
| 
 |  | ||||||
| 	if (tp->ecn_flags & TCP_ECN_OK) { |  | ||||||
| 		/* Not-retransmitted data segment: set ECT and inject CWR. */ |  | ||||||
| 		if (skb->len != tcp_header_len && |  | ||||||
| 		    !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { |  | ||||||
| 			INET_ECN_xmit(sk); |  | ||||||
| 			if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) { |  | ||||||
| 				tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; |  | ||||||
| 				tcp_hdr(skb)->cwr = 1; |  | ||||||
| 				skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN; |  | ||||||
| 			} |  | ||||||
| 		} else { |  | ||||||
| 			/* ACK or retransmitted segment: clear ECT|CE */ |  | ||||||
| 			INET_ECN_dontxmit(sk); |  | ||||||
| 		} |  | ||||||
| 		if (tp->ecn_flags & TCP_ECN_DEMAND_CWR) |  | ||||||
| 			tcp_hdr(skb)->ece = 1; |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| /* Input functions */ |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb) |  | ||||||
| { |  | ||||||
| 	if (tcp_hdr(skb)->cwr) |  | ||||||
| 		tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp) |  | ||||||
| { |  | ||||||
| 	tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb) |  | ||||||
| { |  | ||||||
| 	if (tp->ecn_flags&TCP_ECN_OK) { |  | ||||||
| 		if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags)) |  | ||||||
| 			tp->ecn_flags |= TCP_ECN_DEMAND_CWR; |  | ||||||
| 		/* Funny extension: if ECT is not set on a segment,
 |  | ||||||
| 		 * it is surely retransmit. It is not in ECN RFC, |  | ||||||
| 		 * but Linux follows this rule. */ |  | ||||||
| 		else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags))) |  | ||||||
| 			tcp_enter_quickack_mode((struct sock *)tp); |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th) |  | ||||||
| { |  | ||||||
| 	if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr)) |  | ||||||
| 		tp->ecn_flags &= ~TCP_ECN_OK; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th) |  | ||||||
| { |  | ||||||
| 	if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr)) |  | ||||||
| 		tp->ecn_flags &= ~TCP_ECN_OK; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th) |  | ||||||
| { |  | ||||||
| 	if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK)) |  | ||||||
| 		return 1; |  | ||||||
| 	return 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static inline void TCP_ECN_openreq_child(struct tcp_sock *tp, |  | ||||||
| 					 struct request_sock *req) |  | ||||||
| { |  | ||||||
| 	tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| static __inline__ void |  | ||||||
| TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) |  | ||||||
| { |  | ||||||
| 	if (sysctl_tcp_ecn && th->ece && th->cwr) |  | ||||||
| 		inet_rsk(req)->ecn_ok = 1; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| #endif |  | ||||||
|  | @ -118,6 +118,7 @@ int sysctl_tcp_abc __read_mostly; | ||||||
| #define IsSackFrto() (sysctl_tcp_frto == 0x2) | #define IsSackFrto() (sysctl_tcp_frto == 0x2) | ||||||
| 
 | 
 | ||||||
| #define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH) | #define TCP_REMNANT (TCP_FLAG_FIN|TCP_FLAG_URG|TCP_FLAG_SYN|TCP_FLAG_PSH) | ||||||
|  | #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH)) | ||||||
| 
 | 
 | ||||||
| /* Adapt the MSS value used to make delayed ack decision to the
 | /* Adapt the MSS value used to make delayed ack decision to the
 | ||||||
|  * real world. |  * real world. | ||||||
|  | @ -198,6 +199,55 @@ static inline int tcp_in_quickack_mode(const struct sock *sk) | ||||||
| 	return icsk->icsk_ack.quick && !icsk->icsk_ack.pingpong; | 	return icsk->icsk_ack.quick && !icsk->icsk_ack.pingpong; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp) | ||||||
|  | { | ||||||
|  | 	if (tp->ecn_flags&TCP_ECN_OK) | ||||||
|  | 		tp->ecn_flags |= TCP_ECN_QUEUE_CWR; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb) | ||||||
|  | { | ||||||
|  | 	if (tcp_hdr(skb)->cwr) | ||||||
|  | 		tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp) | ||||||
|  | { | ||||||
|  | 	tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb) | ||||||
|  | { | ||||||
|  | 	if (tp->ecn_flags&TCP_ECN_OK) { | ||||||
|  | 		if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags)) | ||||||
|  | 			tp->ecn_flags |= TCP_ECN_DEMAND_CWR; | ||||||
|  | 		/* Funny extension: if ECT is not set on a segment,
 | ||||||
|  | 		 * it is surely retransmit. It is not in ECN RFC, | ||||||
|  | 		 * but Linux follows this rule. */ | ||||||
|  | 		else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags))) | ||||||
|  | 			tcp_enter_quickack_mode((struct sock *)tp); | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th) | ||||||
|  | { | ||||||
|  | 	if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr)) | ||||||
|  | 		tp->ecn_flags &= ~TCP_ECN_OK; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th) | ||||||
|  | { | ||||||
|  | 	if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr)) | ||||||
|  | 		tp->ecn_flags &= ~TCP_ECN_OK; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th) | ||||||
|  | { | ||||||
|  | 	if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK)) | ||||||
|  | 		return 1; | ||||||
|  | 	return 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* Buffer size and advertised window tuning.
 | /* Buffer size and advertised window tuning.
 | ||||||
|  * |  * | ||||||
|  * 1. Tuning sk->sk_sndbuf, when connection enters established state. |  * 1. Tuning sk->sk_sndbuf, when connection enters established state. | ||||||
|  |  | ||||||
|  | @ -368,6 +368,12 @@ void tcp_twsk_destructor(struct sock *sk) | ||||||
| 
 | 
 | ||||||
| EXPORT_SYMBOL_GPL(tcp_twsk_destructor); | EXPORT_SYMBOL_GPL(tcp_twsk_destructor); | ||||||
| 
 | 
 | ||||||
|  | static inline void TCP_ECN_openreq_child(struct tcp_sock *tp, | ||||||
|  | 					 struct request_sock *req) | ||||||
|  | { | ||||||
|  | 	tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| /* This is not only more efficient than what we used to do, it eliminates
 | /* This is not only more efficient than what we used to do, it eliminates
 | ||||||
|  * a lot of code duplication between IPv4/IPv6 SYN recv processing. -DaveM |  * a lot of code duplication between IPv4/IPv6 SYN recv processing. -DaveM | ||||||
|  * |  * | ||||||
|  |  | ||||||
|  | @ -269,6 +269,56 @@ static u16 tcp_select_window(struct sock *sk) | ||||||
| 	return new_win; | 	return new_win; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | static inline void TCP_ECN_send_synack(struct tcp_sock *tp, | ||||||
|  | 				       struct sk_buff *skb) | ||||||
|  | { | ||||||
|  | 	TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR; | ||||||
|  | 	if (!(tp->ecn_flags&TCP_ECN_OK)) | ||||||
|  | 		TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb) | ||||||
|  | { | ||||||
|  | 	struct tcp_sock *tp = tcp_sk(sk); | ||||||
|  | 
 | ||||||
|  | 	tp->ecn_flags = 0; | ||||||
|  | 	if (sysctl_tcp_ecn) { | ||||||
|  | 		TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR; | ||||||
|  | 		tp->ecn_flags = TCP_ECN_OK; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static __inline__ void | ||||||
|  | TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th) | ||||||
|  | { | ||||||
|  | 	if (inet_rsk(req)->ecn_ok) | ||||||
|  | 		th->ece = 1; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb, | ||||||
|  | 				int tcp_header_len) | ||||||
|  | { | ||||||
|  | 	struct tcp_sock *tp = tcp_sk(sk); | ||||||
|  | 
 | ||||||
|  | 	if (tp->ecn_flags & TCP_ECN_OK) { | ||||||
|  | 		/* Not-retransmitted data segment: set ECT and inject CWR. */ | ||||||
|  | 		if (skb->len != tcp_header_len && | ||||||
|  | 		    !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { | ||||||
|  | 			INET_ECN_xmit(sk); | ||||||
|  | 			if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) { | ||||||
|  | 				tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; | ||||||
|  | 				tcp_hdr(skb)->cwr = 1; | ||||||
|  | 				skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN; | ||||||
|  | 			} | ||||||
|  | 		} else { | ||||||
|  | 			/* ACK or retransmitted segment: clear ECT|CE */ | ||||||
|  | 			INET_ECN_dontxmit(sk); | ||||||
|  | 		} | ||||||
|  | 		if (tp->ecn_flags & TCP_ECN_DEMAND_CWR) | ||||||
|  | 			tcp_hdr(skb)->ece = 1; | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
| static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp, | static void tcp_build_and_update_options(__be32 *ptr, struct tcp_sock *tp, | ||||||
| 					 __u32 tstamp, __u8 **md5_hash) | 					 __u32 tstamp, __u8 **md5_hash) | ||||||
| { | { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Ilpo Järvinen
						Ilpo Järvinen