Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 Apr 2019 02:34:10 +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-10@freebsd.org
Subject:   svn commit: r346778 - stable/10/usr.sbin/nfsdumpstate
Message-ID:  <201904270234.x3R2YAJn009211@repo.freebsd.org>

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

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/10/usr.sbin/nfsdumpstate/Makefile
  stable/10/usr.sbin/nfsdumpstate/nfsdumpstate.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/nfsdumpstate/Makefile
==============================================================================
--- stable/10/usr.sbin/nfsdumpstate/Makefile	Sat Apr 27 02:33:49 2019	(r346777)
+++ stable/10/usr.sbin/nfsdumpstate/Makefile	Sat Apr 27 02:34:10 2019	(r346778)
@@ -1,6 +1,15 @@
 # $FreeBSD$
 
+.include <bsd.own.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/10/usr.sbin/nfsdumpstate/nfsdumpstate.c
==============================================================================
--- stable/10/usr.sbin/nfsdumpstate/nfsdumpstate.c	Sat Apr 27 02:33:49 2019	(r346777)
+++ stable/10/usr.sbin/nfsdumpstate/nfsdumpstate.c	Sat Apr 27 02:34:10 2019	(r346778)
@@ -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?201904270234.x3R2YAJn009211>