Hello,
during reading the tcp code of linux, I found an oddity:
In some (but not all) functions dealing with the "write_seq" field of a "struct tcp_sock", if this field ever was to be set as 0, it is actually set as 1.
Examples are:
* http://lxr.linux.no/source/net/ipv4/tcp_ipv4.c#L593 :
if ((tp->write_seq = tw->tw_snd_nxt + 65535 + 2) == 0) tp->write_seq = 1;
* http://lxr.linux.no/source/net/ipv4/tcp.c#L1821 :
if ((tp->write_seq += tp->max_window + 2) == 0) tp->write_seq = 1;
But this kind of changing numbers changes the result of the calculation of "how much data is still unsent", as in
* http://lxr.linux.no/source/net/ipv4/tcp.c#L452 :
case SIOCOUTQ: if (sk->sk_state == TCP_LISTEN) return -EINVAL;
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) answ = 0; else answ = tp->write_seq - tp->snd_una; break;
* http://lxr.linux.no/source/net/ipv4/tcp_diag.c#L155
r->tcpdiag_wqueue = tp->write_seq - tp->snd_una;
So I ask: Is this a bug or a feature? Why is sometimes "tp->write_seq==1" allowed and sometimes not?
ciao, Xuân.
- : send the line "unsubscribe linux-net" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html