2005-04-16 15:20:36 -07:00
|
|
|
#ifndef _NET_TCP_ECN_H_
|
|
|
|
#define _NET_TCP_ECN_H_ 1
|
|
|
|
|
|
|
|
#include <net/inet_ecn.h>
|
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 22:46:52 -07:00
|
|
|
#include <net/request_sock.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
|
[TCP]: Sed magic converts func(sk, tp, ...) -> func(sk, ...)
This is (mostly) automated change using magic:
sed -e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e 's|struct sock \*sk,[\n\t ]*struct tcp_sock \*tp\([^{]*\n{\n\)|
struct sock \*sk\1\tstruct tcp_sock *tp = tcp_sk(sk);\n|g'
-e 's|struct sock \*sk, struct tcp_sock \*tp|
struct sock \*sk|g' -e 's|sk, tp\([^-]\)|sk\1|g'
Fixed four unused variable (tp) warnings that were introduced.
In addition, manually added newlines after local variables and
tweaked function arguments positioning.
$ gcc --version
gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)
...
$ codiff -fV built-in.o.old built-in.o.new
net/ipv4/route.c:
rt_cache_flush | +14
1 function changed, 14 bytes added
net/ipv4/tcp.c:
tcp_setsockopt | -5
tcp_sendpage | -25
tcp_sendmsg | -16
3 functions changed, 46 bytes removed
net/ipv4/tcp_input.c:
tcp_try_undo_recovery | +3
tcp_try_undo_dsack | +2
tcp_mark_head_lost | -12
tcp_ack | -15
tcp_event_data_recv | -32
tcp_rcv_state_process | -10
tcp_rcv_established | +1
7 functions changed, 6 bytes added, 69 bytes removed, diff: -63
net/ipv4/tcp_output.c:
update_send_head | -9
tcp_transmit_skb | +19
tcp_cwnd_validate | +1
tcp_write_wakeup | -17
__tcp_push_pending_frames | -25
tcp_push_one | -8
tcp_send_fin | -4
7 functions changed, 20 bytes added, 63 bytes removed, diff: -43
built-in.o.new:
18 functions changed, 40 bytes added, 178 bytes removed, diff: -138
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-20 22:18:02 -07:00
|
|
|
static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
[TCP]: Sed magic converts func(sk, tp, ...) -> func(sk, ...)
This is (mostly) automated change using magic:
sed -e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e 's|struct sock \*sk,[\n\t ]*struct tcp_sock \*tp\([^{]*\n{\n\)|
struct sock \*sk\1\tstruct tcp_sock *tp = tcp_sk(sk);\n|g'
-e 's|struct sock \*sk, struct tcp_sock \*tp|
struct sock \*sk|g' -e 's|sk, tp\([^-]\)|sk\1|g'
Fixed four unused variable (tp) warnings that were introduced.
In addition, manually added newlines after local variables and
tweaked function arguments positioning.
$ gcc --version
gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)
...
$ codiff -fV built-in.o.old built-in.o.new
net/ipv4/route.c:
rt_cache_flush | +14
1 function changed, 14 bytes added
net/ipv4/tcp.c:
tcp_setsockopt | -5
tcp_sendpage | -25
tcp_sendmsg | -16
3 functions changed, 46 bytes removed
net/ipv4/tcp_input.c:
tcp_try_undo_recovery | +3
tcp_try_undo_dsack | +2
tcp_mark_head_lost | -12
tcp_ack | -15
tcp_event_data_recv | -32
tcp_rcv_state_process | -10
tcp_rcv_established | +1
7 functions changed, 6 bytes added, 69 bytes removed, diff: -63
net/ipv4/tcp_output.c:
update_send_head | -9
tcp_transmit_skb | +19
tcp_cwnd_validate | +1
tcp_write_wakeup | -17
__tcp_push_pending_frames | -25
tcp_push_one | -8
tcp_send_fin | -4
7 functions changed, 20 bytes added, 63 bytes removed, diff: -43
built-in.o.new:
18 functions changed, 40 bytes added, 178 bytes removed, diff: -138
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-20 22:18:02 -07:00
|
|
|
struct tcp_sock *tp = tcp_sk(sk);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
tp->ecn_flags = 0;
|
2006-06-29 12:30:00 -07:00
|
|
|
if (sysctl_tcp_ecn) {
|
2005-04-16 15:20:36 -07:00
|
|
|
TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
|
|
|
|
tp->ecn_flags = TCP_ECN_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
2005-06-18 22:47:21 -07:00
|
|
|
TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 22:46:52 -07:00
|
|
|
if (inet_rsk(req)->ecn_ok)
|
2005-04-16 15:20:36 -07:00
|
|
|
th->ece = 1;
|
|
|
|
}
|
|
|
|
|
[TCP]: Sed magic converts func(sk, tp, ...) -> func(sk, ...)
This is (mostly) automated change using magic:
sed -e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e 's|struct sock \*sk,[\n\t ]*struct tcp_sock \*tp\([^{]*\n{\n\)|
struct sock \*sk\1\tstruct tcp_sock *tp = tcp_sk(sk);\n|g'
-e 's|struct sock \*sk, struct tcp_sock \*tp|
struct sock \*sk|g' -e 's|sk, tp\([^-]\)|sk\1|g'
Fixed four unused variable (tp) warnings that were introduced.
In addition, manually added newlines after local variables and
tweaked function arguments positioning.
$ gcc --version
gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)
...
$ codiff -fV built-in.o.old built-in.o.new
net/ipv4/route.c:
rt_cache_flush | +14
1 function changed, 14 bytes added
net/ipv4/tcp.c:
tcp_setsockopt | -5
tcp_sendpage | -25
tcp_sendmsg | -16
3 functions changed, 46 bytes removed
net/ipv4/tcp_input.c:
tcp_try_undo_recovery | +3
tcp_try_undo_dsack | +2
tcp_mark_head_lost | -12
tcp_ack | -15
tcp_event_data_recv | -32
tcp_rcv_state_process | -10
tcp_rcv_established | +1
7 functions changed, 6 bytes added, 69 bytes removed, diff: -63
net/ipv4/tcp_output.c:
update_send_head | -9
tcp_transmit_skb | +19
tcp_cwnd_validate | +1
tcp_write_wakeup | -17
__tcp_push_pending_frames | -25
tcp_push_one | -8
tcp_send_fin | -4
7 functions changed, 20 bytes added, 63 bytes removed, diff: -43
built-in.o.new:
18 functions changed, 40 bytes added, 178 bytes removed, diff: -138
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-20 22:18:02 -07:00
|
|
|
static inline void TCP_ECN_send(struct sock *sk, struct sk_buff *skb,
|
|
|
|
int tcp_header_len)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
[TCP]: Sed magic converts func(sk, tp, ...) -> func(sk, ...)
This is (mostly) automated change using magic:
sed -e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e '/struct sock \*sk/ N' -e '/struct sock \*sk/ N'
-e 's|struct sock \*sk,[\n\t ]*struct tcp_sock \*tp\([^{]*\n{\n\)|
struct sock \*sk\1\tstruct tcp_sock *tp = tcp_sk(sk);\n|g'
-e 's|struct sock \*sk, struct tcp_sock \*tp|
struct sock \*sk|g' -e 's|sk, tp\([^-]\)|sk\1|g'
Fixed four unused variable (tp) warnings that were introduced.
In addition, manually added newlines after local variables and
tweaked function arguments positioning.
$ gcc --version
gcc (GCC) 4.1.1 20060525 (Red Hat 4.1.1-1)
...
$ codiff -fV built-in.o.old built-in.o.new
net/ipv4/route.c:
rt_cache_flush | +14
1 function changed, 14 bytes added
net/ipv4/tcp.c:
tcp_setsockopt | -5
tcp_sendpage | -25
tcp_sendmsg | -16
3 functions changed, 46 bytes removed
net/ipv4/tcp_input.c:
tcp_try_undo_recovery | +3
tcp_try_undo_dsack | +2
tcp_mark_head_lost | -12
tcp_ack | -15
tcp_event_data_recv | -32
tcp_rcv_state_process | -10
tcp_rcv_established | +1
7 functions changed, 6 bytes added, 69 bytes removed, diff: -63
net/ipv4/tcp_output.c:
update_send_head | -9
tcp_transmit_skb | +19
tcp_cwnd_validate | +1
tcp_write_wakeup | -17
__tcp_push_pending_frames | -25
tcp_push_one | -8
tcp_send_fin | -4
7 functions changed, 20 bytes added, 63 bytes removed, diff: -43
built-in.o.new:
18 functions changed, 40 bytes added, 178 bytes removed, diff: -138
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
2007-04-20 22:18:02 -07:00
|
|
|
struct tcp_sock *tp = tcp_sk(sk);
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
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;
|
2007-04-10 21:04:22 -07:00
|
|
|
tcp_hdr(skb)->cwr = 1;
|
2006-06-30 13:37:03 -07:00
|
|
|
skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_ECN;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* ACK or retransmitted segment: clear ECT|CE */
|
|
|
|
INET_ECN_dontxmit(sk);
|
|
|
|
}
|
|
|
|
if (tp->ecn_flags & TCP_ECN_DEMAND_CWR)
|
2007-04-10 21:04:22 -07:00
|
|
|
tcp_hdr(skb)->ece = 1;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Input functions */
|
|
|
|
|
|
|
|
static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb)
|
|
|
|
{
|
2007-04-10 21:04:22 -07:00
|
|
|
if (tcp_hdr(skb)->cwr)
|
2005-04-16 15:20:36 -07:00
|
|
|
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)))
|
2005-08-09 20:10:42 -07:00
|
|
|
tcp_enter_quickack_mode((struct sock *)tp);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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,
|
2005-06-18 22:47:21 -07:00
|
|
|
struct request_sock *req)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 22:46:52 -07:00
|
|
|
tp->ecn_flags = inet_rsk(req)->ecn_ok ? TCP_ECN_OK : 0;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static __inline__ void
|
2005-06-18 22:47:21 -07:00
|
|
|
TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
if (sysctl_tcp_ecn && th->ece && th->cwr)
|
[NET] Generalise TCP's struct open_request minisock infrastructure
Kept this first changeset minimal, without changing existing names to
ease peer review.
Basicaly tcp_openreq_alloc now receives the or_calltable, that in turn
has two new members:
->slab, that replaces tcp_openreq_cachep
->obj_size, to inform the size of the openreq descendant for
a specific protocol
The protocol specific fields in struct open_request were moved to a
class hierarchy, with the things that are common to all connection
oriented PF_INET protocols in struct inet_request_sock, the TCP ones
in tcp_request_sock, that is an inet_request_sock, that is an
open_request.
I.e. this uses the same approach used for the struct sock class
hierarchy, with sk_prot indicating if the protocol wants to use the
open_request infrastructure by filling in sk_prot->rsk_prot with an
or_calltable.
Results? Performance is improved and TCP v4 now uses only 64 bytes per
open request minisock, down from 96 without this patch :-)
Next changeset will rename some of the structs, fields and functions
mentioned above, struct or_calltable is way unclear, better name it
struct request_sock_ops, s/struct open_request/struct request_sock/g,
etc.
Signed-off-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 22:46:52 -07:00
|
|
|
inet_rsk(req)->ecn_ok = 1;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|