From nobody Tue Nov 12 03:28:19 2024 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 4XnX1c1JQCz5d3TP; Tue, 12 Nov 2024 03:28: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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XnX1b4J51z4611; Tue, 12 Nov 2024 03:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731382099; 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=njpqOq6FymvLfDk6XlnabkloMF5OxivD4qHGQ9KIhUE=; b=Qoi4GkiP0SPxTkJLiili6qlLVM9oOhLNQk2WZ2xLH7G2bgPpvREpikpr4E974HN4UzhKID 2Nfr9ewL3i8+LZohv6RvEsLEMlmj7VrQBXLkSryufTHDY3rb8dqAocrkOZxJVcS2SJaIJn nymr6MdSVHzIHK2MJzkHnQrpLW9hT/E3tgCLGYV9c5l9blUdl675SN7Eh4l8MxAjEBQm7g wF+0Pt6GpDMOlSfCms4McApAv4a/gXpYyq8SZLXCESq+eLskLSWkhyMeByrORa6rf0plkC BDxOpin9UchYgRRk65v3a9eecwQqgWMEYI9+6o8JXX1VXnJ6SiQ6tY7nUOydWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731382099; 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=njpqOq6FymvLfDk6XlnabkloMF5OxivD4qHGQ9KIhUE=; b=TPTxb+iW+ZOws2DsOA7jPvFfEZLKjLxIeqAxhosT7wSx9g0Co3vNowNTFq/Kfjyov7Wlns hVf1kL0OC19gj+jVVezLFX/JbJnpHWcqRPIb++MDTufkZyoP0Fevx1huuRPxAtaHSr8K5j JcnnS0NQg01vJn7tTvrZlrVK2UicQly1BGn4eek1KM7b76A/caL7o/eHc361jpb0TN8R50 s2APJZ3pGAq/Zt5FKmVNB0S0Ehj/jmah9Tj55+gmVfQN0zHHHnnAwb6GMmF+c5G1CMP/Rv 5OJOQM28+2we6qJUeB6EBq1eKnoFw6/XEQtmsY+LBmuRFPD+n2QuvEFUqjnHqw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731382099; a=rsa-sha256; cv=none; b=Gn1zkjcoUQWXQORe+VMd9kzcfh/+HP9CKSIMg/+XXv9n5gjztFydTD41ckGYqa15p+A8hZ CwFjOuRXru3dZLxs8X98iewfDHPuMb0XwohpJKMSnlWFIBeDu/EkdAh5krmaP8ybUlGtua JWNe181uu4CgycuMoW87yDxVDutFLeF2kNBcv07loASq6SKEEsjjpg7rwZEDA4le8NHG04 djf0js9H2dNgzPq0uzsIm+zBpF3hTYqJdUMeE0ysHHAY2SeNbPo0eVVkEjFUdb0buTVCS/ 6Fp5TqcCTzv7PvGWJ+SrdRjfujN1vjPFvQKP6N6aRdgwDKssYfAsxzqfpwGlQQ== 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 4XnX1b32MCzt4y; Tue, 12 Nov 2024 03:28:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AC3SJdi078167; Tue, 12 Nov 2024 03:28:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AC3SJ3u078164; Tue, 12 Nov 2024 03:28:19 GMT (envelope-from git) Date: Tue, 12 Nov 2024 03:28:19 GMT Message-Id: <202411120328.4AC3SJ3u078164@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Cy Schubert Subject: git: 3a2cb65b6e6d - main - ipfilter: Support printing of IPv6 addresses in error message 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cy X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3a2cb65b6e6dc1e71013db27ce143eb8670a1755 Auto-Submitted: auto-generated The branch main has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=3a2cb65b6e6dc1e71013db27ce143eb8670a1755 commit 3a2cb65b6e6dc1e71013db27ce143eb8670a1755 Author: Cy Schubert AuthorDate: 2024-11-08 07:39:11 +0000 Commit: Cy Schubert CommitDate: 2024-11-12 03:21:22 +0000 ipfilter: Support printing of IPv6 addresses in error message Replace inet_ntoa(3) with inet_ntop(3). This supporting the printing of IPv6 IP addresses in addition to IPv4 IP addresses in error message. MFC after: 1 week --- sbin/ipf/libipf/load_poolnode.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/sbin/ipf/libipf/load_poolnode.c b/sbin/ipf/libipf/load_poolnode.c index 0e41a3921b71..880a6cd1c681 100644 --- a/sbin/ipf/libipf/load_poolnode.c +++ b/sbin/ipf/libipf/load_poolnode.c @@ -53,11 +53,29 @@ load_poolnode(int role, char *name, ip_pool_node_t *node, int ttl, if (err != 0) { if ((opts & OPT_DONOTHING) == 0) { char msg[255]; + char ipaddr[80], mask_msg[10], mask[8]; - snprintf(msg, sizeof(msg), "%s pool(%s) node(%s/", what, - name, inet_ntoa(pn.ipn_addr.adf_addr.in4)); - strlcat(msg, inet_ntoa(pn.ipn_mask.adf_addr.in4), sizeof(msg)); - strcat(msg, ")"); + inet_ntop(pn.ipn_addr.adf_family, + pn.ipn_addr.adf_addr.vptr, ipaddr, + sizeof(ipaddr)); + +#ifdef USE_INET6 + if (pn.ipn_mask.adf_family == AF_INET) { +#endif + inet_ntop(pn.ipn_mask.adf_family, + pn.ipn_mask.adf_addr.vptr, mask, + sizeof(mask)); + mask_msg[0]='/'; + mask_msg[1]='\0'; + strlcat(mask_msg, mask, sizeof(mask_msg)); +#ifdef USE_INET6 + } else { + mask_msg[0]='\0'; + } +#endif + + snprintf(msg, sizeof(msg), "%s pool(%s) node(%s%s)", + what, name, ipaddr, mask_msg); return (ipf_perror_fd(pool_fd(), iocfunc, msg)); } }