From nobody Fri Nov 17 22:34:00 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SXBX844XBz51RtD; Fri, 17 Nov 2023 22:34:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SXBX81h7Qz4Gmr; Fri, 17 Nov 2023 22:34:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700260440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GiBNMk7ogLj+FhjSV3Zw8Bf05aWZNbn7H4PO0LfuhpU=; b=mOiox2smsFvMe7ek7Mq/gWJgFVvuQ5dWj1J2n7jadl/hoTIIS/Uigw5WPYmkoP+mrC5I1M S3m3BRBBVyz1e9Hz8+dv+TqtUIef2OVo9sKPb+mR7/aRZaC2VV+Bd9BQEcSJTLAlypmbph gDutc1s0O0q6aqXWGM2fllG/v50XvUbG1OGZrLCNcexLSG3cjMy8j5Ug3/AGL7hj1plyPe JNv1MhtU8A9pVVDyv/FXjd/Li02x2BdFbG4kb+w4UGf2m3OOpXdEoT5a9YLEA+7kJGoF9F Plzf0srJVoj6jQtz1/t6ZKfovHAUzarBZ+Oyvo7D9F5JVDNMQ5E8fvfExxD3sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700260440; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GiBNMk7ogLj+FhjSV3Zw8Bf05aWZNbn7H4PO0LfuhpU=; b=XG0EuLsyhiuSMo7l5mRoacuxrpuYkRJmuFtK18lBRb9X9lfLY6M7KxiemYCITW49yts225 uy8x4rmV8nTlJjogLxxmvwgbVC/TNI9YiQi75rl0wz2kunksjVer5lmQXB5OEtskYLHkwo AnznNENoZ/EsKhPHFoRyiBW+4My+Yz2ArzFE8KxqBh1h++LHseNhUWng/x1lNNyqSw5uXM UH7ngxB3oSRo0LoWTl9xf0u/X8Y0X22R9aMSthuJBUP0EEzXoU90PhULTrz74vjAj8NBXe h2CTMZBA5pWyfDLph5c7JGleOIC5+/qbv56N8KXsmsxT3O3ZWbcuOiLLkcLLPw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700260440; a=rsa-sha256; cv=none; b=Bs6vLVY29KDVE9CpgOV53ykNdeYgLjiYWATPnSD4qcaOcjiID5+iPo3AXYb9s1kBLdKK/b nb77COaJa94ENCBox/2SREi+BnBgi1RwQM2RFIy43sDsABQcV9995utjiVAspQlTeO6tim XbaxM0AjzJ2U3OZQRVPB8PkZbG52F+AQxF4FXbltkm2t74QIWT/WFgraYUbJ8nY1LI1kFu FbjHpGI1KcNfwvXdWYqc6gYMhbyKS+dNo8n/mct4/k06nhQYHmDyaSsfwosBxvCane934q GHFw8CbBFJtYW/cl9dbPss3NTR6lWsMPEThC0w4Jwryt/cWjPD57cEFseiDIhw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SXBX80pDVz11xP; Fri, 17 Nov 2023 22:34:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AHMY0Ki027512; Fri, 17 Nov 2023 22:34:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AHMY0Fq027502; Fri, 17 Nov 2023 22:34:00 GMT (envelope-from git) Date: Fri, 17 Nov 2023 22:34:00 GMT Message-Id: <202311172234.3AHMY0Fq027502@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 7093414c63b0 - main - pf: sctp heartbeats confirm a connection List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7093414c63b08864dd9348f63e67b39a70c8b1be Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=7093414c63b08864dd9348f63e67b39a70c8b1be commit 7093414c63b08864dd9348f63e67b39a70c8b1be Author: Kristof Provost AuthorDate: 2023-11-17 12:52:34 +0000 Commit: Kristof Provost CommitDate: 2023-11-17 22:33:44 +0000 pf: sctp heartbeats confirm a connection When we create a new state for multihomed sctp connections (i.e. based on INIT/INIT_ACK or ASCONF parameters) the new connection will never see a COOKIE/COOKIE_ACK exchange. We should consider HEARTBEAT_ACK to be a confirmation that the connection is established. This ensures that such connections do not time out earlier than expected. MFC after: 1 week Sponsored by: Orange Business Services --- sys/net/pfvar.h | 17 ++++++++++------- sys/netpfil/pf/pf.c | 2 +- sys/netpfil/pf/pf_norm.c | 10 +++++++++- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 27992864c899..4b10190bf9ea 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1580,13 +1580,16 @@ struct pf_pdesc { #define PFDESC_SCTP_INIT 0x0001 #define PFDESC_SCTP_INIT_ACK 0x0002 #define PFDESC_SCTP_COOKIE 0x0004 -#define PFDESC_SCTP_ABORT 0x0008 -#define PFDESC_SCTP_SHUTDOWN 0x0010 -#define PFDESC_SCTP_SHUTDOWN_COMPLETE 0x0020 -#define PFDESC_SCTP_DATA 0x0040 -#define PFDESC_SCTP_ASCONF 0x0080 -#define PFDESC_SCTP_OTHER 0x0100 -#define PFDESC_SCTP_ADD_IP 0x0200 +#define PFDESC_SCTP_COOKIE_ACK 0x0008 +#define PFDESC_SCTP_ABORT 0x0010 +#define PFDESC_SCTP_SHUTDOWN 0x0020 +#define PFDESC_SCTP_SHUTDOWN_COMPLETE 0x0040 +#define PFDESC_SCTP_DATA 0x0080 +#define PFDESC_SCTP_ASCONF 0x0100 +#define PFDESC_SCTP_HEARTBEAT 0x0200 +#define PFDESC_SCTP_HEARTBEAT_ACK 0x0400 +#define PFDESC_SCTP_OTHER 0x0800 +#define PFDESC_SCTP_ADD_IP 0x1000 u_int16_t sctp_flags; u_int32_t sctp_initiate_tag; diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 082987d34b07..84bd75276af7 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -5932,7 +5932,7 @@ pf_test_state_sctp(struct pf_kstate **state, struct pfi_kkif *kif, dst->scrub->pfss_v_tag = pd->sctp_initiate_tag; } - if (pd->sctp_flags & PFDESC_SCTP_COOKIE) { + if (pd->sctp_flags & (PFDESC_SCTP_COOKIE | PFDESC_SCTP_HEARTBEAT_ACK)) { if (src->state < SCTP_ESTABLISHED) { pf_set_protostate(*state, psrc, SCTP_ESTABLISHED); (*state)->timeout = PFTM_SCTP_ESTABLISHED; diff --git a/sys/netpfil/pf/pf_norm.c b/sys/netpfil/pf/pf_norm.c index fb165cf548b0..a92462c53f15 100644 --- a/sys/netpfil/pf/pf_norm.c +++ b/sys/netpfil/pf/pf_norm.c @@ -2126,12 +2126,20 @@ pf_scan_sctp(struct mbuf *m, int ipoff, int off, struct pf_pdesc *pd, pd->sctp_flags |= PFDESC_SCTP_SHUTDOWN_COMPLETE; break; case SCTP_COOKIE_ECHO: - case SCTP_COOKIE_ACK: pd->sctp_flags |= PFDESC_SCTP_COOKIE; break; + case SCTP_COOKIE_ACK: + pd->sctp_flags |= PFDESC_SCTP_COOKIE_ACK; + break; case SCTP_DATA: pd->sctp_flags |= PFDESC_SCTP_DATA; break; + case SCTP_HEARTBEAT_REQUEST: + pd->sctp_flags |= PFDESC_SCTP_HEARTBEAT; + break; + case SCTP_HEARTBEAT_ACK: + pd->sctp_flags |= PFDESC_SCTP_HEARTBEAT_ACK; + break; case SCTP_ASCONF: pd->sctp_flags |= PFDESC_SCTP_ASCONF;