From nobody Fri Feb 18 10:46:05 2022 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 AC8D619CD8AF; Fri, 18 Feb 2022 10:46:05 +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 4K0SzK3lmKz4TVS; Fri, 18 Feb 2022 10:46:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645181165; 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=D9bMS51x30sTP7r8MaBRyLQppQSxFIWLjKxDBJhXIAI=; b=EloYNptqmjUfOa4zA74ZMGliW8RsQbrvVLup2sO/oENU9nzLCK/91n9tFNRDURRyNat343 6uqxk8Hv5Q5Kcu7447f4KbkFO9yy6Dh9oV+8Y02ehZP2J7ZCZbeL0qoyW9jHN+6aNQrJpW 2p2PBVprGXgBDzc9pzfgkoggecHQ2RHBi1gmUNseGMbXNukf6j32A+RmtXbz4xtwZpBaEF JoebkqrhCClnrLdOxewY0sJI2vt9FF5c3dQ0paffHFh3hyWxvh6L/+IPxHvJ/xMQezvbHl w2S6ybbpC0EeQzLp5MUyMOCf3Ma5Y3y5dlb/9l0oKDsJZVo/4SU2C0uXirt/hg== 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 5235D1BFCF; Fri, 18 Feb 2022 10:46:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21IAk5r6043304; Fri, 18 Feb 2022 10:46:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21IAk5h0043303; Fri, 18 Feb 2022 10:46:05 GMT (envelope-from git) Date: Fri, 18 Feb 2022 10:46:05 GMT Message-Id: <202202181046.21IAk5h0043303@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: 63220460d0af - stable/13 - libpfctl: fix creatorid endianness 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: 63220460d0af381abfaddc4a203c3df21bd9719d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645181165; 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=D9bMS51x30sTP7r8MaBRyLQppQSxFIWLjKxDBJhXIAI=; b=PCWw7i7hewfoym5o2Kk0mY0/Vr+TgRRtLsCNhwUSvXWOZrhndqePmgPidPCgMYfxx7s7ZH TJSAs4kUWmQpkd8CwS45/EBYbYDqjYsej1Mq7SoNDW17+hXFnv3qwgI6/jhL910UlDoN/F EoCt0GsNUY2DpTTNBMvtSN76ZLj6itDYS7Phc5nw7ZPzfewJYzkZlbQXSLnYM9XVSJLHJX fYlfinY8PaLXk+pHdbMN8U59M+vCZFxS2PKXTjfrp1BOqvEEvmdmp7Uofe+XO4UM9ySfvN IwZiWP+C6ub6RBKV6ZdfvGDoVRDfTG4TVvoYLiDbyakezjIUUyMkRQBf7eN8sw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645181165; a=rsa-sha256; cv=none; b=aMO8Ufs+WiiXaq9c3OZwo8FPUTocL7wVz0+Regu4ni9onifdhJedvgcG+vA7QyJyCe17dW 8ShbSxH0rVUd1gGebxSnnSlJdrhpfuqirkMdn37EdJf6a55xEkeF9wtbqb5qzcEzZyrIf9 rSZpZCYhmVHKqDYwxdMNmb6v6xldC3R9ZzOo/IQbiPgPxZcV//ClxeDyAysPsCCRuktDgw l3o2KAkmSmbCYSU2RxuC/xRjOB1urQd7u4nui+jdk5qUOrSEjDoNwYM9+jBtE3VsCoFGRa NDClNXHgMy8RM4YoFh6HJ1x7yLmYZEt2vuQw/UWZ1wdPAW27EcnI1x4QxMqsqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=63220460d0af381abfaddc4a203c3df21bd9719d commit 63220460d0af381abfaddc4a203c3df21bd9719d Author: Kristof Provost AuthorDate: 2022-01-21 16:50:15 +0000 Commit: Kristof Provost CommitDate: 2022-02-18 10:14:58 +0000 libpfctl: fix creatorid endianness We provide the hostid (which is the state creatorid) to the kernel as a big endian number (see pfctl/pfctl.c pfctl_set_hostid()), so convert it back to system endianness when we get it from the kernel. This avoids a confusing mismatch between the value the user configures and the value displayed in the state. MFC after: 3 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D33989 (cherry picked from commit 735748f30aad80593e2b7f5f5f175d64484c5eeb) --- lib/libpfctl/libpfctl.c | 4 ++-- sbin/pfctl/pfctl_parser.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 9252f64969bb..e77bdee93deb 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -188,7 +188,7 @@ pfctl_get_status(int dev) status->running = nvlist_get_bool(nvl, "running"); status->since = nvlist_get_number(nvl, "since"); status->debug = nvlist_get_number(nvl, "debug"); - status->hostid = nvlist_get_number(nvl, "hostid"); + status->hostid = ntohl(nvlist_get_number(nvl, "hostid")); status->states = nvlist_get_number(nvl, "states"); status->src_nodes = nvlist_get_number(nvl, "src_nodes"); @@ -809,7 +809,7 @@ pf_state_export_to_state(struct pfctl_state *ps, const struct pf_state_export *s ps->packets[1] = s->packets[1]; ps->bytes[0] = s->bytes[0]; ps->bytes[1] = s->bytes[1]; - ps->creatorid = s->creatorid; + ps->creatorid = ntohl(s->creatorid); ps->key[0].proto = s->proto; ps->key[1].proto = s->proto; ps->key[0].af = s->af; diff --git a/sbin/pfctl/pfctl_parser.c b/sbin/pfctl/pfctl_parser.c index 8dde3c916009..8537d2933dc8 100644 --- a/sbin/pfctl/pfctl_parser.c +++ b/sbin/pfctl/pfctl_parser.c @@ -541,7 +541,7 @@ print_status(struct pfctl_status *s, struct pfctl_syncookies *cookies, int opts) } if (opts & PF_OPT_VERBOSE) { - printf("Hostid: 0x%08x\n", ntohl(s->hostid)); + printf("Hostid: 0x%08x\n", s->hostid); for (i = 0; i < PF_MD5_DIGEST_LENGTH; i++) { buf[i + i] = hex[s->pf_chksum[i] >> 4];