Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Vijay Subramanian and committed by
David S. Miller
ab56222a 08f4fc9d

+11 -6
+5
include/linux/tcp.h
··· 238 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 + 241 246 struct tcp_options_received { 242 247 /* PAWS/RTTM data */ 243 248 long ts_recent_stamp;/* Time we stored ts_recent (for aging) */
+2 -2
include/net/tcp.h
··· 773 773 774 774 static 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 779 779 static 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 784 784 static inline unsigned int tcp_left_out(const struct tcp_sock *tp)
+1 -1
net/ipv4/syncookies.c
··· 245 245 if (!sysctl_tcp_timestamps) 246 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 249 *ecn_ok = (options >> 5) & 1; 250 250 if (*ecn_ok && !sysctl_tcp_ecn) 251 251 return false;
+3 -3
net/ipv4/tcp_input.c
··· 865 865 /* RFC3517 uses different metric in lost marker => reset on change */ 866 866 if (tcp_is_fack(tp)) 867 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 871 /* Take a notice that peer is sending D-SACKs */ 872 872 static 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 877 /* Initialize metrics on socket. */ ··· 3878 3878 case TCPOPT_SACK_PERM: 3879 3879 if (opsize == TCPOLEN_SACK_PERM && th->syn && 3880 3880 !estab && sysctl_tcp_sack) { 3881 - opt_rx->sack_ok = 1; 3881 + opt_rx->sack_ok = TCP_SACK_SEEN; 3882 3882 tcp_sack_reset(opt_rx); 3883 3883 } 3884 3884 break;