Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Apr 2019 02:13:15 +0000 (UTC)
From:      Rick Macklem <rmacklem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r346775 - stable/11/usr.sbin/nfsdumpstate
Message-ID:  <201904270213.x3R2DF8A098274@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rmacklem
Date: Sat Apr 27 02:13:15 2019
New Revision: 346775
URL: https://svnweb.freebsd.org/changeset/base/346775

Log:
  MFC: r346190
  Fix nfsdumpstate(8) so that it can print out INET6 callback addresses.
  
  The patch adds support for printing of INET6 callback addresses.
  It also adds the #ifdef INET, INET6 as requested by bz@.

Modified:
  stable/11/usr.sbin/nfsdumpstate/Makefile
  stable/11/usr.sbin/nfsdumpstate/nfsdumpstate.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/nfsdumpstate/Makefile
==============================================================================
--- stable/11/usr.sbin/nfsdumpstate/Makefile	Sat Apr 27 02:05:04 2019	(r346774)
+++ stable/11/usr.sbin/nfsdumpstate/Makefile	Sat Apr 27 02:13:15 2019	(r346775)
@@ -1,6 +1,15 @@
 # $FreeBSD$
 
+.include <src.opts.mk>
+
 PROG=	nfsdumpstate
 MAN=	nfsdumpstate.8
+
+.if ${MK_INET_SUPPORT} != "no"
+CFLAGS+= -DINET
+.endif
+.if ${MK_INET6_SUPPORT} != "no"
+CFLAGS+= -DINET6
+.endif
 
 .include <bsd.prog.mk>

Modified: stable/11/usr.sbin/nfsdumpstate/nfsdumpstate.c
==============================================================================
--- stable/11/usr.sbin/nfsdumpstate/nfsdumpstate.c	Sat Apr 27 02:05:04 2019	(r346774)
+++ stable/11/usr.sbin/nfsdumpstate/nfsdumpstate.c	Sat Apr 27 02:13:15 2019	(r346775)
@@ -121,13 +121,14 @@ dump_openstate(void)
 {
 	struct nfsd_dumplist dumplist;
 	int cnt, i;
+	char nbuf[INET6_ADDRSTRLEN];
 
 	dumplist.ndl_size = DUMPSIZE;
 	dumplist.ndl_list = (void *)dp;
 	if (nfssvc(NFSSVC_DUMPCLIENTS, &dumplist) < 0)
 		errx(1, "Can't perform dump clients syscall");
 
-	printf("%-13s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %-15s %s\n",
+	printf("%-13s %9.9s %9.9s %9.9s %9.9s %9.9s %9.9s %-45s %s\n",
 	    "Flags", "OpenOwner", "Open", "LockOwner",
 	    "Lock", "Deleg", "OldDeleg", "Clientaddr", "ClientID");
 	/*
@@ -143,9 +144,23 @@ dump_openstate(void)
 		    dp[cnt].ndcl_nlocks,
 		    dp[cnt].ndcl_ndelegs,
 		    dp[cnt].ndcl_nolddelegs);
-		if (dp[cnt].ndcl_addrfam == AF_INET)
-			printf("%-15s ",
+		switch (dp[cnt].ndcl_addrfam) {
+#ifdef INET
+		case AF_INET:
+			printf("%-45s ",
 			    inet_ntoa(dp[cnt].ndcl_cbaddr.sin_addr));
+			break;
+#endif
+#ifdef INET6
+		case AF_INET6:
+			if (inet_ntop(AF_INET6, &dp[cnt].ndcl_cbaddr.sin6_addr,
+			    nbuf, sizeof(nbuf)) != NULL)
+				printf("%-45s ", nbuf);
+			else
+				printf("%-45s ", " ");
+			break;
+#endif
+		}
 		for (i = 0; i < dp[cnt].ndcl_clid.nclid_idlen; i++)
 			printf("%02x", dp[cnt].ndcl_clid.nclid_id[i]);
 		printf("\n");



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