PERFORCE change 164169 for review
Gabor Pali
pgj at FreeBSD.org
Fri Jun 12 12:04:02 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=164169
Change 164169 by pgj at petymeg-current on 2009/06/12 12:02:52
- Improve inetpr()
- Move inet-related nlist members from netstat to libnetstat
Affected files ...
.. //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#22 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#4 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#12 edit
.. //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#7 edit
Differences ...
==== //depot/projects/soc2009/pgj_libstat/src/lib/libnetstat/netstat.c#22 (text+ko) ====
@@ -376,12 +376,24 @@
{
kvm_t *kvm;
int use_kvm;
+ struct nlist *nlp = NULL;
use_kvm = flags & NETSTAT_SOCKET_KVM;
if (use_kvm) {
/* Use KVM to retrieve data. */
+ switch (domain) {
+ case PF_LOCAL:
+ nlp = &nl[X_UNP_COUNT];
+ break;
+ case PF_INET:
+ case PF_INET6:
+ nlp = &nl[X_TCBINFO];
+ break;
+ default:
+ break;
+ }
kvm = (kvm_t *)kvm_handle;
- if (kvm_nlist(kvm, nl) < 0) {
+ if (kvm_nlist(kvm, nlp) < 0) {
list->stl_error = NETSTAT_ERROR_KVM;
return (-1);
}
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/extern.h#4 (text+ko) ====
@@ -68,7 +68,7 @@
const char *pluralies(uintmax_t);
int sotoxsocket(struct socket *, struct xsocket *);
-void inetpr(void *, int);
+void inetpr(void *, int, int);
void tcp_stats(u_long, const char *, int, int);
void udp_stats(u_long, const char *, int, int);
#ifdef SCTP
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/inet.c#12 (text+ko) ====
@@ -104,7 +104,7 @@
* -a (all) flag is specified.
*/
void
-inetpr(void *kvmd, int proto)
+inetpr(void *kvmd, int family, int proto)
{
struct socket_type_list *stlp;
int error, st_flags;
@@ -127,7 +127,7 @@
if (aflag)
st_flags |= NETSTAT_SOCKET_ALL;
- if (netstat_socket(PF_INET, 0, proto, stlp, st_flags, kvm) < 0) {
+ if (netstat_socket(family, 0, proto, stlp, st_flags, kvm) < 0) {
error = netstat_stl_geterror(stlp);
if (error == NETSTAT_ERROR_KVM)
warnx("netstat_socket: %s", kvm_geterr(kvm));
==== //depot/projects/soc2009/pgj_libstat/src/usr.bin/netstat/main.c#7 (text+ko) ====
@@ -162,19 +162,11 @@
{ .n_name = "_igmpstat" },
#define N_PIMSTAT 43
{ .n_name = "_pimstat" },
-#define N_TCBINFO 44
- { .n_name = "_tcbinfo" },
-#define N_UDBINFO 45
- { .n_name = "_udbinfo" },
-#define N_DIVCBINFO 46
- { .n_name = "_divcbinfo" },
-#define N_RIPCBINFO 47
- { .n_name = "_ripcbinfo" },
-#define N_RIP6STAT 48
+#define N_RIP6STAT 44
{ .n_name = "_rip6stat" },
-#define N_SCTPSTAT 49
+#define N_SCTPSTAT 45
{ .n_name = "_sctpstat" },
-#define N_MFCTABLESIZE 50
+#define N_MFCTABLESIZE 46
{ .n_name = "_mfctablesize" },
{ .n_name = NULL },
};
@@ -192,21 +184,21 @@
int pr_usesysctl; /* non-zero if we use sysctl, not kvm */
int pr_protocol;
} protox[] = {
- { N_TCBINFO, N_TCPSTAT, 1, NULL,
+ { 0, N_TCPSTAT, 1, NULL,
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
- { N_UDBINFO, N_UDPSTAT, 1, NULL,
+ { 0, N_UDPSTAT, 1, NULL,
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
#ifdef SCTP
{ -1, N_SCTPSTAT, 1, sctp_protopr,
sctp_stats, NULL, "sctp", 1, IPPROTO_SCTP },
#endif
- { N_DIVCBINFO, -1, 1, NULL,
+ { 0, -1, 1, NULL,
NULL, NULL, "divert", 1, IPPROTO_DIVERT },
- { N_RIPCBINFO, N_IPSTAT, 1, NULL,
+ { 0, N_IPSTAT, 1, NULL,
ip_stats, NULL, "ip", 1, IPPROTO_RAW },
- { N_RIPCBINFO, N_ICMPSTAT, 1, NULL,
+ { 0, N_ICMPSTAT, 1, NULL,
icmp_stats, NULL, "icmp", 1, IPPROTO_ICMP },
- { N_RIPCBINFO, N_IGMPSTAT, 1, NULL,
+ { 0, N_IGMPSTAT, 1, NULL,
igmp_stats, NULL, "igmp", 1, IPPROTO_IGMP },
#ifdef IPSEC
{ -1, N_IPSECSTAT, 1, NULL, /* keep as compat */
@@ -218,7 +210,7 @@
{ -1, N_IPCOMPSTAT, 1, NULL,
ipcomp_stats, NULL, "ipcomp", 0, 0},
#endif
- { N_RIPCBINFO, N_PIMSTAT, 1, NULL,
+ { 0, N_PIMSTAT, 1, NULL,
pim_stats, NULL, "pim", 1, IPPROTO_PIM },
{ -1, N_CARPSTAT, 1, NULL,
carp_stats, NULL, "carp", 1, 0 },
@@ -230,13 +222,13 @@
#ifdef INET6
struct protox ip6protox[] = {
- { N_TCBINFO, N_TCPSTAT, 1, NULL,
+ { 0, N_TCPSTAT, 1, NULL,
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
- { N_UDBINFO, N_UDPSTAT, 1, NULL,
+ { 0, N_UDPSTAT, 1, NULL,
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
- { N_RIPCBINFO, N_IP6STAT, 1, NULL,
+ { 0, N_IP6STAT, 1, NULL,
ip6_stats, ip6_ifstats, "ip6", 1, IPPROTO_RAW },
- { N_RIPCBINFO, N_ICMP6STAT, 1, NULL,
+ { 0, N_ICMP6STAT, 1, NULL,
icmp6_stats, icmp6_ifstats, "icmp6", 1, IPPROTO_ICMPV6 },
#ifdef IPSEC
{ -1, N_IPSEC6STAT, 1, NULL,
@@ -658,7 +650,7 @@
case IPPROTO_IGMP:
case IPPROTO_PIM:
case IPPROTO_ICMPV6:
- inetpr(kvmd, tp->pr_protocol);
+ inetpr(kvmd, af, tp->pr_protocol);
break;
default:
if (pr != NULL)
More information about the p4-projects
mailing list