Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Nov 2019 13:20:24 +0000 (UTC)
From:      Mike Karels <karels@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r355029 - stable/12/usr.bin/netstat
Message-ID:  <201911231320.xANDKOf0022543@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: karels
Date: Sat Nov 23 13:20:24 2019
New Revision: 355029
URL: https://svnweb.freebsd.org/changeset/base/355029

Log:
  MFC r354633:
  
  Fix netstat -gs with ip_mroute module and/or vnet
  
  The code for "netstat -gs -f inet" failed if the kernel namelist did not
  include the _mrtstat symbol. However, that symbol is not in a standard
  kernel even with the ip_mroute module loaded, where the functionality is
  available. It is also not in a kernel with MROUTING but also VIMAGE, as
  there can be multiple sets of stats. However, when running the command
  on a live system, the symbol is not used; a sysctl is used. Go ahead
  and try the sysctl in any case, and complain that IPv4 MROUTING is not
  present only if the sysctl fails with ENOENT. Also fail if _mrtstat is
  not defined when running on a core file; netstat doesn't know about vnets,
  so can only work if MROUTING was included, and VIMAGE was not.
  
  Reviewed by:    bz

Modified:
  stable/12/usr.bin/netstat/mroute.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/netstat/mroute.c
==============================================================================
--- stable/12/usr.bin/netstat/mroute.c	Sat Nov 23 07:06:16 2019	(r355028)
+++ stable/12/usr.bin/netstat/mroute.c	Sat Nov 23 13:20:24 2019	(r355029)
@@ -409,14 +409,12 @@ mrt_stats()
 
 	mstaddr = nl[N_MRTSTAT].n_value;
 
-	if (mstaddr == 0) {
-		fprintf(stderr, "No IPv4 MROUTING kernel support.\n");
-		return;
-	}
-
 	if (fetch_stats("net.inet.ip.mrtstat", mstaddr, &mrtstat,
-	    sizeof(mrtstat), kread_counters) != 0)
+	    sizeof(mrtstat), kread_counters) != 0) {
+		if ((live && errno == ENOENT) || (!live && mstaddr == 0))
+			fprintf(stderr, "No IPv4 MROUTING kernel support.\n");
 		return;
+	}
 
 	xo_emit("{T:IPv4 multicast forwarding}:\n");
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911231320.xANDKOf0022543>