Per route TCP options support kill switches
Subsystems (3)
v4 cover Per route TCP options support kill switches
Allow selectively turning off support for specific TCP options on a per route basis.
One normally want to disable SACK, DSACK, time stamp or window scale if one got a piece of broken networking equipment somewhere as a stop gap until you can bring a big enough hammer to deal with the broken network equipment. It doesn't make sense to "punish" the entire connections going through the machine to destinations not related to the broken equipment.
This is doubly true when one is dealing with network containers used to isolate several virtual domains.
Per route options implemented in free bits in the features route entry property, which in some cases were reserved by name for these options, so this does not inflate any structure.
Global sysctls for these options are still preserved and retain the exact original meaning (e.g. you have to have both the global sysctl turned on and not turn off the TCP option parsing in the specific route to have it proccessed).
It is not possible to turn off globally an option but turn it on per route, so as to not subtly change the meaning of current establish sysctls (and this is a rare need anyway).
Tested on x86 using Qemu/KVM.
Working but crude matching patch to iproute2 sent earlier to the list.
Patchset based on original work by Ori Finkelman and Yony Amit from ComSleep Ltd.
The author wishes to thank Eric Dumazaet, William Allen Simpson, Bill Fink and Ilpo Jarvinen for their feedback.
Gilad Ben-Yossef (7):
Only parse time stamp TCP option in time wait sock Allow tcp_parse_options to consult dst entry Add dst_feature to query route entry features Add the no SACK route option feature
Allow disabling TCP timestamp options per route Allow to turn off TCP window scale opt per route Allow disabling of DSACK TCP option per route
include/linux/rtnetlink.h | 6 ++++-- include/net/dst.h | 8 +++++++- include/net/tcp.h | 3 ++- net/ipv4/syncookies.c | 27 ++++++++++++++------------- net/ipv4/tcp_input.c | 26 ++++++++++++++++++-------- net/ipv4/tcp_ipv4.c | 21 ++++++++++++--------- net/ipv4/tcp_minisocks.c | 9 ++++++--- net/ipv4/tcp_output.c | 18 +++++++++++++----- net/ipv6/syncookies.c | 28 +++++++++++++++------------- net/ipv6/tcp_ipv6.c | 3 ++- 10 files changed, 93 insertions(+), 56 deletions(-)
PATCH v4 1/7 Only parse time stamp TCP option in time wait sock
Since we only use tcp_parse_options here to check for the exietence of TCP timestamp option in the header, it is better to call with the "established" flag on.
--- net/ipv4/tcp_minisocks.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/tcp_minisocks.c +2 -2
@@ -100,9 +100,9 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,struct tcp_options_received tmp_opt;int paws_reject =0 ; - tmp_opt.saw_tstamp =0 ;if (th->doff > (sizeof (*th) >>2 ) && tcptw->tw_ts_recent_stamp) { -tcp_parse_options (skb, &tmp_opt,0 ); + tmp_opt.tstamp_ok =1 ; +tcp_parse_options (skb, &tmp_opt,1 );if (tmp_opt.saw_tstamp) { tmp_opt.ts_recent = tcptw->tw_ts_recent;
Signature · 1 line
1.5.6.3
PATCH v4 2/7 Allow tcp_parse_options to consult dst entry
In reply to Gilad Ben-YossefWe need tcp_parse_options to be aware of dst_entry to take into account per dst_entry TCP options settings
--- include/net/tcp.h | 3 ++- net/ipv4/syncookies.c | 27 ++++++++++++++------------- net/ipv4/tcp_input.c | 9 ++++++--- net/ipv4/tcp_ipv4.c | 21 ++++++++++++--------- net/ipv4/tcp_minisocks.c | 7 +++++-- net/ipv6/syncookies.c | 28 +++++++++++++++------------- net/ipv6/tcp_ipv6.c | 3 ++- 7 files changed, 56 insertions(+), 42 deletions(-)
include/net/tcp.h +2 -1
@@ -409,7 +409,8 @@ extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk,extern void tcp_parse_options (struct sk_buff *skb,struct tcp_options_received *opt_rx, -int estab); +int estab, +struct dst_entry *dst);extern u8 *tcp_parse_md5sig_option (struct tcphdr *th);
net/ipv4/syncookies.c +14 -13
@@ -276,13 +276,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb,NET_INC_STATS_BH (sock_net (sk),LINUX_MIB_SYNCOOKIESRECV ); -/* check for timestamp cookie support */ -memset (&tcp_opt,0 ,sizeof (tcp_opt)); -tcp_parse_options (skb, &tcp_opt,0 ); - -if (tcp_opt.saw_tstamp) -cookie_check_timestamp (&tcp_opt); - ret =NULL ; req =inet_reqsk_alloc (&tcp_request_sock_ops);/* for safety */ if (!req)
@@ -298,12 +291,6 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, ireq->loc_addr =ip_hdr (skb)->daddr; ireq->rmt_addr =ip_hdr (skb)->saddr; ireq->ecn_ok =0 ; - ireq->snd_wscale = tcp_opt.snd_wscale; - ireq->rcv_wscale = tcp_opt.rcv_wscale; - ireq->sack_ok = tcp_opt.sack_ok; - ireq->wscale_ok = tcp_opt.wscale_ok; - ireq->tstamp_ok = tcp_opt.saw_tstamp; - req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval :0 ;/* We throwed the options of the initial SYN away, so we hope * the ACK carries the same options again (see RFC1122 4.2.3.8)
@@ -351,6 +338,20 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, } } +/* check for timestamp cookie support */ +memset (&tcp_opt,0 ,sizeof (tcp_opt)); +tcp_parse_options (skb, &tcp_opt,0 , &rt->u.dst); + +if (tcp_opt.saw_tstamp) +cookie_check_timestamp (&tcp_opt); + + ireq->snd_wscale = tcp_opt.snd_wscale; + ireq->rcv_wscale = tcp_opt.rcv_wscale; + ireq->sack_ok = tcp_opt.sack_ok; + ireq->wscale_ok = tcp_opt.wscale_ok; + ireq->tstamp_ok = tcp_opt.saw_tstamp; + req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval :0 ; +/* Try to redo what tcp_v4_send_synack did. */ req->window_clamp = tp->window_clamp ? :dst_metric (&rt->u.dst,RTAX_WINDOW );
net/ipv4/tcp_input.c +6 -3
@@ -3698,12 +3698,14 @@ old_ack:* the fast version below fails. */ void tcp_parse_options (struct sk_buff *skb,struct tcp_options_received *opt_rx, -int estab) +int estab,struct dst_entry *dst) {unsigned char *ptr;struct tcphdr *th =tcp_hdr (skb);int length = (th->doff *4 ) -sizeof (struct tcphdr ); +BUG_ON (!estab && !dst); + ptr = (unsigned char *)(th +1 ); opt_rx->saw_tstamp =0 ;
@@ -3820,7 +3822,7 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th,if (tcp_parse_aligned_timestamp (tp, th))return 1 ; } -tcp_parse_options (skb, &tp->rx_opt,1 ); +tcp_parse_options (skb, &tp->rx_opt,1 ,NULL );return 1 ; }
@@ -5364,8 +5366,9 @@ static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb,struct tcp_sock *tp =tcp_sk (sk);struct inet_connection_sock *icsk =inet_csk (sk);int saved_clamp = tp->rx_opt.mss_clamp; +struct dst_entry *dst =__sk_dst_get (sk); -tcp_parse_options (skb, &tp->rx_opt,0 ); +tcp_parse_options (skb, &tp->rx_opt,0 , dst);if (th->ack) {/* rfc793:
net/ipv4/tcp_ipv4.c +12 -9
@@ -1256,11 +1256,21 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)tcp_rsk (req)->af_specific = &tcp_request_sock_ipv4_ops;#endif + ireq =inet_rsk (req); + ireq->loc_addr = daddr; + ireq->rmt_addr = saddr; + ireq->no_srccheck =inet_sk (sk)->transparent; + ireq->opt =tcp_v4_save_options (sk, skb); + + dst =inet_csk_route_req (sk, req); +if (!dst) + goto drop_and_free; +tcp_clear_options (&tmp_opt); tmp_opt.mss_clamp =536 ; tmp_opt.user_mss =tcp_sk (sk)->rx_opt.user_mss; -tcp_parse_options (skb, &tmp_opt,0 ); +tcp_parse_options (skb, &tmp_opt,0 , dst);if (want_cookie && !tmp_opt.saw_tstamp)tcp_clear_options (&tmp_opt);
@@ -1269,14 +1279,8 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)tcp_openreq_init (req, &tmp_opt, skb); - ireq =inet_rsk (req); - ireq->loc_addr = daddr; - ireq->rmt_addr = saddr; - ireq->no_srccheck =inet_sk (sk)->transparent; - ireq->opt =tcp_v4_save_options (sk, skb); -if (security_inet_conn_request (sk, skb, req)) - goto drop_and_free; + goto drop_and_release;if (!want_cookie)TCP_ECN_create_request (req,tcp_hdr (skb));
@@ -1301,7 +1305,6 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb)*/ if (tmp_opt.saw_tstamp && tcp_death_row.sysctl_tw_recycle && - (dst =inet_csk_route_req (sk, req)) !=NULL && (peer =rt_get_peer ((struct rtable *)dst)) !=NULL && peer->v4daddr == saddr) { if (get_seconds() < peer->tcp_ts_stamp + TCP_PAWS_MSL &&
net/ipv4/tcp_minisocks.c +5 -2
@@ -102,7 +102,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,if (th->doff > (sizeof (*th) >>2 ) && tcptw->tw_ts_recent_stamp) { tmp_opt.tstamp_ok =1 ; -tcp_parse_options (skb, &tmp_opt,1 ); +tcp_parse_options (skb, &tmp_opt,1 ,NULL );if (tmp_opt.saw_tstamp) { tmp_opt.ts_recent = tcptw->tw_ts_recent;
@@ -500,10 +500,11 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,int paws_reject =0 ;struct tcp_options_received tmp_opt;struct sock *child; +struct dst_entry *dst =inet_csk_route_req (sk, req); tmp_opt.saw_tstamp =0 ;if (th->doff > (sizeof (struct tcphdr )>>2 )) { -tcp_parse_options (skb, &tmp_opt,0 ); +tcp_parse_options (skb, &tmp_opt,0 , dst);if (tmp_opt.saw_tstamp) { tmp_opt.ts_recent = req->ts_recent;
@@ -516,6 +517,8 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, } } +dst_release (dst); +/* Check for pure retransmitted SYN. */ if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn && flg == TCP_FLAG_SYN &&
net/ipv6/syncookies.c +15 -13
@@ -184,13 +184,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)NET_INC_STATS_BH (sock_net (sk),LINUX_MIB_SYNCOOKIESRECV ); -/* check for timestamp cookie support */ -memset (&tcp_opt,0 ,sizeof (tcp_opt)); -tcp_parse_options (skb, &tcp_opt,0 ); - -if (tcp_opt.saw_tstamp) -cookie_check_timestamp (&tcp_opt); - ret =NULL ; req =inet6_reqsk_alloc (&tcp6_request_sock_ops);if (!req)
@@ -224,12 +217,6 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) req->expires =0UL ; req->retrans =0 ; ireq->ecn_ok =0 ; - ireq->snd_wscale = tcp_opt.snd_wscale; - ireq->rcv_wscale = tcp_opt.rcv_wscale; - ireq->sack_ok = tcp_opt.sack_ok; - ireq->wscale_ok = tcp_opt.wscale_ok; - ireq->tstamp_ok = tcp_opt.saw_tstamp; - req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval :0 ; treq->rcv_isn =ntohl (th->seq) -1 ; treq->snt_isn = cookie;
@@ -264,6 +251,21 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) goto out_free; } +/* check for timestamp cookie support */ +memset (&tcp_opt,0 ,sizeof (tcp_opt)); +tcp_parse_options (skb, &tcp_opt,0 , dst); + +if (tcp_opt.saw_tstamp) +cookie_check_timestamp (&tcp_opt); + + req->ts_recent = tcp_opt.saw_tstamp ? tcp_opt.rcv_tsval :0 ; + + ireq->snd_wscale = tcp_opt.snd_wscale; + ireq->rcv_wscale = tcp_opt.rcv_wscale; + ireq->sack_ok = tcp_opt.sack_ok; + ireq->wscale_ok = tcp_opt.wscale_ok; + ireq->tstamp_ok = tcp_opt.saw_tstamp; + req->window_clamp = tp->window_clamp ? :dst_metric (dst,RTAX_WINDOW ); tcp_select_initial_window(tcp_full_space(sk), req->mss, &req->rcv_wnd, &req->window_clamp,
net/ipv6/tcp_ipv6.c +2 -1
@@ -1165,6 +1165,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb)struct tcp_sock *tp =tcp_sk (sk);struct request_sock *req =NULL ;__u32 isn =TCP_SKB_CB (skb)->when; +struct dst_entry *dst =__sk_dst_get (sk);#ifdef CONFIG_SYN_COOKIES int want_cookie =0 ;#else
@@ -1203,7 +1204,7 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) tmp_opt.mss_clamp =IPV6_MIN_MTU -sizeof (struct tcphdr ) -sizeof (struct ipv6hdr ); tmp_opt.user_mss = tp->rx_opt.user_mss; -tcp_parse_options (skb, &tmp_opt,0 ); +tcp_parse_options (skb, &tmp_opt,0 , dst);if (want_cookie && !tmp_opt.saw_tstamp)tcp_clear_options (&tmp_opt);
Signature · 1 line
1.5.6.3
PATCH v4 3/7 Add dst_feature to query route entry features
In reply to Gilad Ben-YossefAdding an accessor to existing dst_entry feautres field and refactor the only supported feature (allfrag) to use it.
--- include/net/dst.h | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
include/net/dst.h +7 -1
@@ -111,6 +111,12 @@ dst_metric(const struct dst_entry *dst, int metric)return dst->metrics[metric-1 ]; } +static inline u32 +dst_feature (const struct dst_entry *dst,u32 feature) +{ +return dst_metric (dst,RTAX_FEATURES ) & feature; +} +static inline u32 dst_mtu (const struct dst_entry *dst) {u32 mtu =dst_metric (dst,RTAX_MTU );
@@ -136,7 +142,7 @@ static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric,static inline u32 dst_allfrag (const struct dst_entry *dst) { -int ret =dst_metric (dst,RTAX_FEATURES ) &RTAX_FEATURE_ALLFRAG ; +int ret =dst_feature (dst,RTAX_FEATURE_ALLFRAG );/* Yes, _exactly_. This is paranoia. */ barrier ();return ret;
Signature · 1 line
1.5.6.3
PATCH v4 4/7 Add the no SACK route option feature
In reply to Gilad Ben-YossefImplement querying and acting upon the no sack bit in the features field.
--- include/linux/rtnetlink.h | 2 +- net/ipv4/tcp_input.c | 3 ++- net/ipv4/tcp_output.c | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-)
include/linux/rtnetlink.h +1 -1
@@ -377,7 +377,7 @@ enum#define RTAX_MAX (__RTAX_MAX - 1)#define RTAX_FEATURE_ECN 0x00000001 -#define RTAX_FEATURE_SACK 0x00000002 +#define RTAX_FEATURE_NO_SACK 0x00000002#define RTAX_FEATURE_TIMESTAMP 0x00000004#define RTAX_FEATURE_ALLFRAG 0x00000008
net/ipv4/tcp_input.c +2 -1
@@ -3763,7 +3763,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,break ;case TCPOPT_SACK_PERM :if (opsize ==TCPOLEN_SACK_PERM && th->syn && - !estab && sysctl_tcp_sack) { + !estab && sysctl_tcp_sack && + !dst_feature (dst,RTAX_FEATURE_NO_SACK )) { opt_rx->sack_ok =1 ;tcp_sack_reset (opt_rx); }
net/ipv4/tcp_output.c +3 -1
@@ -464,6 +464,7 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, struct tcp_md5sig_key **md5) {struct tcp_sock *tp =tcp_sk (sk);unsigned size =0 ; +struct dst_entry *dst =__sk_dst_get (sk);#ifdef CONFIG_TCP_MD5SIG *md5 = tp->af_specific->md5_lookup (sk, sk);
@@ -498,7 +499,8 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, opts->options |=OPTION_WSCALE ; size +=TCPOLEN_WSCALE_ALIGNED ; } -if (likely (sysctl_tcp_sack)) { +if (likely (sysctl_tcp_sack && + !dst_feature (dst,RTAX_FEATURE_NO_SACK ))) { opts->options |=OPTION_SACK_ADVERTISE ;if (unlikely (!(OPTION_TS & opts->options))) size +=TCPOLEN_SACKPERM_ALIGNED ;
Signature · 1 line
1.5.6.3
PATCH v4 5/7 Allow disabling TCP timestamp options per route
In reply to Gilad Ben-YossefImplement querying and acting upon the no timestamp bit in the feature field.
--- include/linux/rtnetlink.h | 2 +- net/ipv4/tcp_input.c | 3 ++- net/ipv4/tcp_output.c | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-)
include/linux/rtnetlink.h +1 -1
@@ -378,7 +378,7 @@ enum#define RTAX_FEATURE_ECN 0x00000001#define RTAX_FEATURE_NO_SACK 0x00000002 -#define RTAX_FEATURE_TIMESTAMP 0x00000004 +#define RTAX_FEATURE_NO_TSTAMP 0x00000004#define RTAX_FEATURE_ALLFRAG 0x00000008struct rta_session
net/ipv4/tcp_input.c +2 -1
@@ -3755,7 +3755,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,case TCPOPT_TIMESTAMP :if ((opsize ==TCPOLEN_TIMESTAMP ) && ((estab && opt_rx->tstamp_ok) || - (!estab && sysctl_tcp_timestamps))) { + (!estab && sysctl_tcp_timestamps && + !dst_feature (dst,RTAX_FEATURE_NO_TSTAMP )))) { opt_rx->saw_tstamp =1 ; opt_rx->rcv_tsval =get_unaligned_be32 (ptr); opt_rx->rcv_tsecr =get_unaligned_be32 (ptr +4 );
net/ipv4/tcp_output.c +6 -2
@@ -488,7 +488,9 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, opts->mss =tcp_advertise_mss (sk); size +=TCPOLEN_MSS_ALIGNED ; -if (likely (sysctl_tcp_timestamps && *md5 ==NULL )) { +if (likely (sysctl_tcp_timestamps && + !dst_feature (dst,RTAX_FEATURE_NO_TSTAMP ) && + *md5 ==NULL )) { opts->options |=OPTION_TS ; opts->tsval =TCP_SKB_CB (skb)->when; opts->tsecr = tp->rx_opt.ts_recent;
@@ -2317,7 +2319,9 @@ static void tcp_connect_init(struct sock *sk)* See tcp_input.c:tcp_rcv_state_process case TCP_SYN_SENT. */ tp->tcp_header_len =sizeof (struct tcphdr ) + - (sysctl_tcp_timestamps ?TCPOLEN_TSTAMP_ALIGNED :0 ); + (sysctl_tcp_timestamps && + (!dst_feature (dst,RTAX_FEATURE_NO_TSTAMP ) ? +TCPOLEN_TSTAMP_ALIGNED :0 ));#ifdef CONFIG_TCP_MD5SIG if (tp->af_specific->md5_lookup (sk, sk) !=NULL )
Signature · 1 line
1.5.6.3
PATCH v4 6/7 Allow to turn off TCP window scale opt per route
In reply to Gilad Ben-YossefAdd and use no window scale bit in the features field.
Note that this is not the same as setting a window scale of 0 as would happen with window limit on route.
--- include/linux/rtnetlink.h | 1 + net/ipv4/tcp_input.c | 3 ++- net/ipv4/tcp_output.c | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-)
include/linux/rtnetlink.h +1 -0
@@ -380,6 +380,7 @@ enum#define RTAX_FEATURE_NO_SACK 0x00000002#define RTAX_FEATURE_NO_TSTAMP 0x00000004#define RTAX_FEATURE_ALLFRAG 0x00000008 +#define RTAX_FEATURE_NO_WSCALE 0x00000010struct rta_session {
net/ipv4/tcp_input.c +2 -1
@@ -3739,7 +3739,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,break ;case TCPOPT_WINDOW :if (opsize ==TCPOLEN_WINDOW && th->syn && - !estab && sysctl_tcp_window_scaling) { + !estab && sysctl_tcp_window_scaling && + !dst_feature (dst,RTAX_FEATURE_NO_WSCALE )) {__u8 snd_wscale = *(__u8 *)ptr; opt_rx->wscale_ok =1 ;if (snd_wscale >14 ) {
net/ipv4/tcp_output.c +4 -2
@@ -496,7 +496,8 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, opts->tsecr = tp->rx_opt.ts_recent; size +=TCPOLEN_TSTAMP_ALIGNED ; } -if (likely (sysctl_tcp_window_scaling)) { +if (likely (sysctl_tcp_window_scaling && + !dst_feature (dst,RTAX_FEATURE_NO_WSCALE ))) { opts->ws = tp->rx_opt.rcv_wscale; opts->options |=OPTION_WSCALE ; size +=TCPOLEN_WSCALE_ALIGNED ;
@@ -2347,7 +2348,8 @@ static void tcp_connect_init(struct sock *sk) tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len -sizeof (struct tcphdr ) :0 ), &tp->rcv_wnd, &tp->window_clamp, - sysctl_tcp_window_scaling, + (sysctl_tcp_window_scaling && + !dst_feature (dst,RTAX_FEATURE_NO_WSCALE )), &rcv_wscale); tp->rx_opt.rcv_wscale = rcv_wscale;
Signature · 1 line
1.5.6.3
PATCH v4 7/7 Allow disabling of DSACK TCP option per route
In reply to Gilad Ben-YossefAdd and use no DSCAK bit in the features field.
--- include/linux/rtnetlink.h | 1 + net/ipv4/tcp_input.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
include/linux/rtnetlink.h +1 -0
@@ -381,6 +381,7 @@ enum#define RTAX_FEATURE_NO_TSTAMP 0x00000004#define RTAX_FEATURE_ALLFRAG 0x00000008#define RTAX_FEATURE_NO_WSCALE 0x00000010 +#define RTAX_FEATURE_NO_DSACK 0x00000020struct rta_session {
net/ipv4/tcp_input.c +6 -2
@@ -4080,8 +4080,10 @@ static inline int tcp_sack_extend(struct tcp_sack_block *sp, u32 seq,static void tcp_dsack_set (struct sock *sk,u32 seq,u32 end_seq) {struct tcp_sock *tp =tcp_sk (sk); +struct dst_entry *dst =__sk_dst_get (sk); -if (tcp_is_sack (tp) && sysctl_tcp_dsack) { +if (tcp_is_sack (tp) && sysctl_tcp_dsack && + !dst_feature (dst,RTAX_FEATURE_NO_DSACK )) {int mib_idx;if (before (seq, tp->rcv_nxt))
@@ -4110,13 +4112,15 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq)static void tcp_send_dupack (struct sock *sk,struct sk_buff *skb) {struct tcp_sock *tp =tcp_sk (sk); +struct dst_entry *dst =__sk_dst_get (sk);if (TCP_SKB_CB (skb)->end_seq !=TCP_SKB_CB (skb)->seq &&before (TCP_SKB_CB (skb)->seq, tp->rcv_nxt)) {NET_INC_STATS_BH (sock_net (sk),LINUX_MIB_DELAYEDACKLOST );tcp_enter_quickack_mode (sk); -if (tcp_is_sack (tp) && sysctl_tcp_dsack) { +if (tcp_is_sack (tp) && sysctl_tcp_dsack && + !dst_feature (dst,RTAX_FEATURE_NO_DSACK )) {u32 end_seq =TCP_SKB_CB (skb)->end_seq;if (after (TCP_SKB_CB (skb)->end_seq, tp->rcv_nxt))
Signature · 1 line
1.5.6.3
Quoted 46 lines · Gilad Ben-Yossef
Allow selectively turning off support for specific TCP options on a per route basis.
One normally want to disable SACK, DSACK, time stamp or window scale if one got a piece of broken networking equipment somewhere as a stop gap until you can bring a big enough hammer to deal with the broken network equipment. It doesn't make sense to "punish" the entire connections going through the machine to destinations not related to the broken equipment.
This is doubly true when one is dealing with network containers used to isolate several virtual domains.
Per route options implemented in free bits in the features route entry property, which in some cases were reserved by name for these options, so this does not inflate any structure.
Global sysctls for these options are still preserved and retain the exact original meaning (e.g. you have to have both the global sysctl turned on and not turn off the TCP option parsing in the specific route to have it proccessed).
It is not possible to turn off globally an option but turn it on per route, so as to not subtly change the meaning of current establish sysctls (and this is a rare need anyway).
Tested on x86 using Qemu/KVM.
Working but crude matching patch to iproute2 sent earlier to the list.
Patchset based on original work by Ori Finkelman and Yony Amit from ComSleep Ltd.
The author wishes to thank Eric Dumazaet, William Allen Simpson, Bill Fink and Ilpo Jarvinen for their feedback.
Gilad Ben-Yossef (7):
Only parse time stamp TCP option in time wait sock Allowtcp_parse_optionsto consult dst entry Adddst_featureto query route entry features Add the no SACK route option feature
Allow disabling TCP timestamp options per route Allow to turn off TCP window scale opt per route Allow disabling of DSACK TCP option per route
Quoted 12 lines
include/linux/rtnetlink.h | 6 ++++-- include/net/dst.h | 8 +++++++- include/net/tcp.h | 3 ++- net/ipv4/syncookies.c | 27 ++++++++++++++------------- net/ipv4/tcp_input.c | 26 ++++++++++++++++++-------- net/ipv4/tcp_ipv4.c | 21 ++++++++++++--------- net/ipv4/tcp_minisocks.c | 9 ++++++--- net/ipv4/tcp_output.c | 18 +++++++++++++----- net/ipv6/syncookies.c | 28 +++++++++++++++------------- net/ipv6/tcp_ipv6.c | 3 ++- 10 files changed, 93 insertions(+), 56 deletions(-)
I am a bit lost. What exactly changed in this new version, versus v3 ?
Quoted 59 lines · Eric Dumazet
Quoted 43 lines · Gilad Ben-Yossef
Allow selectively turning off support for specific TCP options on a per route basis.
One normally want to disable SACK, DSACK, time stamp or window scale if one got a piece of broken networking equipment somewhere as a stop gap until you can bring a big enough hammer to deal with the broken network equipment. It doesn't make sense to "punish" the entire connections going through the machine to destinations not related to the broken equipment.
This is doubly true when one is dealing with network containers used to isolate several virtual domains.
Per route options implemented in free bits in the features route entry property, which in some cases were reserved by name for these options, so this does not inflate any structure.
Global sysctls for these options are still preserved and retain the exact original meaning (e.g. you have to have both the global sysctl turned on and not turn off the TCP option parsing in the specific route to have it proccessed).
It is not possible to turn off globally an option but turn it on per route, so as to not subtly change the meaning of current establish sysctls (and this is a rare need anyway).
Tested on x86 using Qemu/KVM.
Working but crude matching patch to iproute2 sent earlier to the list.
Patchset based on original work by Ori Finkelman and Yony Amit from ComSleep Ltd.
The author wishes to thank Eric Dumazaet, William Allen Simpson, Bill Fink and Ilpo Jarvinen for their feedback.
Gilad Ben-Yossef (7):
Only parse time stamp TCP option in time wait sock Allowtcp_parse_optionsto consult dst entry Adddst_featureto query route entry features Add the no SACK route option feature
Allow disabling TCP timestamp options per route Allow to turn off TCP window scale opt per route Allow disabling of DSACK TCP option per routeQuoted 13 lines
include/linux/rtnetlink.h | 6 ++++-- include/net/dst.h | 8 +++++++- include/net/tcp.h | 3 ++- net/ipv4/syncookies.c | 27 ++++++++++++++------------- net/ipv4/tcp_input.c | 26 ++++++++++++++++++-------- net/ipv4/tcp_ipv4.c | 21 ++++++++++++--------- net/ipv4/tcp_minisocks.c | 9 ++++++--- net/ipv4/tcp_output.c | 18 +++++++++++++----- net/ipv6/syncookies.c | 28 +++++++++++++++------------- net/ipv6/tcp_ipv6.c | 3 ++- 10 files changed, 93 insertions(+), 56 deletions(-)
Quoted 3 lines
I am a bit lost. What exactly changed in this new version, versus v3 ?
Code wise only the first patch - in tcp_timewait_state_process I was calling tcp_parse_options() without actually initializing properly the tstamp_ok field of the truct tcp_options_received parameter to the that function.
I failed to noticed that since being a non initalized structure on the stack it can actually produce the required behavior depending on whatever random data was there.
I spotted it thanks to Williams A.S. review of my changes in that area.
Since I had the opportunity, I also edited the patch set description to better document some of the things that seemed to bug some of the reviewers (namely Bill F. and Williams A.S ).
Sorry for the confusion.
Thanks,
Gilad
Signature · 15 lines
Gilad Ben-Yossef Chief Coffee Drinker & CTO Codefidence Ltd. Web: http://codefidence.com Cell: +972-52-8260388 Skype: gilad_codefidence Tel: +972-8-9316883 ext. 201 Fax: +972-8-9316884 Email: [email protected] Check out our Open Source technology and training blog - http://tuxology.net "The biggest risk you can take it is to take no risk." -- Mark Zuckerberg and probably others
David Miller
maintainerFrom: Gilad Ben-Yossef <[email protected]>
Date: Wed, 28 Oct 2009 16:15:20 +0200
Quoted 2 lines
Allow selectively turning off support for specific TCP options on a per route basis.
Ok, I can live with these changes, good job.
All applied to net-next-2.6, thanks!