usr.bin/netstat: -n should not print symbolic names
Some checks are pending
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-14, /usr/lib/llvm-14/bin, ubuntu-22.04, bmake libarchive-dev clang-14 lld-14, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /opt/homebrew/opt/llvm@18/bin, macos-latest, bmake libarchive llvm@18, arm64, aarch64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, amd64, amd64) (push) Waiting to run
Cross-build Kernel / ${{ matrix.target_arch }} ${{ matrix.os }} (${{ matrix.compiler }}) (clang-18, /usr/lib/llvm-18/bin, ubuntu-24.04, bmake libarchive-dev clang-18 lld-18, arm64, aarch64) (push) Waiting to run

In numeric mode, the default route is printed as "default" rather
than 0.0.0.0/0 or ::/0

From the man page:
"-n: Show network addresses and ports as numbers.
Normally netstat attempts to resolve addresses and ports, and display
them symbolically.  If the -n option is specified, the address is
printed numerically, according to the address family.
For more information regarding the Internet IPv4 ``dot format'', refer
to inet(3).  Unspecified, or `wildcard'', addresses and ports appear
as `*''."

Reported By:	rgrimes
Reviewed by:	emaste, ngie, eadler, seanc
Relnotes:	yes
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D10320
This commit is contained in:
Allan Jude 2024-11-26 14:54:04 +00:00
parent 6d77827b96
commit 9206c79961

View File

@ -578,7 +578,7 @@ netname4(in_addr_t in, in_addr_t mask)
struct netent *np = 0;
in_addr_t i;
if (in == INADDR_ANY && mask == 0) {
if (!numeric_addr && in == INADDR_ANY && mask == 0) {
strlcpy(line, "default", sizeof(line));
return (line);
}
@ -673,7 +673,8 @@ netname6(struct sockaddr_in6 *sa6, struct sockaddr_in6 *mask)
else
masklen = 128;
if (masklen == 0 && IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr))
if (!numeric_addr && masklen == 0 &&
IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr))
return("default");
getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, nline, sizeof(nline),