svn commit: r217215 - projects/ofed/head/usr.bin/netstat

Jeff Roberson jeff at FreeBSD.org
Mon Jan 10 03:55:46 UTC 2011


Author: jeff
Date: Mon Jan 10 03:55:45 2011
New Revision: 217215
URL: http://svn.freebsd.org/changeset/base/217215

Log:
   - Treat SDP like TCP as it uses the same states and most of the same
     pcb variables.
  
  Sponsored by:	Isilon Systems, iX Systems, and Panasas.

Modified:
  projects/ofed/head/usr.bin/netstat/Makefile
  projects/ofed/head/usr.bin/netstat/inet.c
  projects/ofed/head/usr.bin/netstat/main.c

Modified: projects/ofed/head/usr.bin/netstat/Makefile
==============================================================================
--- projects/ofed/head/usr.bin/netstat/Makefile	Mon Jan 10 03:48:41 2011	(r217214)
+++ projects/ofed/head/usr.bin/netstat/Makefile	Mon Jan 10 03:55:45 2011	(r217215)
@@ -18,6 +18,10 @@ SRCS+=	inet6.c
 CFLAGS+=-DINET6
 .endif
 
+.if ${MK_OFED} != "no"
+CFLAGS+=-DSDP
+.endif
+
 BINGRP=	kmem
 BINMODE=2555
 DPADD=	${LIBKVM} ${LIBMEMSTAT} ${LIBUTIL}

Modified: projects/ofed/head/usr.bin/netstat/inet.c
==============================================================================
--- projects/ofed/head/usr.bin/netstat/inet.c	Mon Jan 10 03:48:41 2011	(r217214)
+++ projects/ofed/head/usr.bin/netstat/inet.c	Mon Jan 10 03:55:45 2011	(r217215)
@@ -85,11 +85,11 @@ __FBSDID("$FreeBSD$");
 char	*inetname(struct in_addr *);
 void	inetprint(struct in_addr *, int, const char *, int);
 #ifdef INET6
-static int udp_done, tcp_done;
+static int udp_done, tcp_done, sdp_done;
 #endif /* INET6 */
 
 static int
-pcblist_sysctl(int proto, char **bufp, int istcp)
+pcblist_sysctl(int proto, const char *name, char **bufp, int istcp)
 {
 	const char *mibvar;
 	char *buf;
@@ -109,7 +109,8 @@ pcblist_sysctl(int proto, char **bufp, i
 		mibvar = "net.inet.raw.pcblist";
 		break;
 	}
-
+	if (strncmp(name, "sdp", 3) == 0)
+		mibvar = "net.inet.sdp.pcblist";
 	len = 0;
 	if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
 		if (errno != ENOENT)
@@ -315,10 +316,17 @@ protopr(u_long off, const char *name, in
 	switch (proto) {
 	case IPPROTO_TCP:
 #ifdef INET6
-		if (tcp_done != 0)
-			return;
-		else
-			tcp_done = 1;
+		if (strncmp(name, "sdp", 3) != 0) {
+			if (tcp_done != 0)
+				return;
+			else
+				tcp_done = 1;
+		} else {
+			if (sdp_done != 0)
+				return;
+			else
+				sdp_done = 1;
+		}
 #endif
 		istcp = 1;
 		break;
@@ -332,7 +340,7 @@ protopr(u_long off, const char *name, in
 		break;
 	}
 	if (live) {
-		if (!pcblist_sysctl(proto, &buf, istcp))
+		if (!pcblist_sysctl(proto, name, &buf, istcp))
 			return;
 	} else {
 		if (!pcblist_kvm(off, &buf, istcp))
@@ -355,12 +363,18 @@ protopr(u_long off, const char *name, in
 		}
 
 		/* Ignore sockets for protocols other than the desired one. */
-		if (so->xso_protocol != proto)
+		if (so->xso_protocol != proto) {
+			printf("%s proto %d, proto %d\n",
+			    name,  so->xso_protocol, proto);
 			continue;
+		}
 
 		/* Ignore PCBs which were freed during copyout. */
-		if (inp->inp_gencnt > oxig->xig_gen)
+		if (inp->inp_gencnt > oxig->xig_gen) {
+			printf("%s gencnt %jd, xig gen %jd\n",
+			    name, inp->inp_gencnt, oxig->xig_gen);
 			continue;
+		}
 
 		if ((af1 == AF_INET && (inp->inp_vflag & INP_IPV4) == 0)
 #ifdef INET6

Modified: projects/ofed/head/usr.bin/netstat/main.c
==============================================================================
--- projects/ofed/head/usr.bin/netstat/main.c	Mon Jan 10 03:48:41 2011	(r217214)
+++ projects/ofed/head/usr.bin/netstat/main.c	Mon Jan 10 03:55:45 2011	(r217215)
@@ -208,6 +208,10 @@ struct protox {
 	{ -1,		N_SCTPSTAT,	1,	sctp_protopr,
 	  sctp_stats,	NULL,		"sctp",	1,	IPPROTO_SCTP },
 #endif
+#ifdef SDP
+	{ -1,		-1,		1,	protopr,
+	 NULL,		NULL,		"sdp",	1,	IPPROTO_TCP },
+#endif
 	{ N_DIVCBINFO,	-1,		1,	protopr,
 	  NULL,		NULL,		"divert", 1,	IPPROTO_DIVERT },
 	{ N_RIPCBINFO,	N_IPSTAT,	1,	protopr,
@@ -248,6 +252,10 @@ struct protox ip6protox[] = {
 	  ip6_stats,	ip6_ifstats,	"ip6",	1,	IPPROTO_RAW },
 	{ N_RIPCBINFO,	N_ICMP6STAT,	1,	protopr,
 	  icmp6_stats,	icmp6_ifstats,	"icmp6", 1,	IPPROTO_ICMPV6 },
+#ifdef SDP
+	{ -1,		-1,		1,	protopr,
+	 NULL,		NULL,		"sdp",	1,	IPPROTO_TCP },
+#endif
 #ifdef IPSEC
 	{ -1,		N_IPSEC6STAT,	1,	NULL,
 	  ipsec_stats,	NULL,		"ipsec6", 0,	0 },


More information about the svn-src-projects mailing list