FreeBSD Bugzilla – Attachment 10363 Details for
Bug 20808
netstat -m doesn't use -N or -M arguments, nor warn about it
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
p
p (text/plain; charset=us-ascii), 4.40 KB, created by
ru
on 2001-06-12 16:38:13 UTC
(
hide
)
Description:
p
Filename:
MIME Type:
Creator:
ru
Created:
2001-06-12 16:38:13 UTC
Size:
4.40 KB
patch
obsolete
>Index: main.c >=================================================================== >RCS file: /home/ncvs/src/usr.bin/netstat/main.c,v >retrieving revision 1.34.2.4 >diff -u -p -r1.34.2.4 main.c >--- main.c 2001/03/22 13:48:42 1.34.2.4 >+++ main.c 2001/06/12 15:28:42 >@@ -145,6 +145,14 @@ static struct nlist nl[] = { > { "_mif6table" }, > #define N_PFKEYSTAT 37 > { "_pfkeystat" }, >+#define N_MBSTAT 38 >+ { "_mbstat" }, >+#define N_MBTYPES 39 >+ { "_mbtypes" }, >+#define N_NMBCLUSTERS 40 >+ { "_nmbclusters" }, >+#define N_NMBUFS 41 >+ { "_nmbufs" }, > { "" }, > }; > >@@ -465,7 +473,12 @@ main(argc, argv) > setgid(getgid()); > > if (mflag) { >- mbpr(); >+ if (memf != NULL) { >+ kread(0, 0, 0); >+ mbpr(nl[N_MBSTAT].n_value, nl[N_MBTYPES].n_value, >+ nl[N_NMBCLUSTERS].n_value, nl[N_NMBUFS].n_value); >+ } else >+ mbpr(0, 0, 0, 0); > exit(0); > } > if (pflag) { >Index: mbuf.c >=================================================================== >RCS file: /home/ncvs/src/usr.bin/netstat/mbuf.c,v >retrieving revision 1.17.2.2 >diff -u -p -r1.17.2.2 mbuf.c >--- mbuf.c 2000/10/24 22:53:26 1.17.2.2 >+++ mbuf.c 2001/06/12 15:28:42 >@@ -53,8 +53,6 @@ static const char rcsid[] = > #define YES 1 > typedef int bool; > >-struct mbstat mbstat; >- > static struct mbtypenames { > int mt_type; > char *mt_name; >@@ -96,10 +94,12 @@ static struct mbtypenames { > * Print mbuf statistics. > */ > void >-mbpr() >+mbpr(mbaddr, mbtaddr, nmbcaddr, nmbufaddr) >+ u_long mbaddr, mbtaddr, nmbcaddr, nmbufaddr; > { > u_long totmem, totpossible, totmbufs; > register int i; >+ struct mbstat mbstat; > struct mbtypenames *mp; > int name[3], nmbclusters, nmbufs, nmbtypes; > size_t nmbclen, nmbuflen, mbstatlen, mbtypeslen; >@@ -108,16 +108,12 @@ mbpr() > > mbtypes = NULL; > seen = NULL; >- >- name[0] = CTL_KERN; >- name[1] = KERN_IPC; >- name[2] = KIPC_MBSTAT; >- mbstatlen = sizeof mbstat; >- if (sysctl(name, 3, &mbstat, &mbstatlen, 0, 0) < 0) { >- warn("sysctl: retrieving mbstat"); >- goto err; >- } > >+ /* >+ * XXX >+ * We can't kread() mbtypeslen from a core image so we'll >+ * bogusly assume it's the same as in the running kernel. >+ */ > if (sysctlbyname("kern.ipc.mbtypes", NULL, &mbtypeslen, NULL, 0) < 0) { > warn("sysctl: retrieving mbtypes length"); > goto err; >@@ -126,29 +122,50 @@ mbpr() > warn("malloc: %lu bytes for mbtypes", (u_long)mbtypeslen); > goto err; > } >- if (sysctlbyname("kern.ipc.mbtypes", mbtypes, &mbtypeslen, NULL, >- 0) < 0) { >- warn("sysctl: retrieving mbtypes"); >- goto err; >- } > > nmbtypes = mbtypeslen / sizeof(*mbtypes); > if ((seen = calloc(nmbtypes, sizeof(*seen))) == NULL) { > warn("calloc"); > goto err; > } >- >- name[2] = KIPC_NMBCLUSTERS; >- nmbclen = sizeof(int); >- if (sysctl(name, 3, &nmbclusters, &nmbclen, 0, 0) < 0) { >- warn("sysctl: retrieving nmbclusters"); >- goto err; >- } > >- nmbuflen = sizeof(int); >- if (sysctlbyname("kern.ipc.nmbufs", &nmbufs, &nmbuflen, 0, 0) < 0) { >- warn("sysctl: retrieving nmbufs"); >- goto err; >+ if (mbaddr) { >+ if (kread(mbaddr, (char *)&mbstat, sizeof mbstat)) >+ goto err; >+ if (kread(mbtaddr, (char *)mbtypes, mbtypeslen)) >+ goto err; >+ if (kread(nmbcaddr, (char *)&nmbclusters, sizeof(int))) >+ goto err; >+ if (kread(nmbufaddr, (char *)&nmbufs, sizeof(int))) >+ goto err; >+ } else { >+ name[0] = CTL_KERN; >+ name[1] = KERN_IPC; >+ name[2] = KIPC_MBSTAT; >+ mbstatlen = sizeof mbstat; >+ if (sysctl(name, 3, &mbstat, &mbstatlen, 0, 0) < 0) { >+ warn("sysctl: retrieving mbstat"); >+ goto err; >+ } >+ >+ if (sysctlbyname("kern.ipc.mbtypes", mbtypes, &mbtypeslen, NULL, >+ 0) < 0) { >+ warn("sysctl: retrieving mbtypes"); >+ goto err; >+ } >+ >+ name[2] = KIPC_NMBCLUSTERS; >+ nmbclen = sizeof(int); >+ if (sysctl(name, 3, &nmbclusters, &nmbclen, 0, 0) < 0) { >+ warn("sysctl: retrieving nmbclusters"); >+ goto err; >+ } >+ >+ nmbuflen = sizeof(int); >+ if (sysctlbyname("kern.ipc.nmbufs", &nmbufs, &nmbuflen, 0, 0) < 0) { >+ warn("sysctl: retrieving nmbufs"); >+ goto err; >+ } > } > > #undef MSIZE >Index: netstat.h >=================================================================== >RCS file: /home/ncvs/src/usr.bin/netstat/netstat.h,v >retrieving revision 1.16.2.2 >diff -u -p -r1.16.2.2 netstat.h >--- netstat.h 2001/03/22 13:48:44 1.16.2.2 >+++ netstat.h 2001/06/12 15:28:42 >@@ -94,7 +94,7 @@ void pfkey_stats __P((u_long, char *)); > > void bdg_stats __P((u_long, char *)); > >-void mbpr __P((void)); >+void mbpr __P((u_long, u_long, u_long, u_long)); > > void hostpr __P((u_long, u_long)); > void impstats __P((u_long, u_long));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 20808
:
10362
| 10363