We found that sometimes a restored tcp socket doesn't work. A reason of this bug is incorrect window parameters and in this case tcp_acceptable_seq() returns tcp_wnd_end(tp) instead of tp->snd_nxt. The other side drops packets with this seq, because seq is less than tp->rcv_nxt ( tcp_sequence() ). Data from a send queue is sent only if there is enough space in a window, so when we restore unacked data, we need to expand a window to fit this data. This was in a first version of this patch: "tcp: extend window to fit all restored unacked data in a send queue" Then Alexey recommended me to restore window parameters instead of adjusted them according with data in a sent queue. This sounds resonable. rcv_wnd has to be restored, because it was reported to another side and the offered window is never shrunk. One of reasons why we need to restore snd_wnd was described above.
Showing the changes to include/uapi/linux (1 of 2 files). Show all
Unified · Split
| @@ -115,12 +115,22 @@ enum { · 114 unmodified lines | ||
| 115 | 115 | #define TCP_CC_INFO 26 /* Get Congestion Control (optional) info */ |
| 116 | 116 | #define TCP_SAVE_SYN 27 /* Record SYN headers for new connections */ |
| 117 | 117 | #define TCP_SAVED_SYN 28 /* Get SYN headers recorded for connection */ |
| 118 | +#define TCP_REPAIR_WINDOW 29 /* Get/set window parameters */ | |
| 118 | 119 | |
| 119 | 120 | struct tcp_repair_opt { |
| 120 | 121 | __u32 opt_code; |
| 121 | 122 | __u32 opt_val; |
| 122 | 123 | }; |
| 123 | 124 | |
| 125 | +struct tcp_repair_window { | |
| 126 | + __u32 snd_wl1; | |
| 127 | + __u32 snd_wnd; | |
| 128 | + __u32 max_window; | |
| 129 | + | |
| 130 | + __u32 rcv_wnd; | |
| 131 | + __u32 rcv_wup; | |
| 132 | +}; | |
| 133 | + | |
| 124 | 134 | enum { |
| 125 | 135 | TCP_NO_QUEUE, |
| 126 | 136 | TCP_RECV_QUEUE, |