PERFORCE change 163987 for review
Gabor Pali
pgj at FreeBSD.org
Wed Jun 10 13:16:18 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163987
Change 163987 by pgj at petymeg-current on 2009/06/10 13:16:11
Add support for extracting only valid (properly flagged) tcp
connections
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#15 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#7 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#15 (text+ko) ====
@@ -149,11 +149,21 @@
if (so->xso_protocol != protocol)
continue;
- if (inp->inp_gencnt <= oxig->xig_gen) {
- stp = _netstat_st_allocate(list, PF_INET, protocol,
- ipproto[protocol]);
- extract_inet_data(tp, inp, so, stp);
- }
+ /* Keep active PCBs only. */
+ if (inp->inp_gencnt > oxig->xig_gen)
+ continue;
+
+ /* Not a valid IPv4/IPv6 connection. */
+ if (((inp->inp_vflag & INP_IPV4) == 0)
+#ifdef INET6
+ && ((inp->inp_vflag & INP_IPV6) == 0)
+#endif
+ )
+ continue;
+
+ stp = _netstat_st_allocate(list, PF_INET, protocol,
+ ipproto[protocol]);
+ extract_inet_data(tp, inp, so, stp);
}
free(buf);
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#7 (text+ko) ====
@@ -623,17 +623,6 @@
tp = XXX_netstat_st_get_tcpcb(stp);
istcp = 1;
}
- if ((netstat_st_get_family(stp) == AF_INET && (inp.inp_vflag & INP_IPV4) == 0)
-#ifdef INET6
- || (netstat_st_get_family(stp) == AF_INET6 && (inp.inp_vflag & INP_IPV6) == 0)
-#endif /* INET6 */
- || (netstat_st_get_family(stp) == AF_UNSPEC && ((inp.inp_vflag & INP_IPV4) == 0
-#ifdef INET6
- && (inp.inp_vflag & INP_IPV6) == 0
-#endif /* INET6 */
- ))
- )
- return;
if (!aflag &&
(
(istcp && netstat_st_get_listening(stp))
More information about the p4-projects
mailing list