From nobody Mon Mar 25 04:44:52 2024 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 4V30j06RvMz5FHmK; Mon, 25 Mar 2024 04:44:52 +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 4V30j05H2fz4KYH; Mon, 25 Mar 2024 04:44:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711341892; 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=Itn5hQsQyqToGY9GF5giQpEUqrUXRJlG4bTerw4nRQI=; b=ndzbJum2Idkc0l0OHFInntg4ASWDdMZ7uaQ9qD43ieN9RA8xfUbLDY/mtnBFCiOb/svu7r nogPhWpyDatlhqWIApc9TB0FvNs7sdirC9HoC2BXWn3LjT2LRKQ/glBRsZW7mlKGA6qZSl UguYxBaCcSuAtX9nQGEeQJ3YG+t+a9ryKZFh+p3NhKXkpGCslFRMDQrIOeuuZldWQlC4x0 YeKrVJg6xNhGPzexgQYqNDsmznPFxUgMSx/fAfN6gon6jSAX5zs/UOqAeqiFKM+QHKtzND PckfPzoi5vueiuUvenxsnwS2p7lM914epjCY50+3mDg9GIp0lA8sKTtMxp6PkQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711341892; a=rsa-sha256; cv=none; b=F0KwnsUfPO//DwDbrCVwl8RqPSfXL5+URd5PrsA9uDYJyVKunOueV10+YQH45t5tFvRyx9 rvYqCWPy446DL7NWEG6PMswWEMbA1KyhO1Ai59jtl7tqTxFmqnOl2/8iIn7Em/02hxdDWF banrxoKeddg6YWgEcqe3cJUxMw0S8MLs8i0HSBBF4KIfjOjEr7ZJ0LUmdlAedUt3LlwCLC T0y8uWwlsBxkqzFOoynM4yKaoWvUy0p1TlJdN2zC0Ev4WRzI+u9NNRfLeyE4JKpuytWhwW BwzCuEaNC9HR52CzDneVK8PkZA8hdID4CVqkEeFKDHnRPyyxY3a6k+9O+oy6Mg== 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=1711341892; 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=Itn5hQsQyqToGY9GF5giQpEUqrUXRJlG4bTerw4nRQI=; b=v6XIeNCk430Kekg97OBXD4oeVPJQfgrImMXZeGooNMIJFjJNlwzbo4AFum8wLY5SW+0ssS u59GcW+AsIdg27kbzRZfAv6O2sXDkltGyoRDvPK5ziwVyB7gAvlK8zaPub4aFZnV8O4uxX DlkgS8vM6spysQCIm5x/i0+cACxrTttt4nQIPa67ZnjDCb/2nH+7D11mZSxaJRyx/04qWJ wenexXebSxtqIEWFmTkYEWHy6T5HNMx6HQXkVXmXBqb1vgudn2moWMgtNNz2QgK5bXjlmu WDmYwe8l3p0DvoLhP4DXzWT7I8N5gpcwzF0S+DaYawbMVAcD92UIKhAORxjF6A== 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 4V30j04cxGz124q; Mon, 25 Mar 2024 04:44:52 +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 42P4iqvO049848; Mon, 25 Mar 2024 04:44:52 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42P4iq44049845; Mon, 25 Mar 2024 04:44:52 GMT (envelope-from git) Date: Mon, 25 Mar 2024 04:44:52 GMT Message-Id: <202403250444.42P4iq44049845@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: caccf6d3c008 - main - pfsync: cope with multiple pending plus messages 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: caccf6d3c008d3c778986734c2705cdae849a877 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=caccf6d3c008d3c778986734c2705cdae849a877 commit caccf6d3c008d3c778986734c2705cdae849a877 Author: Kristof Provost AuthorDate: 2024-03-24 15:08:52 +0000 Commit: Kristof Provost CommitDate: 2024-03-25 04:44:24 +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 --- 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 6e43071e1d0d..c22a6a5982a9 100644 --- a/sys/netpfil/pf/if_pfsync.c +++ b/sys/netpfil/pf/if_pfsync.c @@ -239,7 +239,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; @@ -476,6 +476,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); } @@ -1771,6 +1772,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; } } @@ -1912,6 +1914,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); @@ -2565,20 +2568,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);