[PATCH] uml: add -ffreestanding to CFLAGS
[linux/fpc-iii.git] / include / net / tcp_ecn.h
blobc6b84397448dac0b810079c96fe1c642773b16fd
1 #ifndef _NET_TCP_ECN_H_
2 #define _NET_TCP_ECN_H_ 1
4 #include <net/inet_ecn.h>
5 #include <net/request_sock.h>
7 #define TCP_HP_BITS (~(TCP_RESERVED_BITS|TCP_FLAG_PSH))
9 #define TCP_ECN_OK 1
10 #define TCP_ECN_QUEUE_CWR 2
11 #define TCP_ECN_DEMAND_CWR 4
13 static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp)
15 if (tp->ecn_flags&TCP_ECN_OK)
16 tp->ecn_flags |= TCP_ECN_QUEUE_CWR;
20 /* Output functions */
22 static inline void TCP_ECN_send_synack(struct tcp_sock *tp,
23 struct sk_buff *skb)
25 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR;
26 if (!(tp->ecn_flags&TCP_ECN_OK))
27 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE;
30 static inline void TCP_ECN_send_syn(struct sock *sk, struct tcp_sock *tp,
31 struct sk_buff *skb)
33 tp->ecn_flags = 0;
34 if (sysctl_tcp_ecn && !(sk->sk_route_caps & NETIF_F_TSO)) {
35 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
36 tp->ecn_flags = TCP_ECN_OK;
37 sock_set_flag(sk, SOCK_NO_LARGESEND);
41 static __inline__ void
42 TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th)
44 if (inet_rsk(req)->ecn_ok)
45 th->ece = 1;
48 static inline void TCP_ECN_send(struct sock *sk, struct tcp_sock *tp,
49 struct sk_buff *skb, int tcp_header_len)
51 if (tp->ecn_flags & TCP_ECN_OK) {
52 /* Not-retransmitted data segment: set ECT and inject CWR. */
53 if (skb->len != tcp_header_len &&
54 !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) {
55 INET_ECN_xmit(sk);
56 if (tp->ecn_flags&TCP_ECN_QUEUE_CWR) {
57 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR;
58 skb->h.th->cwr = 1;
60 } else {
61 /* ACK or retransmitted segment: clear ECT|CE */
62 INET_ECN_dontxmit(sk);
64 if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
65 skb->h.th->ece = 1;
69 /* Input functions */
71 static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb)
73 if (skb->h.th->cwr)
74 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
77 static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp)
79 tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
82 static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb)
84 if (tp->ecn_flags&TCP_ECN_OK) {
85 if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags))
86 tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
87 /* Funny extension: if ECT is not set on a segment,
88 * it is surely retransmit. It is not in ECN RFC,
89 * but Linux follows this rule. */
90 else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags)))
91 tcp_enter_quickack_mode((struct sock *)tp);
95 static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th)
97 if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || th->cwr))
98 tp->ecn_flags &= ~TCP_ECN_OK;
101 static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th)
103 if ((tp->ecn_flags&TCP_ECN_OK) && (!th->ece || !th->cwr))
104 tp->ecn_flags &= ~TCP_ECN_OK;
107 static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th)
109 if (th->ece && !th->syn && (tp->ecn_flags&TCP_ECN_OK))
110 return 1;
111 return 0;
114 static inline void TCP_ECN_openreq_child(struct tcp_sock *tp,
115 struct request_sock *req)
117 tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0;
120 static __inline__ void
121 TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th)
123 if (sysctl_tcp_ecn && th->ece && th->cwr)
124 inet_rsk(req)->ecn_ok = 1;
127 #endif