The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3ed8d5645dd42a7c080ba800cf6d25cb7e147d7e

commit 3ed8d5645dd42a7c080ba800cf6d25cb7e147d7e
Author:     Gleb Smirnoff <gleb...@freebsd.org>
AuthorDate: 2025-06-17 15:50:17 +0000
Commit:     Gleb Smirnoff <gleb...@freebsd.org>
CommitDate: 2025-06-17 15:50:17 +0000

    tcp: increase tcps_sc_recvcookie only in the syncache_expand()
    
    The syncookie_expand() is called from syncookie_cmp() in INVARIANTS mode
    to confirm that values calculated via syncookies mechanism match those
    stored in the syncache entry.  This creates a counting bug, that with
    INVARIANTS every successful use of syncache also counts as use of a
    syncookie.
    
    Reviewed by:            tuexen
    Differential Revision:  https://reviews.freebsd.org/D50897
---
 sys/netinet/tcp_syncache.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c
index 2832825f0c40..f7dfed78b0eb 100644
--- a/sys/netinet/tcp_syncache.c
+++ b/sys/netinet/tcp_syncache.c
@@ -1113,8 +1113,10 @@ syncache_expand(struct in_conninfo *inc, struct tcpopt 
*to, struct tcphdr *th,
                        goto failed;
                }
                bzero(&scs, sizeof(scs));
-               if (syncookie_expand(inc, sch, &scs, th, to, *lsop, port))
+               if (syncookie_expand(inc, sch, &scs, th, to, *lsop, port)) {
                        sc = &scs;
+                       TCPSTAT_INC(tcps_sc_recvcookie);
+               }
                if (locked)
                        SCH_UNLOCK(sch);
                if (sc == NULL) {
@@ -2344,7 +2346,6 @@ syncookie_expand(struct in_conninfo *inc, const struct 
syncache_head *sch,
 
        sc->sc_port = port;
 
-       TCPSTAT_INC(tcps_sc_recvcookie);
        return (true);
 }
 

Reply via email to