Skip to content

Commit 4f25434

Browse files
Francesco Ruggeriummakynes
authored andcommitted
netfilter: conntrack: connection timeout after re-register
If the first packet conntrack sees after a re-register is an outgoing keepalive packet with no data (SEG.SEQ = SND.NXT-1), td_end is set to SND.NXT-1. When the peer correctly acknowledges SND.NXT, tcp_in_window fails check III (Upper bound for valid (s)ack: sack <= receiver.td_end) and returns false, which cascades into nf_conntrack_in setting skb->_nfct = 0 and in later conntrack iptables rules not matching. In cases where iptables are dropping packets that do not match conntrack rules this can result in idle tcp connections to time out. v2: adjust td_end when getting the reply rather than when sending out the keepalive packet. Fixes: f94e638 ("netfilter: conntrack: reset tcp maxwin on re-register") Signed-off-by: Francesco Ruggeri <fruggeri@arista.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 79dce09 commit 4f25434

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

net/netfilter/nf_conntrack_proto_tcp.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,20 @@ static bool tcp_in_window(const struct nf_conn *ct,
541541
swin = win << sender->td_scale;
542542
sender->td_maxwin = (swin == 0 ? 1 : swin);
543543
sender->td_maxend = end + sender->td_maxwin;
544-
/*
545-
* We haven't seen traffic in the other direction yet
546-
* but we have to tweak window tracking to pass III
547-
* and IV until that happens.
548-
*/
549-
if (receiver->td_maxwin == 0)
544+
if (receiver->td_maxwin == 0) {
545+
/* We haven't seen traffic in the other
546+
* direction yet but we have to tweak window
547+
* tracking to pass III and IV until that
548+
* happens.
549+
*/
550550
receiver->td_end = receiver->td_maxend = sack;
551+
} else if (sack == receiver->td_end + 1) {
552+
/* Likely a reply to a keepalive.
553+
* Needed for III.
554+
*/
555+
receiver->td_end++;
556+
}
557+
551558
}
552559
} else if (((state->state == TCP_CONNTRACK_SYN_SENT
553560
&& dir == IP_CT_DIR_ORIGINAL)

0 commit comments

Comments
 (0)