mirror of
https://github.com/opnsense/src.git
synced 2026-06-13 02:30:51 -04:00
netstat: restore printing the "default" keyword, provide -nn option
Avoid POLA breakage and preserve output standard that really predates the FreeBSD project itself. There are scripts in the wild that rely on the behavior. Provide option to specify -nn twice to have a completely numeric output of the routing tables. Fixes:9206c79961This reverts commite090646d6f. Reviewed by: zlei, gallatin, melifaro, allanjude, markj, emaste Differential Revision: https://reviews.freebsd.org/D48729
This commit is contained in:
parent
fe5a6266dd
commit
c2aa91745e
6 changed files with 23 additions and 16 deletions
|
|
@ -240,9 +240,9 @@ default_route_with_multiple_fibs_on_same_subnet_body()
|
|||
|
||||
# Verify that the default route exists for both fibs, with their
|
||||
# respective interfaces.
|
||||
atf_check -o match:"^0\.0\.0\.0.*${TAP0}$" \
|
||||
atf_check -o match:"^default.*${TAP0}$" \
|
||||
setfib ${FIB0} netstat -rn -f inet
|
||||
atf_check -o match:"^0\.0\.0\.0.*${TAP1}$" \
|
||||
atf_check -o match:"^default.*${TAP1}$" \
|
||||
setfib ${FIB1} netstat -rn -f inet
|
||||
}
|
||||
|
||||
|
|
@ -286,9 +286,9 @@ default_route_with_multiple_fibs_on_same_subnet_inet6_body()
|
|||
|
||||
# Verify that the default route exists for both fibs, with their
|
||||
# respective interfaces.
|
||||
atf_check -o match:"^::/0.*${TAP0}$" \
|
||||
atf_check -o match:"^default.*${TAP0}$" \
|
||||
setfib ${FIB0} netstat -rn -f inet6
|
||||
atf_check -o match:"^::/0.*${TAP1}$" \
|
||||
atf_check -o match:"^default.*${TAP1}$" \
|
||||
setfib ${FIB1} netstat -rn -f inet6
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +479,7 @@ slaac_on_nondefault_fib6_body()
|
|||
atf_check -o match:"${SUBNET}:/${MASK}.*\<U\>.*$EPAIRB" \
|
||||
netstat -rnf inet6 -F $FIB1
|
||||
# Check default route
|
||||
atf_check -o match:"^::/0.*\<UG\>.*$EPAIRB" \
|
||||
atf_check -o match:"default.*\<UG\>.*$EPAIRB" \
|
||||
netstat -rnf inet6 -F $FIB1
|
||||
|
||||
# Check that none of the above routes appeared on other routes
|
||||
|
|
|
|||
|
|
@ -163,12 +163,12 @@ ndp_slaac_default_route_body() {
|
|||
while [ -z "$(jexec ${jname} ndp -r)" ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
atf_check -o match:"^::/0[[:space:]]+fe80:" \
|
||||
atf_check -o match:"^default[[:space:]]+fe80:" \
|
||||
jexec ${jname} netstat -rn -6
|
||||
|
||||
# Get rid of the default route.
|
||||
jexec ${jname} route -6 flush
|
||||
atf_check -o not-match:"^::/0[[:space:]]+fe80:" \
|
||||
atf_check -o not-match:"^default[[:space:]]+fe80:" \
|
||||
jexec ${jname} netstat -rn -6
|
||||
|
||||
# Send another RA, make sure that the default route is installed again.
|
||||
|
|
@ -180,7 +180,7 @@ ndp_slaac_default_route_body() {
|
|||
while [ -z "$(jexec ${jname} ndp -r)" ]; do
|
||||
sleep 0.1
|
||||
done
|
||||
atf_check -o match:"^::/0[[:space:]]+fe80:" \
|
||||
atf_check -o match:"^default[[:space:]]+fe80:" \
|
||||
jexec ${jname} netstat -rn -6
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -207,8 +207,8 @@ int iflag; /* show interfaces */
|
|||
int Lflag; /* show size of listen queues */
|
||||
int mflag; /* show memory stats */
|
||||
int noutputs = 0; /* how much outputs before we exit */
|
||||
int numeric_addr; /* show addresses numerically */
|
||||
int numeric_port; /* show ports numerically */
|
||||
u_int numeric_addr = 0; /* show addresses numerically */
|
||||
bool numeric_port; /* show ports numerically */
|
||||
int Oflag; /* show nhgrp objects*/
|
||||
int oflag; /* show nexthop objects*/
|
||||
int Pflag; /* show TCP log ID */
|
||||
|
|
@ -361,7 +361,8 @@ main(int argc, char *argv[])
|
|||
nlistf = optarg;
|
||||
break;
|
||||
case 'n':
|
||||
numeric_addr = numeric_port = 1;
|
||||
numeric_addr++;
|
||||
numeric_port = true;
|
||||
break;
|
||||
case 'o':
|
||||
oflag = 1;
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd July 29, 2024
|
||||
.Dd January 29, 2025
|
||||
.Dt NETSTAT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -872,6 +872,12 @@ Normally
|
|||
.Nm
|
||||
attempts to resolve addresses and ports,
|
||||
and display them symbolically.
|
||||
Specifying
|
||||
.Fl n
|
||||
twice will also disable printing the keyword
|
||||
.Qq Dv default
|
||||
for the default IPv4 and IPv6 routes when displaying contents of routing
|
||||
tables.
|
||||
.It Fl W
|
||||
Wider output; expand address fields, etc, to avoid truncation.
|
||||
Non-numeric values such as domain names may still be truncated; use the
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ extern int iflag; /* show interfaces */
|
|||
extern int Lflag; /* show size of listen queues */
|
||||
extern int mflag; /* show memory stats */
|
||||
extern int noutputs; /* how much outputs before we exit */
|
||||
extern int numeric_addr; /* show addresses numerically */
|
||||
extern int numeric_port; /* show ports numerically */
|
||||
extern u_int numeric_addr; /* show addresses numerically */
|
||||
extern bool numeric_port; /* show ports numerically */
|
||||
extern int Pflag; /* show TCP log ID */
|
||||
extern int rflag; /* show routing tables (or routing stats) */
|
||||
extern int Rflag; /* show flowid / RSS information */
|
||||
|
|
|
|||
|
|
@ -578,7 +578,7 @@ netname4(in_addr_t in, in_addr_t mask)
|
|||
struct netent *np = 0;
|
||||
in_addr_t i;
|
||||
|
||||
if (!numeric_addr && in == INADDR_ANY && mask == 0) {
|
||||
if (numeric_addr < 2 && in == INADDR_ANY && mask == 0) {
|
||||
strlcpy(line, "default", sizeof(line));
|
||||
return (line);
|
||||
}
|
||||
|
|
@ -673,7 +673,7 @@ netname6(struct sockaddr_in6 *sa6, struct sockaddr_in6 *mask)
|
|||
else
|
||||
masklen = 128;
|
||||
|
||||
if (!numeric_addr && masklen == 0 &&
|
||||
if (numeric_addr < 2 && masklen == 0 &&
|
||||
IN6_IS_ADDR_UNSPECIFIED(&sa6->sin6_addr))
|
||||
return("default");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue