PERFORCE change 164328 for review

Gabor Pali pgj at FreeBSD.org
Sun Jun 14 12:01:21 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=164328

Change 164328 by pgj at petymeg-current on 2009/06/14 12:01:11

	- Fix up some small problems with querying active connections
	- Add a "fixme" note about lazy domain/port name resolution

Affected files ...

.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#30 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#9 edit

Differences ...

==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#30 (text+ko) ====

@@ -205,6 +205,12 @@
 		    )
 			continue;
 
+#ifdef INET6
+		if ((family == PF_INET && ((inp->inp_vflag & INP_IPV4) == 0)) ||
+		    (family == PF_INET6 && ((inp->inp_vflag & INP_IPV6) == 0)))
+			continue;
+#endif
+
 		if ((flags & NETSTAT_SOCKET_ALL) == 0 &&
 		    (
 		     (protocol == IPPROTO_TCP && tp->t_state == TCPS_LISTEN)
@@ -461,7 +467,7 @@
 		else
 			NPCB_SCT(inet, domain, protocol, list, flags);
 		break;
-	/* All PF_INET */
+	/* All PF_INET, PF_INET6 */
 	case 0:
 		/* Errors do not count here. */
 		if (use_kvm) {
@@ -703,6 +709,7 @@
 #endif
 }
 
+/* XXX: Add support for "lazy" domain and port name resolution. */
 struct addr_type *
 extract_inet_address(int type, const char *proto, struct in_addr *in,
     u_short port, int anonport)
@@ -758,6 +765,7 @@
 	return (result);
 }
 
+/* XXX: Add support for "lazy" domain and port name resolution. */
 struct addr_type *
 extract_inet6_address(int type, const char *proto, struct in6_addr *in,
     u_short port)

==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#9 (text+ko) ====

@@ -561,14 +561,6 @@
 		printproto(tp, tp->pr_name);
 		exit(0);
 	}
-	if (af == AF_INET)
-		for (tp = protox; tp->pr_name; tp++)
-			printproto(tp, tp->pr_name);
-#ifdef INET6
-	if (af == AF_INET6)
-		for (tp = ip6protox; tp->pr_name; tp++)
-			printproto(tp, tp->pr_name);
-#endif /*INET6*/
 #ifdef IPSEC
 	if (af == PF_KEY || af == AF_UNSPEC)
 		for (tp = pfkeyprotox; tp->pr_name; tp++)
@@ -590,7 +582,11 @@
 #endif /* NETGRAPH */
 	if (af == AF_UNIX && !sflag)
 		unixpr(kvmd);
-	if (af == AF_UNSPEC) {
+	if (af == AF_UNSPEC || af == AF_INET
+#ifdef INET6
+	    || af == AF_INET6
+#endif 
+	    ) {
 		stlp = netstat_stl_alloc();
 		if (stlp == NULL) {
 			warn("netstat_stl_alloc");
@@ -605,7 +601,7 @@
 		 * There should be guaranteed that sockets are not mixed (i.e.
 		 * they are coming ordered by family/protocol).
 		 */
-		if (netstat_socket(PF_UNSPEC, 0, 0, stlp, st_flags,
+		if (netstat_socket(af, 0, 0, stlp, st_flags,
 		    kvmd) < 0) {
 			error = netstat_stl_geterror(stlp);
 			if (error == NETSTAT_ERROR_KVM)


More information about the p4-projects mailing list