Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jun 2009 13:42:43 GMT
From:      Gabor Pali <pgj@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 163782 for review
Message-ID:  <200906081342.n58DghxM039508@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=163782

Change 163782 by pgj@petymeg-current on 2009/06/08 13:41:51

	Add pcb, vnode, conn, refs, reflink

Affected files ...

.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#7 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.h#10 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#7 edit
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_util.c#9 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/unix.c#9 edit

Differences ...

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

@@ -3,6 +3,8 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
+#include <sys/un.h>
+#include <sys/unpcb.h>
 #include <err.h>
 #include <errno.h>
 #include <kvm.h>
@@ -26,7 +28,7 @@
 	{ .n_name = NULL },
 };
 
-static void extract_xsocket_data(struct xsocket *, struct socket_type *);
+static void extract_xunpcb_data(struct xunpcb *, struct socket_type *);
 
 static const char *const socktype[] =
     { "#0", "stream", "dgram", "raw", "rdm", "seqpacket" }; 
@@ -69,7 +71,7 @@
 		if (xunp->xu_unp.unp_gencnt <= oxug->xug_gen) {
 			stp = _netstat_st_allocate(list, PF_LOCAL, type,
 			    socktype[type]);
-			extract_xsocket_data(&xunp->xu_socket, stp);
+			extract_xunpcb_data(xunp, stp);
 			stp->xup = *((struct xunpcb *)xug);
 		}
 	}
@@ -147,7 +149,7 @@
 		sotoxsocket(&so, &xu.xu_socket);
 		stp = _netstat_st_allocate(list, PF_LOCAL, type,
 		    socktype[type]);
-		extract_xsocket_data(&xu.xu_socket, stp);
+		extract_xunpcb_data(&xu, stp);
 		stp->xup = xu;
 	}
 
@@ -221,11 +223,17 @@
 }
 
 void
-extract_xsocket_data(struct xsocket *xso, struct socket_type *stp)
+extract_xunpcb_data(struct xunpcb *xpcb, struct socket_type *stp)
 {
-	stp->st_qlen = xso->so_qlen;
-	stp->st_incqlen = xso->so_incqlen;
-	stp->st_qlimit = xso->so_qlimit;
-	stp->st_snd_cc = xso->so_snd.sb_cc;
-	stp->st_rcv_cc = xso->so_rcv.sb_cc;
+	stp->st_qlen = xpcb->xu_socket.so_qlen;
+	stp->st_incqlen = xpcb->xu_socket.so_incqlen;
+	stp->st_qlimit = xpcb->xu_socket.so_qlimit;
+	stp->st_snd_cc = xpcb->xu_socket.so_snd.sb_cc;
+	stp->st_rcv_cc = xpcb->xu_socket.so_rcv.sb_cc;
+	stp->st_pcb = (long)xpcb->xu_socket.so_pcb;
+	stp->st_vnode = (long)xpcb->xu_unp.unp_vnode;
+	stp->st_conn = (long)xpcb->xu_unp.unp_conn;
+	stp->st_refs = (long)LIST_FIRST(&xpcb->xu_unp.unp_refs);
+	stp->st_reflink = (long)LIST_NEXT(&xpcb->xu_unp, unp_reflink);
+	stp->st_flags = SOCKTYPE_VNODE | SOCKTYPE_CONN | SOCKTYPE_REFS;
 }

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

@@ -59,9 +59,14 @@
 u_short		netstat_st_get_qlen(const struct socket_type *stp);
 u_short		netstat_st_get_incqlen(const struct socket_type *stp);
 u_short		netstat_st_get_qlimit(const struct socket_type *stp);
+long		netstat_st_get_pcb(const struct socket_type *stp);
+long		netstat_st_get_vnode(const struct socket_type *stp);
+long		netstat_st_get_conn(const struct socket_type *stp);
+long		netstat_st_get_refs(const struct socket_type *stp);
+long		netstat_st_get_reflink(const struct socket_type *stp);
 
 /* XXX: Remove this hack :) */
-void		*netstat_st_get_pcb(const struct socket_type *stp);
+void		*XXX_netstat_st_get_pcb(const struct socket_type *stp);
 
 __END_DECLS
 

==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat_internal.h#7 (text+ko) ====

@@ -35,6 +35,11 @@
 	u_short		st_incqlen; /* number of unaccepted incomplete
 				       connections */
 	u_short		st_qlimit;  /* max number queued connections */
+	long		st_pcb;	    /* protocol control block */
+	long		st_vnode;   /* if associated with file */
+	long		st_conn;    /* control block of connected socket */
+	long		st_refs;    /* referencing socket linked list */
+	long		st_reflink; /* link in references list */
 
 	/* Mixed properties, needed for different reasons, to be refined
 	 * continuously.
@@ -45,6 +50,11 @@
 	LIST_ENTRY(socket_type) st_list;
 };
 
+/* Internal flags for socket_type: */
+#define	SOCKTYPE_VNODE		0x01	/* Associated with a file. */
+#define SOCKTYPE_CONN		0x02	/* Has a control block connected. */
+#define SOCKTYPE_REFS		0x04	/* Has socket references. */
+
 struct socket_type_list {
 	LIST_HEAD(, socket_type)    stl_list;
 	int			    stl_error;

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

@@ -282,9 +282,39 @@
 	return (stp->st_qlimit);
 }
 
+long
+netstat_st_get_pcb(const struct socket_type *stp)
+{
+	return (stp->st_pcb);
+}
+
+long
+netstat_st_get_vnode(const struct socket_type *stp)
+{
+	return (stp->st_vnode);
+}
+
+long
+netstat_st_get_conn(const struct socket_type *stp)
+{
+	return (stp->st_conn);
+}
+
+long
+netstat_st_get_refs(const struct socket_type *stp)
+{
+	return (stp->st_refs); 
+}
+
+long
+netstat_st_get_reflink(const struct socket_type *stp)
+{
+	return (stp->st_reflink);
+}
+
 /* XXX: hack alert :) */
 void *
-netstat_st_get_pcb(const struct socket_type *stp)
+XXX_netstat_st_get_pcb(const struct socket_type *stp)
 {
 	return (void *)(&stp->xup);
 }

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

@@ -133,7 +133,7 @@
 	struct xunpcb *xunp;
 	struct xsocket *so;
 
-	xunp = netstat_st_get_pcb(stp);
+	xunp = XXX_netstat_st_get_pcb(stp);
 	so = &xunp->xu_socket;
 	unp = &xunp->xu_unp;
 	if (unp->unp_addr)
@@ -159,14 +159,10 @@
 		printf("unix  %-14.14s", buf1);
 	} else {
 		printf("%8lx %-6.6s %6u %6u %8lx %8lx %8lx %8lx",
-		    (long)so->so_pcb,
-		    netstat_st_get_name(stp),
-		    netstat_st_get_rcv_cc(stp),
-		    netstat_st_get_snd_cc(stp),
-		    (long)unp->unp_vnode,
-		    (long)unp->unp_conn,
-		    (long)LIST_FIRST(&unp->unp_refs),
-		    (long)LIST_NEXT(unp, unp_reflink));
+		    netstat_st_get_pcb(stp), netstat_st_get_name(stp),
+		    netstat_st_get_rcv_cc(stp), netstat_st_get_snd_cc(stp),
+		    netstat_st_get_vnode(stp), netstat_st_get_conn(stp),
+		    netstat_st_get_refs(stp), netstat_st_get_reflink(stp));
 	}
 	if (sa)
 		printf(" %.*s",



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