Commit f038ac8f authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by David S. Miller

[TCP]: cleanup tcp_parse_options deep indented switch

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: default avatarIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent dbb1db8b
...@@ -3284,26 +3284,27 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, ...@@ -3284,26 +3284,27 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
length--; length--;
continue; continue;
default: default:
opsize=*ptr++; opsize = *ptr++;
if (opsize < 2) /* "silly options" */ if (opsize < 2) /* "silly options" */
return; return;
if (opsize > length) if (opsize > length)
return; /* don't parse partial options */ return; /* don't parse partial options */
switch (opcode) { switch (opcode) {
case TCPOPT_MSS: case TCPOPT_MSS:
if (opsize==TCPOLEN_MSS && th->syn && !estab) { if (opsize == TCPOLEN_MSS && th->syn && !estab) {
u16 in_mss = ntohs(get_unaligned((__be16 *)ptr)); u16 in_mss = ntohs(get_unaligned((__be16 *)ptr));
if (in_mss) { if (in_mss) {
if (opt_rx->user_mss && opt_rx->user_mss < in_mss) if (opt_rx->user_mss &&
opt_rx->user_mss < in_mss)
in_mss = opt_rx->user_mss; in_mss = opt_rx->user_mss;
opt_rx->mss_clamp = in_mss; opt_rx->mss_clamp = in_mss;
} }
} }
break; break;
case TCPOPT_WINDOW: case TCPOPT_WINDOW:
if (opsize==TCPOLEN_WINDOW && th->syn && !estab) if (opsize == TCPOLEN_WINDOW && th->syn &&
if (sysctl_tcp_window_scaling) { !estab && sysctl_tcp_window_scaling) {
__u8 snd_wscale = *(__u8 *) ptr; __u8 snd_wscale = *(__u8 *)ptr;
opt_rx->wscale_ok = 1; opt_rx->wscale_ok = 1;
if (snd_wscale > 14) { if (snd_wscale > 14) {
if (net_ratelimit()) if (net_ratelimit())
...@@ -3316,22 +3317,20 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, ...@@ -3316,22 +3317,20 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
} }
break; break;
case TCPOPT_TIMESTAMP: case TCPOPT_TIMESTAMP:
if (opsize==TCPOLEN_TIMESTAMP) { if ((opsize == TCPOLEN_TIMESTAMP) &&
if ((estab && opt_rx->tstamp_ok) || ((estab && opt_rx->tstamp_ok) ||
(!estab && sysctl_tcp_timestamps)) { (!estab && sysctl_tcp_timestamps))) {
opt_rx->saw_tstamp = 1; opt_rx->saw_tstamp = 1;
opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr)); opt_rx->rcv_tsval = ntohl(get_unaligned((__be32 *)ptr));
opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4))); opt_rx->rcv_tsecr = ntohl(get_unaligned((__be32 *)(ptr+4)));
} }
}
break; break;
case TCPOPT_SACK_PERM: case TCPOPT_SACK_PERM:
if (opsize==TCPOLEN_SACK_PERM && th->syn && !estab) { if (opsize == TCPOLEN_SACK_PERM && th->syn &&
if (sysctl_tcp_sack) { !estab && sysctl_tcp_sack) {
opt_rx->sack_ok = 1; opt_rx->sack_ok = 1;
tcp_sack_reset(opt_rx); tcp_sack_reset(opt_rx);
} }
}
break; break;
case TCPOPT_SACK: case TCPOPT_SACK:
...@@ -3351,8 +3350,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, ...@@ -3351,8 +3350,8 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx,
#endif #endif
} }
ptr+=opsize-2; ptr += opsize-2;
length-=opsize; length -= opsize;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment