From nobody Mon Apr 1 07:34:36 2024 X-Original-To: dev-commits-src-branches@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 4V7N7d2NRrz5Fqxl; Mon, 1 Apr 2024 07:34:37 +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 4V7N7d0QZgz4kGH; Mon, 1 Apr 2024 07:34:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711956877; 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=DCELliUr/OHnQbBUgtDozNb9GJ2IxZNck/o6hfiIBzc=; b=oGXh/V6B0ggqaPBg86z50khVuF78/goFopON/aCKua5QMmw9obWb7M/xw2vRwWcNs5TSpO DSom77vvTRuTvSvL5o00gRmmJCVNe9Hu9WU4TpGrO0+DMR9biyIdLapnuiFS7/xULngG+x wTdxzN/7RUKntvgdHmURSWfo6qSWf74xDhr/C83dJQ0LybKtyk4CFt4Ce5Ci9Fd37x1wrs FCrkG2IJ7kDoNZX4veaAJRrLRAz5bWQfBggsEq+TepT2EhCszRej2salbRta71Tzv7V8OG 7DNlha9imRKTGYcc5LqgQuhYkskAoUF7JBF1IPtqrJWUhvi+w2/hOadsZFZl/Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711956877; a=rsa-sha256; cv=none; b=BAHjOxcSwDm4dTlj/FbnRhjYATiiPpup0xjKqyIx4T/p7bD92YrB16+krwSJ1TtzCggZIa yeQa4EBhtvJT9OKgJgSdc9mpfWg19UzkNxRcoP+VV8da9PRgZgpfwNX4yaseYDbTfzB2Il SCP+G45e/LqkKJeOcNXEeXQuSe5REqeYmlkNBoPqCzIB3Y2WsuowG65rJNiWi0gPdLikP1 OpY8bPyViXQ9BbpUVKyNKQl+pUW5rE9TXoXMO5yYEeMFiVeVfbR/9aNL5MdhgdACihIjL/ Nq3tpD6LQbkrKLwNhNCOPLVSskLBpSlDEqgvuH3GWm9rWMOOl0hxJSentV6mLw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711956877; 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=DCELliUr/OHnQbBUgtDozNb9GJ2IxZNck/o6hfiIBzc=; b=L8nM+lpqY99Oi1xHCs5bXevv96qvOaQ4MkD5SdhLspFSIyD2NI2wPHW+kyCDCSlR7n6OWK SprK4jFp0Ik9cfjrsK/75kcnBLWqApMCfbRHUABEDT6Lj2qf2rhQmjk9nxu7Az760CTUJp Uo+YWLVt1NmLMqm+JoSqWbK5anE7NOf0stPe/RRjy+mUIrbv41keL7lbURt3GJO5a5pwyC eujhaj6Bwfu/dOlTGzcPMihmwqyYQRA6RqQpgEAQ6NlcFvtkUuC/KQLQ64wODO4BWamnMz g2amD35Fp552MNNGU1eDN4NdzveDrBlnAbd2JQcpcxHSj9RgqdCaXz0UY0vq3Q== 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 4V7N7d02zRz1CXD; Mon, 1 Apr 2024 07:34:37 +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 4317YaXt037756; Mon, 1 Apr 2024 07:34:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4317YaQd037753; Mon, 1 Apr 2024 07:34:36 GMT (envelope-from git) Date: Mon, 1 Apr 2024 07:34:36 GMT Message-Id: <202404010734.4317YaQd037753@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: e0a58ef24a3b - stable/13 - pfsync: cope with multiple pending plus messages List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/13 X-Git-Reftype: branch X-Git-Commit: e0a58ef24a3baf5ed4cc09a798b9fe2d85408052 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=e0a58ef24a3baf5ed4cc09a798b9fe2d85408052 commit e0a58ef24a3baf5ed4cc09a798b9fe2d85408052 Author: Kristof Provost AuthorDate: 2024-03-24 15:08:52 +0000 Commit: Kristof Provost CommitDate: 2024-04-01 07:33:36 +0000 pfsync: cope with multiple pending plus messages It's possible for pfsync to add a plus message when one is already queued. Append both, rather than overwriting the already pending one. MFC after: 1 week (cherry picked from commit caccf6d3c008d3c778986734c2705cdae849a877) --- sys/netpfil/pf/if_pfsync.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c index a08a8334683a..d4d3c521a568 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -202,7 +202,7 @@ struct pfsync_bucket TAILQ_HEAD(, pfsync_upd_req_item) b_upd_req_list; TAILQ_HEAD(, pfsync_deferral) b_deferrals; u_int b_deferred; - void *b_plus; + uint8_t *b_plus; size_t b_pluslen; struct ifaltq b_snd; @@ -421,6 +421,7 @@ pfsync_clone_destroy(struct ifnet *ifp) free(b->b_plus, M_PFSYNC); b->b_plus = NULL; + b->b_pluslen = 0; callout_drain(&b->b_tmo); } @@ -1562,6 +1563,7 @@ pfsync_drop(struct pfsync_softc *sc) b->b_len = PFSYNC_MINPKT; free(b->b_plus, M_PFSYNC); b->b_plus = NULL; + b->b_pluslen = 0; } } @@ -1675,6 +1677,7 @@ pfsync_sendout(int schedswi, int c) free(b->b_plus, M_PFSYNC); b->b_plus = NULL; + b->b_pluslen = 0; } subh = (struct pfsync_subheader *)(m->m_data + offset); @@ -2289,20 +2292,28 @@ pfsync_send_plus(void *plus, size_t pluslen) { struct pfsync_softc *sc = V_pfsyncif; struct pfsync_bucket *b = &sc->sc_buckets[0]; + uint8_t *newplus; PFSYNC_BUCKET_LOCK(b); - MPASS(b->b_plus == NULL); - if (b->b_len + pluslen > sc->sc_ifp->if_mtu) pfsync_sendout(1, b->b_id); - b->b_plus = malloc(pluslen, M_PFSYNC, M_NOWAIT); - if (b->b_plus == NULL) + newplus = malloc(pluslen + b->b_pluslen, M_PFSYNC, M_NOWAIT); + if (newplus == NULL) goto out; - memcpy(b->b_plus, plus, pluslen); - b->b_len += (b->b_pluslen = pluslen); + if (b->b_plus != NULL) { + memcpy(newplus, b->b_plus, b->b_pluslen); + free(b->b_plus, M_PFSYNC); + } else { + MPASS(b->b_pluslen == 0); + } + memcpy(newplus + b->b_pluslen, plus, pluslen); + + b->b_plus = newplus; + b->b_pluslen += pluslen; + b->b_len += pluslen; pfsync_sendout(1, b->b_id);