PERFORCE change 82948 for review
soc-anders
soc-anders at FreeBSD.org
Thu Sep 1 01:19:51 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=82948
Change 82948 by soc-anders at soc-anders_gimli on 2005/09/01 01:19:09
Created a separate mib structure for slip which is now returned
rather than sl_softc when making link specific ifmib sysctl calls.
Modified slstat to use the new structures rather than sl_softc.
Affected files ...
.. //depot/projects/soc2005/ifcleanup/src/src/sys/net/if_sl.c#2 edit
.. //depot/projects/soc2005/ifcleanup/src/src/sys/net/if_slvar.h#2 edit
.. //depot/projects/soc2005/ifcleanup/src/src/usr.sbin/slstat/slstat.c#2 edit
Differences ...
==== //depot/projects/soc2005/ifcleanup/src/src/sys/net/if_sl.c#2 (text+ko) ====
@@ -331,8 +331,8 @@
SL2IFP(sc)->if_start = slstart;
SL2IFP(sc)->if_snd.ifq_maxlen = 50;
sc->sc_fastq.ifq_maxlen = 32;
- SL2IFP(sc)->if_linkmib = sc;
- SL2IFP(sc)->if_linkmiblen = sizeof *sc;
+ SL2IFP(sc)->if_linkmib = &sc->sc_mib;
+ SL2IFP(sc)->if_linkmiblen = sizeof sc->sc_mib;
mtx_init(&sc->sc_fastq.ifq_mtx, "sl_fastq", NULL, MTX_DEF);
/*
==== //depot/projects/soc2005/ifcleanup/src/src/sys/net/if_slvar.h#2 (text+ko) ====
@@ -42,6 +42,7 @@
* (This exists so programs like slstats can get at the definition
* of sl_softc.)
*/
+#ifdef _KERNEL
struct sl_softc {
struct ifnet *sc_ifp; /* network-visible interface */
struct ifqueue sc_fastq; /* interactive output queue */
@@ -50,23 +51,40 @@
u_char *sc_mp; /* pointer to next available buf char */
u_char *sc_ep; /* pointer to last available buf char */
u_char *sc_buf; /* input buffer */
- u_int sc_flags; /* see below */
- u_int sc_escape; /* =1 if last char input was FRAME_ESCAPE */
- time_t sc_lasttime; /* last time a char arrived */
- long sc_abortcount; /* number of abort escape chars */
- time_t sc_starttime; /* time of first abort in window */
- u_int sc_keepalive; /* time to decide link hang */
- u_int sc_outfill; /* time to send FRAME_END when output idle */
+#endif /* _KERNEL */
+ struct sl_linkmib {
+ u_int scm_flags; /* see below */
+ u_int scm_escape; /* =1 if last char input was FRAME_ESCAPE */
+ time_t scm_lasttime; /* last time a char arrived */
+ long scm_abortcount; /* number of abort escape chars */
+ time_t scm_starttime; /* time of first abort in window */
+ u_int scm_keepalive; /* time to decide link hang */
+ u_int scm_outfill; /* time to send FRAME_END when output idle */
/*
* Handles for scheduling outfill and
* keepalive timeouts.
*/
+ struct slcompress scm_comp; /* tcp compression data */
+ }
+#ifndef _KERNEL
+ ;
+#else
+ sc_mib;
+
+#define sc_flags sc_mib.scm_flags
+#define sc_escape sc_mib.scm_escape
+#define sc_lasttime sc_mib.scm_lasttime
+#define sc_abortcount sc_mib.scm_abortcount
+#define sc_starttime sc_mib.scm_starttime
+#define sc_keepalive sc_mib.scm_keepalive
+#define sc_outfill sc_mib.scm_outfill
+#define sc_comp sc_mib.scm_comp
struct callout_handle sc_ofhandle;
struct callout_handle sc_kahandle;
- struct slcompress sc_comp; /* tcp compression data */
LIST_ENTRY(sl_softc) sl_next;
u_char *bpfbuf; /* hang buffer for bpf here */
};
+#endif /* _KERNEL */
#define SL2IFP(sc) ((sc)->sc_ifp)
/* internal flags */
==== //depot/projects/soc2005/ifcleanup/src/src/usr.sbin/slstat/slstat.c#2 (text+ko) ====
@@ -38,8 +38,8 @@
#include <string.h>
#include <unistd.h>
+#include <sys/mbuf.h>
#include <net/if.h>
-#include <net/if_var.h>
#include <net/if_mib.h>
#include <net/if_types.h>
#include <netinet/in.h>
@@ -132,13 +132,12 @@
}
name[4] = indx;
- name[5] = IFDATA_LINKSPECIFIC;
intpr();
exit(0);
}
-#define V(offset) ((line % 20)? ((sc->offset - osc->offset) / \
- (rflag ? interval : 1)) : sc->offset)
+#define V(type,offset) ((line % 20)? ((type.offset - o##type.offset) / \
+ (rflag ? interval : 1)) : type.offset)
#define AMT (sizeof(*sc) - 2 * sizeof(sc->sc_comp.tstate))
static void
@@ -161,17 +160,29 @@
{
register int line = 0;
int oldmask;
- struct sl_softc *sc, *osc;
+ /* struct sl_softc *sc, *osc;*/
+ struct sl_linkmib scm, oscm;
+ struct ifmibdata ifmd, oifmd;
size_t len;
+ /*
sc = (struct sl_softc *)malloc(AMT);
osc = (struct sl_softc *)malloc(AMT);
- bzero((char *)osc, AMT);
- len = AMT;
+ */
+ bzero((char *)&oscm, sizeof(oscm));
+ bzero((char *)&oifmd, sizeof(oifmd));
while (1) {
- if (sysctl(name, 6, sc, &len, 0, 0) < 0 &&
- (errno != ENOMEM || len != AMT))
+ len = sizeof(ifmd);
+ name[5] = IFDATA_GENERAL;
+ if (sysctl(name, 6, &ifmd, &len, 0, 0) < 0 &&
+ (errno != ENOMEM || len != sizeof(ifmd)))
+ err(1, "sysctl ifdata general");
+
+ len = sizeof(scm);
+ name[5] = IFDATA_LINKSPECIFIC;
+ if (sysctl(name, 6, &scm, &len, 0, 0) < 0 &&
+ (errno != ENOMEM || len != sizeof(scm)))
err(1, "sysctl linkspecific");
(void)signal(SIGALRM, catchalarm);
@@ -192,31 +203,33 @@
putchar('\n');
}
printf("%8lu %6ld %6u %6u %6u",
- V(sc_ifp->if_ibytes),
- V(sc_ifp->if_ipackets),
- V(sc_comp.sls_compressedin),
- V(sc_comp.sls_uncompressedin),
- V(sc_comp.sls_errorin));
+ V(ifmd, ifmd_data.ifi_ibytes),
+ V(ifmd, ifmd_data.ifi_ipackets),
+ V(scm, scm_comp.sls_compressedin),
+ V(scm, scm_comp.sls_uncompressedin),
+ V(scm, scm_comp.sls_errorin));
if (vflag)
printf(" %6u %6lu %6lu",
- V(sc_comp.sls_tossed),
- V(sc_ifp->if_ipackets) -
- V(sc_comp.sls_compressedin) -
- V(sc_comp.sls_uncompressedin) -
- V(sc_comp.sls_errorin),
- V(sc_ifp->if_ierrors));
+ V(scm, scm_comp.sls_tossed),
+ V(ifmd, ifmd_data.ifi_ipackets) -
+ V(scm, scm_comp.sls_compressedin) -
+ V(scm, scm_comp.sls_uncompressedin) -
+ V(scm, scm_comp.sls_errorin),
+ V(ifmd, ifmd_data.ifi_ierrors));
printf(" | %8lu %6ld %6u %6u %6lu",
- V(sc_ifp->if_obytes) / (rflag ? interval : 1),
- V(sc_ifp->if_opackets),
- V(sc_comp.sls_compressed),
- V(sc_comp.sls_packets) - V(sc_comp.sls_compressed),
- V(sc_ifp->if_opackets) - V(sc_comp.sls_packets));
+ V(ifmd, ifmd_data.ifi_obytes) / (rflag ? interval : 1),
+ V(ifmd, ifmd_data.ifi_opackets),
+ V(scm, scm_comp.sls_compressed),
+ V(scm, scm_comp.sls_packets) -
+ V(scm, scm_comp.sls_compressed),
+ V(ifmd, ifmd_data.ifi_opackets) -
+ V(scm, scm_comp.sls_packets));
if (vflag)
printf(" %6u %6u %6lu %6lu",
- V(sc_comp.sls_searches),
- V(sc_comp.sls_misses),
- V(sc_ifp->if_oerrors),
- V(sc_ifp->if_collisions));
+ V(scm, scm_comp.sls_searches),
+ V(scm, scm_comp.sls_misses),
+ V(ifmd, ifmd_data.ifi_oerrors),
+ V(ifmd, ifmd_data.ifi_collisions));
putchar('\n');
fflush(stdout);
line++;
@@ -227,7 +240,8 @@
sigsetmask(oldmask);
signalled = 0;
(void)alarm(interval);
- bcopy((char *)sc, (char *)osc, AMT);
+ bcopy((char *)&scm, (char *)&oscm, sizeof(scm));
+ bcopy((char *)&ifmd, (char *)&oifmd, sizeof(ifmd));
}
}
More information about the p4-projects
mailing list