Why "tp->write_seq = 1"?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux