From nobody Thu Jan 27 08:08:20 2022 X-Original-To: dev-commits-src-all@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 5A6B419730AA; Thu, 27 Jan 2022 08:08:20 +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 4JktWS2743z3wH5; Thu, 27 Jan 2022 08:08:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643270900; 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=u8iGvOxRcCal72tQ0+X+nUCoM3KuchWmDCZ5Pzoudu4=; b=rO8WrgFZ9t0pcd0OJGS1Jv/lNMdccJtBnAWxZRe5h1hwDqfUvn+nlZi2aCDgY1jrW7iJSq hh24cQz4jH2gRLi9+RsN0tyGrOrIsGBKgoR54fPKuuLc1VZfRdlGOBWowgZKyCL45oal3S AwyDV85KJmOUUVMRxvfVWi0ALgwbqKvpuH8LX440ltrAw5PidPk4FHfGROlhuFVNuLTT8a 7LJVroXcey/IbBUnsKSf/9BQjEEUH6Z6B5WYDLj7+G3LUTWraP5xehasADqF6lgdjzi5kG J0RRnFp/c7EFfqiag593mlMFEll+OtYQEOe8keK0XZmqk+I2O/5ZUIkA0C/BcQ== 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 1ED8D1328A; Thu, 27 Jan 2022 08:08:20 +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 20R88KLI031162; Thu, 27 Jan 2022 08:08:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20R88KCU031161; Thu, 27 Jan 2022 08:08:20 GMT (envelope-from git) Date: Thu, 27 Jan 2022 08:08:20 GMT Message-Id: <202201270808.20R88KCU031161@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: 735748f30aad - main - libpfctl: fix creatorid endianness List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 735748f30aad80593e2b7f5f5f175d64484c5eeb Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643270900; 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=u8iGvOxRcCal72tQ0+X+nUCoM3KuchWmDCZ5Pzoudu4=; b=h3745wWwQETlgmLCdVh6VmmodKRaGmbNp4Aoffz6YJdmxfVnHWjewybfJv9IEnUZMucUA3 tcAc12VMkBg3hZMm9cAS6wwZyMXDQgxz4W5iI+UOqaXKI/wZC6uVecUxWNmvAoDRV519PC HzUklY8yliaTGmzFFrn9tCpjwVxp3znkwwfDCpFSavuMaoJTY5vFJXDyEr/qVXEZ2f4rVq vvuX0vg6FKlNmyFmip0PyaaU6vXeKSO6mQDzu6Dfh9qRCSR9fUtkikoS1a1VGqJ3iiVVs0 OT8Lguq5klGmHKPNoDp3PBaFzaojo6uRky3XIiLfujSVJ4hAgCf84M2SOakYLw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643270900; a=rsa-sha256; cv=none; b=u+xlcKfZBY+zyEtwz053Ejc+4/YhL3vBDby4mO6yBK+UhHKb1qhSL5ph519j9/Is+rPehy vscrJ5o6ndxEDg2KEExhTDtPmeKjcV/VrnmB9jHZHei/UhpHTTwjCeyH44/D8jdwhTj64g xLlTjKd1U3I1rIQDsQy4Xr3cmEFkzuuvxbgC2BIyRCWBPny9FdsA5BW6hSG79otUym6kMA caFvrrikCzP1whpVfXWp2z5bRoJ5+xvNLnedJ9C9/P8rfpyqj+5RwjoaCXAUJwLiFcSXta vNuBLKCk6YsLPhoUp3T7EaxNo6W5oxq/q1R610VYp24fFbDS33UJbDiKZZ679A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=735748f30aad80593e2b7f5f5f175d64484c5eeb commit 735748f30aad80593e2b7f5f5f175d64484c5eeb Author: Kristof Provost AuthorDate: 2022-01-21 16:50:15 +0000 Commit: Kristof Provost CommitDate: 2022-01-27 08:07:27 +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 --- 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 7d19e5bfb48f..58bae146cf6a 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"); @@ -815,7 +815,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 a9bea39a6771..5a01c30a076e 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];