aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVijay Subramanian <subramanian.vijay@gmail.com>2011-12-20 08:23:24 -0500
committerDavid S. Miller <davem@davemloft.net>2011-12-21 01:03:23 -0500
commitab56222a32b9dbaae19c1d37f07b0ac4fc3c27ec (patch)
treece5eff7879a1d80c419835171de13e52c24afdfb
parent08f4fc9da9a04d59f5c937e06e375158abb68206 (diff)
tcp: Replace constants with #define macros
to record the state of SACK/FACK and DSACK for better readability and maintenance. Signed-off-by: Vijay Subramanian <subramanian.vijay@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/tcp.h5
-rw-r--r--include/net/tcp.h4
-rw-r--r--net/ipv4/syncookies.c2
-rw-r--r--net/ipv4/tcp_input.c6
4 files changed, 11 insertions, 6 deletions
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 7f59ee94698..46a85c9e1f2 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -238,6 +238,11 @@ struct tcp_sack_block {
238 u32 end_seq; 238 u32 end_seq;
239}; 239};
240 240
241/*These are used to set the sack_ok field in struct tcp_options_received */
242#define TCP_SACK_SEEN (1 << 0) /*1 = peer is SACK capable, */
243#define TCP_FACK_ENABLED (1 << 1) /*1 = FACK is enabled locally*/
244#define TCP_DSACK_SEEN (1 << 2) /*1 = DSACK was received from peer*/
245
241struct tcp_options_received { 246struct tcp_options_received {
242/* PAWS/RTTM data */ 247/* PAWS/RTTM data */
243 long ts_recent_stamp;/* Time we stored ts_recent (for aging) */ 248 long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
diff --git a/include/net/tcp.h b/include/net/tcp.h
index a4f52e15484..0118ea999f6 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -773,12 +773,12 @@ static inline int tcp_is_reno(const struct tcp_sock *tp)
773 773
774static inline int tcp_is_fack(const struct tcp_sock *tp) 774static inline int tcp_is_fack(const struct tcp_sock *tp)
775{ 775{
776 return tp->rx_opt.sack_ok & 2; 776 return tp->rx_opt.sack_ok & TCP_FACK_ENABLED;
777} 777}
778 778
779static inline void tcp_enable_fack(struct tcp_sock *tp) 779static inline void tcp_enable_fack(struct tcp_sock *tp)
780{ 780{
781 tp->rx_opt.sack_ok |= 2; 781 tp->rx_opt.sack_ok |= TCP_FACK_ENABLED;
782} 782}
783 783
784static inline unsigned int tcp_left_out(const struct tcp_sock *tp) 784static inline unsigned int tcp_left_out(const struct tcp_sock *tp)
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index 90f6544c13e..51fdbb49043 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -245,7 +245,7 @@ bool cookie_check_timestamp(struct tcp_options_received *tcp_opt, bool *ecn_ok)
245 if (!sysctl_tcp_timestamps) 245 if (!sysctl_tcp_timestamps)
246 return false; 246 return false;
247 247
248 tcp_opt->sack_ok = (options >> 4) & 0x1; 248 tcp_opt->sack_ok = (options & (1 << 4)) ? TCP_SACK_SEEN : 0;
249 *ecn_ok = (options >> 5) & 1; 249 *ecn_ok = (options >> 5) & 1;
250 if (*ecn_ok && !sysctl_tcp_ecn) 250 if (*ecn_ok && !sysctl_tcp_ecn)
251 return false; 251 return false;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index f131d92d25e..2877c3e0958 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -865,13 +865,13 @@ static void tcp_disable_fack(struct tcp_sock *tp)
865 /* RFC3517 uses different metric in lost marker => reset on change */ 865 /* RFC3517 uses different metric in lost marker => reset on change */
866 if (tcp_is_fack(tp)) 866 if (tcp_is_fack(tp))
867 tp->lost_skb_hint = NULL; 867 tp->lost_skb_hint = NULL;
868 tp->rx_opt.sack_ok &= ~2; 868 tp->rx_opt.sack_ok &= ~TCP_FACK_ENABLED;
869} 869}
870 870
871/* Take a notice that peer is sending D-SACKs */ 871/* Take a notice that peer is sending D-SACKs */
872static void tcp_dsack_seen(struct tcp_sock *tp) 872static void tcp_dsack_seen(struct tcp_sock *tp)
873{ 873{
874 tp->rx_opt.sack_ok |= 4; 874 tp->rx_opt.sack_ok |= TCP_DSACK_SEEN;
875} 875}
876 876
877/* Initialize metrics on socket. */ 877/* Initialize metrics on socket. */
@@ -3878,7 +3878,7 @@ void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *o
3878 case TCPOPT_SACK_PERM: 3878 case TCPOPT_SACK_PERM:
3879 if (opsize == TCPOLEN_SACK_PERM && th->syn && 3879 if (opsize == TCPOLEN_SACK_PERM && th->syn &&
3880 !estab && sysctl_tcp_sack) { 3880 !estab && sysctl_tcp_sack) {
3881 opt_rx->sack_ok = 1; 3881 opt_rx->sack_ok = TCP_SACK_SEEN;
3882 tcp_sack_reset(opt_rx); 3882 tcp_sack_reset(opt_rx);
3883 } 3883 }
3884 break; 3884 break;