aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChangli Gao <xiaosuo@gmail.com>2010-06-12 10:01:43 -0400
committerDavid S. Miller <davem@davemloft.net>2010-06-15 14:56:19 -0400
commita3433f35a55f7604742cae620c6dc6edfc70db6a (patch)
tree4ce6d169e402c03a48319a9db4055cc31df00d42
parentf350a0a87374418635689471606454abc7beaa3a (diff)
tcp: unify tcp flag macros
unify tcp flag macros: TCPHDR_FIN, TCPHDR_SYN, TCPHDR_RST, TCPHDR_PSH, TCPHDR_ACK, TCPHDR_URG, TCPHDR_ECE and TCPHDR_CWR. TCBCB_FLAG_* are replaced with the corresponding TCPHDR_*. Signed-off-by: Changli Gao <xiaosuo@gmail.com> ---- include/net/tcp.h | 24 ++++++------- net/ipv4/tcp.c | 8 ++-- net/ipv4/tcp_input.c | 2 - net/ipv4/tcp_output.c | 59 ++++++++++++++++----------------- net/netfilter/nf_conntrack_proto_tcp.c | 32 ++++++----------- net/netfilter/xt_TCPMSS.c | 4 -- 6 files changed, 58 insertions(+), 71 deletions(-) Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/tcp.h24
-rw-r--r--net/ipv4/tcp.c8
-rw-r--r--net/ipv4/tcp_input.c2
-rw-r--r--net/ipv4/tcp_output.c59
-rw-r--r--net/netfilter/nf_conntrack_proto_tcp.c32
-rw-r--r--net/netfilter/xt_TCPMSS.c4
6 files changed, 58 insertions, 71 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 573166484413..9e68e25c8b82 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -602,6 +602,17 @@ extern u32 __tcp_select_window(struct sock *sk);
602 */ 602 */
603#define tcp_time_stamp ((__u32)(jiffies)) 603#define tcp_time_stamp ((__u32)(jiffies))
604 604
605#define tcp_flag_byte(th) (((u_int8_t *)th)[13])
606
607#define TCPHDR_FIN 0x01
608#define TCPHDR_SYN 0x02
609#define TCPHDR_RST 0x04
610#define TCPHDR_PSH 0x08
611#define TCPHDR_ACK 0x10
612#define TCPHDR_URG 0x20
613#define TCPHDR_ECE 0x40
614#define TCPHDR_CWR 0x80
615
605/* This is what the send packet queuing engine uses to pass 616/* This is what the send packet queuing engine uses to pass
606 * TCP per-packet control information to the transmission 617 * TCP per-packet control information to the transmission
607 * code. We also store the host-order sequence numbers in 618 * code. We also store the host-order sequence numbers in
@@ -620,19 +631,6 @@ struct tcp_skb_cb {
620 __u32 end_seq; /* SEQ + FIN + SYN + datalen */ 631 __u32 end_seq; /* SEQ + FIN + SYN + datalen */
621 __u32 when; /* used to compute rtt's */ 632 __u32 when; /* used to compute rtt's */
622 __u8 flags; /* TCP header flags. */ 633 __u8 flags; /* TCP header flags. */
623
624 /* NOTE: These must match up to the flags byte in a
625 * real TCP header.
626 */
627#define TCPCB_FLAG_FIN 0x01
628#define TCPCB_FLAG_SYN 0x02
629#define TCPCB_FLAG_RST 0x04
630#define TCPCB_FLAG_PSH 0x08
631#define TCPCB_FLAG_ACK 0x10
632#define TCPCB_FLAG_URG 0x20
633#define TCPCB_FLAG_ECE 0x40
634#define TCPCB_FLAG_CWR 0x80
635
636 __u8 sacked; /* State flags for SACK/FACK. */ 634 __u8 sacked; /* State flags for SACK/FACK. */
637#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */ 635#define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */
638#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */ 636#define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 49d0d2b8900c..779d40c3b96e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -511,7 +511,7 @@ int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg)
511 511
512static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb) 512static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb)
513{ 513{
514 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_PSH; 514 TCP_SKB_CB(skb)->flags |= TCPHDR_PSH;
515 tp->pushed_seq = tp->write_seq; 515 tp->pushed_seq = tp->write_seq;
516} 516}
517 517
@@ -527,7 +527,7 @@ static inline void skb_entail(struct sock *sk, struct sk_buff *skb)
527 527
528 skb->csum = 0; 528 skb->csum = 0;
529 tcb->seq = tcb->end_seq = tp->write_seq; 529 tcb->seq = tcb->end_seq = tp->write_seq;
530 tcb->flags = TCPCB_FLAG_ACK; 530 tcb->flags = TCPHDR_ACK;
531 tcb->sacked = 0; 531 tcb->sacked = 0;
532 skb_header_release(skb); 532 skb_header_release(skb);
533 tcp_add_write_queue_tail(sk, skb); 533 tcp_add_write_queue_tail(sk, skb);
@@ -815,7 +815,7 @@ new_segment:
815 skb_shinfo(skb)->gso_segs = 0; 815 skb_shinfo(skb)->gso_segs = 0;
816 816
817 if (!copied) 817 if (!copied)
818 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_PSH; 818 TCP_SKB_CB(skb)->flags &= ~TCPHDR_PSH;
819 819
820 copied += copy; 820 copied += copy;
821 poffset += copy; 821 poffset += copy;
@@ -1061,7 +1061,7 @@ new_segment:
1061 } 1061 }
1062 1062
1063 if (!copied) 1063 if (!copied)
1064 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_PSH; 1064 TCP_SKB_CB(skb)->flags &= ~TCPHDR_PSH;
1065 1065
1066 tp->write_seq += copy; 1066 tp->write_seq += copy;
1067 TCP_SKB_CB(skb)->end_seq += copy; 1067 TCP_SKB_CB(skb)->end_seq += copy;
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 548d575e6cc6..04334661fa28 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3286,7 +3286,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets,
3286 * connection startup slow start one packet too 3286 * connection startup slow start one packet too
3287 * quickly. This is severely frowned upon behavior. 3287 * quickly. This is severely frowned upon behavior.
3288 */ 3288 */
3289 if (!(scb->flags & TCPCB_FLAG_SYN)) { 3289 if (!(scb->flags & TCPHDR_SYN)) {
3290 flag |= FLAG_DATA_ACKED; 3290 flag |= FLAG_DATA_ACKED;
3291 } else { 3291 } else {
3292 flag |= FLAG_SYN_ACKED; 3292 flag |= FLAG_SYN_ACKED;
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index b4ed957f201a..51d316dbb058 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -294,9 +294,9 @@ static u16 tcp_select_window(struct sock *sk)
294/* Packet ECN state for a SYN-ACK */ 294/* Packet ECN state for a SYN-ACK */
295static inline void TCP_ECN_send_synack(struct tcp_sock *tp, struct sk_buff *skb) 295static inline void TCP_ECN_send_synack(struct tcp_sock *tp, struct sk_buff *skb)
296{ 296{
297 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_CWR; 297 TCP_SKB_CB(skb)->flags &= ~TCPHDR_CWR;
298 if (!(tp->ecn_flags & TCP_ECN_OK)) 298 if (!(tp->ecn_flags & TCP_ECN_OK))
299 TCP_SKB_CB(skb)->flags &= ~TCPCB_FLAG_ECE; 299 TCP_SKB_CB(skb)->flags &= ~TCPHDR_ECE;
300} 300}
301 301
302/* Packet ECN state for a SYN. */ 302/* Packet ECN state for a SYN. */
@@ -306,7 +306,7 @@ static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb)
306 306
307 tp->ecn_flags = 0; 307 tp->ecn_flags = 0;
308 if (sysctl_tcp_ecn == 1) { 308 if (sysctl_tcp_ecn == 1) {
309 TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE | TCPCB_FLAG_CWR; 309 TCP_SKB_CB(skb)->flags |= TCPHDR_ECE | TCPHDR_CWR;
310 tp->ecn_flags = TCP_ECN_OK; 310 tp->ecn_flags = TCP_ECN_OK;
311 } 311 }
312} 312}
@@ -361,7 +361,7 @@ static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u8 flags)
361 skb_shinfo(skb)->gso_type = 0; 361 skb_shinfo(skb)->gso_type = 0;
362 362
363 TCP_SKB_CB(skb)->seq = seq; 363 TCP_SKB_CB(skb)->seq = seq;
364 if (flags & (TCPCB_FLAG_SYN | TCPCB_FLAG_FIN)) 364 if (flags & (TCPHDR_SYN | TCPHDR_FIN))
365 seq++; 365 seq++;
366 TCP_SKB_CB(skb)->end_seq = seq; 366 TCP_SKB_CB(skb)->end_seq = seq;
367} 367}
@@ -820,7 +820,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
820 tcb = TCP_SKB_CB(skb); 820 tcb = TCP_SKB_CB(skb);
821 memset(&opts, 0, sizeof(opts)); 821 memset(&opts, 0, sizeof(opts));
822 822
823 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) 823 if (unlikely(tcb->flags & TCPHDR_SYN))
824 tcp_options_size = tcp_syn_options(sk, skb, &opts, &md5); 824 tcp_options_size = tcp_syn_options(sk, skb, &opts, &md5);
825 else 825 else
826 tcp_options_size = tcp_established_options(sk, skb, &opts, 826 tcp_options_size = tcp_established_options(sk, skb, &opts,
@@ -843,7 +843,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
843 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | 843 *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) |
844 tcb->flags); 844 tcb->flags);
845 845
846 if (unlikely(tcb->flags & TCPCB_FLAG_SYN)) { 846 if (unlikely(tcb->flags & TCPHDR_SYN)) {
847 /* RFC1323: The window in SYN & SYN/ACK segments 847 /* RFC1323: The window in SYN & SYN/ACK segments
848 * is never scaled. 848 * is never scaled.
849 */ 849 */
@@ -866,7 +866,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
866 } 866 }
867 867
868 tcp_options_write((__be32 *)(th + 1), tp, &opts); 868 tcp_options_write((__be32 *)(th + 1), tp, &opts);
869 if (likely((tcb->flags & TCPCB_FLAG_SYN) == 0)) 869 if (likely((tcb->flags & TCPHDR_SYN) == 0))
870 TCP_ECN_send(sk, skb, tcp_header_size); 870 TCP_ECN_send(sk, skb, tcp_header_size);
871 871
872#ifdef CONFIG_TCP_MD5SIG 872#ifdef CONFIG_TCP_MD5SIG
@@ -880,7 +880,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
880 880
881 icsk->icsk_af_ops->send_check(sk, skb); 881 icsk->icsk_af_ops->send_check(sk, skb);
882 882
883 if (likely(tcb->flags & TCPCB_FLAG_ACK)) 883 if (likely(tcb->flags & TCPHDR_ACK))
884</