From nobody Mon Mar 07 13:35:23 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 B1D7E19F9BD5; Mon, 7 Mar 2022 13:35:23 +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 4KBzwq2zr1z4sJs; Mon, 7 Mar 2022 13:35:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646660123; 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=TEtBGVOItC+1G14T1A/FBz7Xhs5Lal5yTqh+mU8xSzU=; b=p7c5+/aBH/KsN8cYPkT52sjQ8329CcSOgI2cvebpAXHRcEYHwsoGAuTIzVIkQylQrAjZH3 4IPS0OSc0wK/MBVwqmXxC1agB3Hd4Rzv3Gr1rrz8E8hYY7BKBiPrJb/1XqvNE6l6x1xP6f mZ96lMC1eXXKyaIhxSTVTbbazO9hggGdwr/jnG8wTW+Ouojdm96BUvbw1PUw+wti4Td1cZ qnATo/Cl2XGZ7yVk8OefH05po55WVP4/qH4H7F8gYqZPs9n649MGC6ZsWUpjOLcRDhcphL F8cNV0UzdiYAyB+2umcyoL80iH1z3gcsoefQKJ7BxEb+IY9Eiji/VxAoHZ1q7Q== 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 23F351167; Mon, 7 Mar 2022 13:35:23 +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 227DZNWN073387; Mon, 7 Mar 2022 13:35:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 227DZNYs073386; Mon, 7 Mar 2022 13:35:23 GMT (envelope-from git) Date: Mon, 7 Mar 2022 13:35:23 GMT Message-Id: <202203071335.227DZNYs073386@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Cy Schubert Subject: git: 8fbffd0b04fc - stable/12 - ipfilter: Print protocol when listing NAT table mappings 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: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8fbffd0b04fc59d3ed547c03c132c45d0d77bea7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646660123; 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=TEtBGVOItC+1G14T1A/FBz7Xhs5Lal5yTqh+mU8xSzU=; b=BzabsScEDDzj9jJT+Xgb1kkauy9FASw/VOHkg5UAvnf/xSm6SQKfy2zyMwJ9z3gLl1N4jh uBkJAwBljWS+syRwSwKG/nhqhT7RmESbSfHSF/OKWCHVsoOJ5mvIWNK/ksoVjIVPQtlBqO KEDBymjaOx+koYgzadghyaH52H6ndT2APP2wI/2AQQuxE/AwpfAsh9rtedoYOERP0f5oAt mkwC0UhBL6qLdgygxyieORu+Ey9RoFcH3XT4FKfkTHZV0N0HmO6/XGnKtfgGbHj5na0GAd ykv/CpPc+VtPaPJpZkavpx3T1gCdAXGJBP4lgco7VnY88S2xpQ9fNOl+wKCqGg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646660123; a=rsa-sha256; cv=none; b=x25mS/LXXJHeqZXjTuUSpKm0ewKGDp8Nby8IFxDK8C6iDvFYseq5KdSOUTZwhb1DICHRl9 0R4ZZ9F2t/LgbfA31xWTq/59NlvE80TVPcDS+Trs0ugy8VjTfWhlrR8JqOeJnSMxyLE29B GkXIcND6SQ/WMzZJGtseoDnFQQrDPLMvD1lHA780C7TZtiW7BF/ZynI4SfLGci2K9JnHpO a4mjUwZzheGAPLoQPmgt8LroFxvyZAAIExC8XsUqDGFUaqMS7hDPvJcuhPFJH/73xh82Cp M/3Eoz5bpOwW9gma5ZyylgrNTHrEVDJ66e3o4va1KxtIX/sToQlyW/+TeNX3yw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=8fbffd0b04fc59d3ed547c03c132c45d0d77bea7 commit 8fbffd0b04fc59d3ed547c03c132c45d0d77bea7 Author: Cy Schubert AuthorDate: 2022-02-28 19:43:33 +0000 Commit: Cy Schubert CommitDate: 2022-03-07 13:34:56 +0000 ipfilter: Print protocol when listing NAT table mappings NAT table mappings list only the source and destination IP, the source and destinaion port numbers, and their mappings. But the protocol is not listed. Now that Facebook and Google use QUIC, seeing port 443 in in a list of active NAT sessions could mean 443/tcp or 443/udp. This patch adds the protocol to the listing to aid in determining whether HTTPS is TCP or QUIC in a NAT mapping listing. This also helps differentiatinete between other protocols such as ICMP, ESP, and AH in ipnat list of active sessions. (cherry picked from commit 9291d079d54b828b43d3714a5f19f0ffe92837b8) --- sbin/ipf/libipf/printactivenat.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sbin/ipf/libipf/printactivenat.c b/sbin/ipf/libipf/printactivenat.c index fcef19a4efa7..3a6337ab0f7b 100644 --- a/sbin/ipf/libipf/printactivenat.c +++ b/sbin/ipf/libipf/printactivenat.c @@ -15,10 +15,17 @@ static const char rcsid[] = "@(#)$Id$"; #endif +static int proto_opened = 0; void printactivenat(nat_t *nat, int opts, u_long ticks) { + struct protoent *pproto; + + if (proto_opened == 0) { + proto_opened = 1; + setprotoent(1); + } PRINTF("%s", getnattype(nat)); @@ -55,6 +62,9 @@ printactivenat(nat_t *nat, int opts, u_long ticks) if ((nat->nat_flags & IPN_TCPUDP) != 0) PRINTF(" %-5hu", ntohs(nat->nat_ndport)); + pproto = getprotobynumber(nat->nat_pr[0]); + PRINTF(" %s", pproto->p_name); + } else if (nat->nat_dir == NAT_OUTBOUND) { printactiveaddress(nat->nat_v[0], "%-15s", &nat->nat_osrc6, nat->nat_ifnames[0]); @@ -76,6 +86,9 @@ printactivenat(nat_t *nat, int opts, u_long ticks) if ((nat->nat_flags & IPN_TCPUDP) != 0) PRINTF(" %hu", ntohs(nat->nat_odport)); PRINTF("]"); + + pproto = getprotobynumber(nat->nat_pr[1]); + PRINTF(" %s", pproto->p_name); } else { printactiveaddress(nat->nat_v[1], "%-15s", &nat->nat_ndst6, nat->nat_ifnames[0]); @@ -97,8 +110,12 @@ printactivenat(nat_t *nat, int opts, u_long ticks) if ((nat->nat_flags & IPN_TCPUDP) != 0) PRINTF(" %hu", ntohs(nat->nat_osport)); PRINTF("]"); + + pproto = getprotobynumber(nat->nat_pr[0]); + PRINTF(" %s", pproto->p_name); } + if (opts & OPT_VERBOSE) { PRINTF("\n\tttl %lu use %hu sumd %s/", nat->nat_age - ticks, nat->nat_use,