Date: Wed, 10 Jun 2009 13:16:17 GMT From: Gabor Pali <pgj@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 163987 for review Message-ID: <200906101316.n5ADGHFw064174@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=163987 Change 163987 by pgj@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))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200906101316.n5ADGHFw064174>