]> git.karo-electronics.de Git - linux-beck.git/commitdiff
tcp: Replace constants with #define macros
authorVijay Subramanian <subramanian.vijay@gmail.com>
Tue, 20 Dec 2011 13:23:24 +0000 (13:23 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Dec 2011 06:03:23 +0000 (01:03 -0500)
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>
include/linux/tcp.h
include/net/tcp.h
net/ipv4/syncookies.c
net/ipv4/tcp_input.c

index 7f59ee94698336fb32be6985e9f791d8b5149dfc..46a85c9e1f25bebddd3a1887b30fb182dcf5b5e4 100644 (file)
@@ -238,6 +238,11 @@ struct tcp_sack_block {
        u32     end_seq;
 };
 
+/*These are used to set the sack_ok field in struct tcp_options_received */
+#define TCP_SACK_SEEN     (1 << 0)   /*1 = peer is SACK capable, */
+#define TCP_FACK_ENABLED  (1 << 1)   /*1 = FACK is enabled locally*/
+#define TCP_DSACK_SEEN    (1 << 2)   /*1 = DSACK was received from peer*/
+
 struct tcp_options_received {
 /*     PAWS/RTTM data  */
        long    ts_recent_stamp;/* Time we stored ts_recent (for aging) */
index a4f52e154843758949169d5e69809d8dc050105a..0118ea999f67a882f6e4e389aa9f2b685e571955 100644 (file)
@@ -773,12 +773,12 @@ static inline int tcp_is_reno(const struct tcp_sock *tp)
 
 static inline int tcp_is_fack(const struct tcp_sock *tp)
 {
-       return tp->rx_opt.sack_ok & 2;
+       return tp->rx_opt.sack_ok & TCP_FACK_ENABLED;
 }
 
 static inline void tcp_enable_fack(struct tcp_sock *tp)
 {
-       tp->rx_opt.sack_ok |= 2;
+       tp->rx_opt.sack_ok |= TCP_FACK_ENABLED;
 }
 
 static inline unsigned int tcp_left_out(const struct tcp_sock *tp)
index 90f6544c13e287639ae2d7686a55dc8f6c9cd168..51fdbb490437a565e7d9d89397295fddb28da34e 100644 (file)
@@ -245,7 +245,7 @@ bool cookie_check_timestamp(struct tcp_options_received *tcp_opt, bool *ecn_ok)
        if (!sysctl_tcp_timestamps)
                return false;
 
-       tcp_opt->sack_ok = (options >> 4) & 0x1;
+       tcp_opt->sack_ok = (options & (1 << 4)) ? TCP_SACK_SEEN : 0;
        *ecn_ok = (options >> 5) & 1;
        if (*ecn_ok && !sysctl_tcp_ecn)
                return false;
index f131d92d25ee23dd0cf2e40503bd0c049ddb1712..2877c3e0958777dff87612bb7c057df451f5b57a 100644 (file)
@@ -865,13 +865,13 @@ static void tcp_disable_fack(struct tcp_sock *tp)
        /* RFC3517 uses different metric in lost marker => reset on change */
        if (tcp_is_fack(tp))
                tp->lost_skb_hint = NULL;
-       tp->rx_opt.sack_ok &= ~2;
+       tp->rx_opt.sack_ok &= ~TCP_FACK_ENABLED;
 }
 
 /* Take a notice that peer is sending D-SACKs */
 static void tcp_dsack_seen(struct tcp_sock *tp)
 {
-       tp->rx_opt.sack_ok |= 4;
+       tp->rx_opt.sack_ok |= TCP_DSACK_SEEN;
 }
 
 /* Initialize metrics on socket. */
@@ -3878,7 +3878,7 @@ void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *o
                        case TCPOPT_SACK_PERM:
                                if (opsize == TCPOLEN_SACK_PERM && th->syn &&
                                    !estab && sysctl_tcp_sack) {
-                                       opt_rx->sack_ok = 1;
+                                       opt_rx->sack_ok = TCP_SACK_SEEN;
                                        tcp_sack_reset(opt_rx);
                                }
                                break;