From nobody Mon Nov 06 13:52:24 2023 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 4SPCTP0Qqsz50tMK; Mon, 6 Nov 2023 13:52:25 +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 4SPCTN729Rz4tdV; Mon, 6 Nov 2023 13:52:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699278745; 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=Xt+ua9Ng88vlamPov+kRH/VlB+wAdghUdkLvSBSzVLQ=; b=o23SdNQ07h6BQHm+ACmFp9I6vKbF57OsZijs+ivnW6h1136sjT6ApYRO8VZk1cednLk6Nt L1fVVx2aPrgkUJO5wVo48uzLmo1qTapHT/FFNiZRgNwPOkA8r7Px8f7ExZFbXuI6vZQxNg fSJEg+KMzUJ1ntlYu687SLswNEFgtXoyCHDZhvoLwzLhY1WK/fLUDmGMRzlsw2VlEH7EEv fFz1eydFYK1aRFlcTxPNanwf43UO8INu+WembmSNNMBeOWXn4qbWQf4hHrDZCB+4ZkY2AZ YeVTZJdgfE/YdhwoSjFYBmTARgdOvs6qrSEnt1HZ4luLJi05DleHyLkTgPYECw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1699278745; 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=Xt+ua9Ng88vlamPov+kRH/VlB+wAdghUdkLvSBSzVLQ=; b=DfYC04bks+erL+FJGiqfOhjqhFWm3mJVUPJzwhfnEtfobuQfivxzaVnYCa2YXXo/g5mDdO yookHUAgzyCEZ19f2ywvxET2MFtb+GtROZwGX8CJgMz8CmaV8U019N4t5JyZ8yjNaIr163 uj3oAOcEopoezQh5k4H38rlOc0TyQRUSUEbUqQJX9jtWM6IjppWJsOoY2enTg2QEi0tK59 Aw+zxpRDWi/iH7+0dLiFPPzhmU2N+slinGsJX893nwM2pKKzfRRhzD0V6tCR/VgOftI+QJ EB6B6mLQhhhs7idSy90bEsxPNILVK8HLyIFT6lO/shrn3S+MqJkYV1Fe5t7UZw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1699278745; a=rsa-sha256; cv=none; b=KZZenWv3AZllggdIXaXzRNf8yEwLfhn4QmB22bb6rTbLNR/dlKtg8owijT69cdAmI+wjgS 7wQTjVv6ZK3Xmoli2E27IJhtI+XAR/nHVdJHpus57PRNHHTX0LJVlDOcyquuNN5GQRmYrD Sm9JUhtRJEJUtIIVCVCZ8F4WBJs8N7U9LWjdA5wXNY9KhZ7D3s+C9/Fnk3L0IuykSc8rqU 1tE60vtX14QgKKG1ej+T9CfT2BrrJTBG9L+5Efm3c0uD+5VoEaIdcUKElAWNoawCoBHqNp nv9f4ODHFuYEA+SC9zaD1kOJ5VME36pmBiG8eYZcvBpF+WFR9vmnozia5KhqPQ== 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 4SPCTN67Chz18Jp; Mon, 6 Nov 2023 13:52:24 +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 3A6DqOV5070883; Mon, 6 Nov 2023 13:52:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3A6DqOsx070880; Mon, 6 Nov 2023 13:52:24 GMT (envelope-from git) Date: Mon, 6 Nov 2023 13:52:24 GMT Message-Id: <202311061352.3A6DqOsx070880@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: 497ccc21ef93 - main - libpfctl: handle the 'pfctl' netlink family not being supported 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: 497ccc21ef9378f92e30867fa2b473759fd64b45 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=497ccc21ef9378f92e30867fa2b473759fd64b45 commit 497ccc21ef9378f92e30867fa2b473759fd64b45 Author: Kristof Provost AuthorDate: 2023-11-06 10:57:35 +0000 Commit: Kristof Provost CommitDate: 2023-11-06 12:53:56 +0000 libpfctl: handle the 'pfctl' netlink family not being supported If we fail to find the pfctl family we should not attempt to make the call. That means that either pf is not loaded, or it's a very old (i.e. pre-netlink) version. Reported by: manu Sponsored by: Rubicon Communications, LLC ("Netgate") --- lib/libpfctl/libpfctl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/libpfctl/libpfctl.c b/lib/libpfctl/libpfctl.c index 1554b81acf59..12b7c1df7ee8 100644 --- a/lib/libpfctl/libpfctl.c +++ b/lib/libpfctl/libpfctl.c @@ -189,6 +189,8 @@ pfctl_startstop(int start) snl_init(&ss, NETLINK_GENERIC); family_id = snl_get_genl_family(&ss, PFNL_FAMILY_NAME); + if (family_id == 0) + return (ENOTSUP); snl_init_writer(&ss, &nw); hdr = snl_create_genl_msg_request(&nw, family_id, @@ -1077,6 +1079,8 @@ pfctl_add_rule(int dev __unused, const struct pfctl_rule *r, const char *anchor, snl_init(&ss, NETLINK_GENERIC); family_id = snl_get_genl_family(&ss, PFNL_FAMILY_NAME); + if (family_id == 0) + return (ENOTSUP); snl_init_writer(&ss, &nw); hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_ADDRULE); @@ -1213,6 +1217,9 @@ pfctl_get_creators_nl(struct snl_state *ss, uint32_t *creators, size_t *len) struct nlmsghdr *hdr; struct snl_writer nw; + if (family_id == 0) + return (ENOTSUP); + snl_init_writer(ss, &nw); hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GETCREATORS); hdr->nlmsg_flags |= NLM_F_DUMP; @@ -1363,6 +1370,9 @@ pfctl_get_states_nl(struct pfctl_state_filter *filter, struct snl_state *ss, pfc struct nlmsghdr *hdr; struct snl_writer nw; + if (family_id == 0) + return (ENOTSUP); + snl_init_writer(ss, &nw); hdr = snl_create_genl_msg_request(&nw, family_id, PFNL_CMD_GETSTATES); hdr->nlmsg_flags |= NLM_F_DUMP;