]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow/timeout: fix TCP seq/ack for reversed flows 5680/head
authorVictor Julien <victor@inliniac.net>
Wed, 23 Dec 2020 14:55:19 +0000 (15:55 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 24 Dec 2020 08:58:16 +0000 (09:58 +0100)
When a flow is swapped it also swaps the stream trackers, so it does
not make sense to reverse them during pseudo packet creation.

(cherry picked from commit 49bd1f85b99e8bd473ae28c6eb93510b2b3c7668)

src/flow-timeout.c

index c5dafb06f8e6b175f71bc7be8f8ffbc789099c17..32063bc733bae02ee8c471c902aef3f76d25e4e3 100644 (file)
@@ -80,6 +80,7 @@ static inline Packet *FlowForceReassemblyPseudoPacketSetup(Packet *p,
                                                            Flow *f,
                                                            TcpSession *ssn)
 {
+    const int orig_dir = direction;
     p->tenant_id = f->tenant_id;
     p->datalink = DLT_RAW;
     p->proto = IPPROTO_TCP;
@@ -217,7 +218,7 @@ static inline Packet *FlowForceReassemblyPseudoPacketSetup(Packet *p,
     p->tcph->th_urp = 0;
 
     /* to server */
-    if (direction == 0) {
+    if (orig_dir == 0) {
         p->tcph->th_sport = htons(f->sp);
         p->tcph->th_dport = htons(f->dp);