]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[TCP]: cleanup tcp_parse_options deep indented switch
authorIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Fri, 4 Jan 2008 04:36:55 +0000 (20:36 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:00:33 +0000 (15:00 -0800)
Removed case indentation level & combined some nested ifs, mostly
within 80 lines now. This is a leftover from indent patch, it
just had to be done manually to avoid messing it up completely.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_input.c

index 18e099c6fa62b627c0ab0aef93c5da22a2eb22b2..fa2c85ca5bc39c32947f499ef6f531d840cc925e 100644 (file)
@@ -3278,81 +3278,80 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
                int opsize;
 
                switch (opcode) {
-                       case TCPOPT_EOL:
+               case TCPOPT_EOL:
+                       return;
+               case TCPOPT_NOP:        /* Ref: RFC 793 section 3.1 */
+                       length--;
+                       continue;
+               default:
+                       opsize = *ptr++;
+                       if (opsize < 2) /* "silly options" */
                                return;
-                       case TCPOPT_NOP:        /* Ref: RFC 793 section 3.1 */
-                               length--;
-                               continue;
-                       default:
-                               opsize=*ptr++;
-                               if (opsize < 2) /* "silly options" */
-                                       return;
-                               if (opsize > length)
-                                       return; /* don't parse partial options */
-                               switch (opcode) {
-                               case TCPOPT_MSS:
-                                       if (opsize==TCPOLEN_MSS && th->syn && !estab) {
-                                               u16 in_mss = ntohs(get_unaligned((__be16 *)ptr));
-                                               if (in_mss) {
-                                                       if (opt_rx->user_mss && opt_rx->user_mss < in_mss)
-                                                               in_mss = opt_rx->user_mss;
-                                                       opt_rx->mss_clamp = in_mss;
-                                               }
-                                       }
-                                       break;
-                               case TCPOPT_WINDOW:
-                                       if (opsize==TCPOLEN_WINDOW && th->syn && !estab)
-                                               if (sysctl_tcp_window_scaling) {
-                                                       __u8 snd_wscale = *(__u8 *) ptr;
-                                                       opt_rx->wscale_ok = 1;
-                                                       if (snd_wscale > 14) {
-                                                               if (net_ratelimit())
-                                                                       printk(KERN_INFO "tcp_parse_options: Illegal window "
-                                                                              "scaling value %d >14 received.\n",
-                                                                              snd_wscale);
-                                                               snd_wscale = 14;
-                                                       }
-                                                       opt_rx->snd_wscale = snd_wscale;
-                                               }
-                                       break;
-                               case TCPOPT_TIMESTAMP:
-                                       if (opsize==TCPOLEN_TIMESTAMP) {
-                                               if ((estab && opt_rx->tstamp_ok) ||
-                                                   (!estab && sysctl_tcp_timestamps)) {
-                                                       opt_rx->saw_tstamp = 1;
-                                                       opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr));
-                                                       opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4)));
-                                               }
+                       if (opsize > length)
+                               return; /* don't parse partial options */
+                       switch (opcode) {
+                       case TCPOPT_MSS:
+                               if (opsize == TCPOLEN_MSS && th->syn && !estab) {
+                                       u16 in_mss = ntohs(get_unaligned((__be16 *)ptr));
+                                       if (in_mss) {
+                                               if (opt_rx->user_mss &&
+                                                   opt_rx->user_mss < in_mss)
+                                                       in_mss = opt_rx->user_mss;
+                                               opt_rx->mss_clamp = in_mss;
                                        }
-                                       break;
-                               case TCPOPT_SACK_PERM:
-                                       if (opsize==TCPOLEN_SACK_PERM && th->syn && !estab) {
-                                               if (sysctl_tcp_sack) {
-                                                       opt_rx->sack_ok = 1;
-                                                       tcp_sack_reset(opt_rx);
-                                               }
+                               }
+                               break;
+                       case TCPOPT_WINDOW:
+                               if (opsize == TCPOLEN_WINDOW && th->syn &&
+                                   !estab && sysctl_tcp_window_scaling) {
+                                       __u8 snd_wscale = *(__u8 *)ptr;
+                                       opt_rx->wscale_ok = 1;
+                                       if (snd_wscale > 14) {
+                                               if (net_ratelimit())
+                                                       printk(KERN_INFO "tcp_parse_options: Illegal window "
+                                                              "scaling value %d >14 received.\n",
+                                                              snd_wscale);
+                                               snd_wscale = 14;
                                        }
-                                       break;
+                                       opt_rx->snd_wscale = snd_wscale;
+                               }
+                               break;
+                       case TCPOPT_TIMESTAMP:
+                               if ((opsize == TCPOLEN_TIMESTAMP) &&
+                                   ((estab && opt_rx->tstamp_ok) ||
+                                    (!estab && sysctl_tcp_timestamps))) {
+                                       opt_rx->saw_tstamp = 1;
+                                       opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr));
+                                       opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4)));
+                               }
+                               break;
+                       case TCPOPT_SACK_PERM:
+                               if (opsize == TCPOLEN_SACK_PERM && th->syn &&
+                                   !estab && sysctl_tcp_sack) {
+                                       opt_rx->sack_ok = 1;
+                                       tcp_sack_reset(opt_rx);
+                               }
+                               break;
 
-                               case TCPOPT_SACK:
-                                       if ((opsize >= (TCPOLEN_SACK_BASE + TCPOLEN_SACK_PERBLOCK)) &&
-                                          !((opsize - TCPOLEN_SACK_BASE) % TCPOLEN_SACK_PERBLOCK) &&
-                                          opt_rx->sack_ok) {
-                                               TCP_SKB_CB(skb)->sacked = (ptr - 2) - (unsigned char *)th;
-                                       }
-                                       break;
+                       case TCPOPT_SACK:
+                               if ((opsize >= (TCPOLEN_SACK_BASE + TCPOLEN_SACK_PERBLOCK)) &&
+                                  !((opsize - TCPOLEN_SACK_BASE) % TCPOLEN_SACK_PERBLOCK) &&
+                                  opt_rx->sack_ok) {
+                                       TCP_SKB_CB(skb)->sacked = (ptr - 2) - (unsigned char *)th;
+                               }
+                               break;
 #ifdef CONFIG_TCP_MD5SIG
-                               case TCPOPT_MD5SIG:
-                                       /*
-                                        * The MD5 Hash has already been
-                                        * checked (see tcp_v{4,6}_do_rcv()).
-                                        */
-                                       break;
+                       case TCPOPT_MD5SIG:
+                               /*
+                                * The MD5 Hash has already been
+                                * checked (see tcp_v{4,6}_do_rcv()).
+                                */
+                               break;
 #endif
-                               }
+                       }
 
-                               ptr+=opsize-2;
-                               length-=opsize;
+                       ptr += opsize-2;
+                       length -= opsize;
                }
        }
 }