From: Simon Wilkinson Date: Thu, 15 Apr 2010 16:35:37 +0000 (+0100) Subject: Move des/stats.h to rxkad directory X-Git-Tag: upstream/1.8.0_pre1^2~4768 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=289461450c0e14cc35e0f8e80ff8047fdc13b6c5;p=packages%2Fo%2Fopenafs.git Move des/stats.h to rxkad directory The structures defined in des/stats.h are rxkad specific, and so should be handled by an rxkad header file, rather than by something in the eventually-to-be-removed DES directory. The structure shouldn't be initialised in libutil. Move initialisation to rxkad_common, where it is already initialised in the pthread case. Change-Id: I3de49cfe1752eaa5f273796516e2ff6c289d9533 Reviewed-on: http://gerrit.openafs.org/2576 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/des/Makefile.in b/src/des/Makefile.in index 5e4653855..aa628151a 100644 --- a/src/des/Makefile.in +++ b/src/des/Makefile.in @@ -49,7 +49,6 @@ OBJS = \ all: \ ${TOP_LIBDIR}/libdes.a \ ${TOP_INCDIR}/des.h \ - ${TOP_INCDIR}/des/stats.h \ ${TOP_INCDIR}/des_prototypes.h \ ${TOP_INCDIR}/des_conf.h \ ${TOP_INCDIR}/mit-cpyright.h \ @@ -65,7 +64,6 @@ buildtools: \ make_odd \ ${TOP_INCDIR}/des.h \ ${TOP_INCDIR}/mit-cpyright.h \ - ${TOP_INCDIR}/des/stats.h generated: \ p.c \ @@ -82,9 +80,6 @@ ${TOP_LIBDIR}/libdes.a: libdes.a ${TOP_INCDIR}/des.h: des.h ${INSTALL_DATA} $? $@ -${TOP_INCDIR}/des/stats.h: stats.h - ${INSTALL_DATA} $? $@ - ${TOP_INCDIR}/des_prototypes.h: des_prototypes.h ${INSTALL_DATA} $? $@ diff --git a/src/des/NTMakefile b/src/des/NTMakefile index 35fe386c6..db073e38b 100644 --- a/src/des/NTMakefile +++ b/src/des/NTMakefile @@ -36,14 +36,10 @@ INCFILES =\ $(INCFILEDIR)\mit-cpyright.h \ $(INCFILEDIR)\des_odd.h \ $(INCFILEDIR)\crypt.h \ - $(INCFILEDIR)\des\stats.h $(INCFILEDIR)\des_odd.h: odd.h $(COPY) odd.h $@ -$(INCFILEDIR)\des\stats.h: stats.h - $(COPY) stats.h $@ - # Library component lists. LIBOBJS = \ diff --git a/src/des/stats.h b/src/des/stats.h deleted file mode 100644 index bbb188a21..000000000 --- a/src/des/stats.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2000, International Business Machines Corporation and others. - * All Rights Reserved. - * - * This software has been released under the terms of the IBM Public - * License. For details, see the LICENSE file in the top-level source - * directory or online at http://www.openafs.org/dl/license10.html - */ - -/* Some Cheap statistics which should be shared with the rxkad definitions, but - * aren't. The layout should match the layout in rxkad/rxkad.p.h. */ - -#ifndef OPENAFS_DES_STATS_H -#define OPENAFS_DES_STATS_H - - -/* this is an optimization for pthreads environments. Instead of having global - rxkad statistics, make them thread-specific, and only perform aggregation on - the stats structures when necessary. Furthermore, don't do any locking, and - live with the nearly accurate aggregation (e.g. you might miss a few increments, - but the resulting aggregation should be almost correct). */ - -#ifdef AFS_PTHREAD_ENV -typedef struct rxkad_stats_t { -#else -struct rxkad_stats { -#endif - afs_uint32 connections[3]; /* client side only */ - afs_uint32 destroyObject; /* client security objects */ - afs_uint32 destroyClient; /* client connections */ - afs_uint32 destroyUnused; /* unused server conn */ - afs_uint32 destroyUnauth; /* unauthenticated server conn */ - afs_uint32 destroyConn[3]; /* server conn per level */ - afs_uint32 expired; /* server packets rejected */ - afs_uint32 challengesSent; /* server challenges sent */ - afs_uint32 challenges[3]; /* challenges seen by client */ - afs_uint32 responses[3]; /* responses seen by server */ - afs_uint32 preparePackets[6]; - afs_uint32 checkPackets[6]; - afs_uint32 bytesEncrypted[2]; /* index just by type */ - afs_uint32 bytesDecrypted[2]; - afs_uint32 fc_encrypts[2]; /* DECRYPT==0, ENCRYPT==1 */ - afs_uint32 fc_key_scheds; /* key schedule creations */ - afs_uint32 des_encrypts[2]; /* DECRYPT==0, ENCRYPT==1 */ - afs_uint32 des_key_scheds; /* key schedule creations */ - afs_uint32 des_randoms; /* random blocks generated */ - afs_uint32 clientObjects; - afs_uint32 serverObjects; - long spares[8]; -#ifdef AFS_PTHREAD_ENV - struct rxkad_stats_t * next; - struct rxkad_stats_t * prev; -} rxkad_stats_t; /* put these here for convenience */ -#else /* AFS_PTHREAD_ENV */ -}; -#ifdef AFS_NT40_ENV -struct rxkad_stats rxkad_stats; /* put this here for convenience */ -#endif -#endif /* AFS_PTHREAD_ENV */ - - -#ifdef AFS_PTHREAD_ENV -struct rxkad_global_stats { - rxkad_stats_t * first; - rxkad_stats_t * last; -}; - -#include -#include -extern pthread_mutex_t rxkad_global_stats_lock; -extern pthread_key_t rxkad_stats_key; - -extern void rxkad_global_stats_init(void); -extern rxkad_stats_t * rxkad_thr_stats_init(void); -extern int rxkad_stats_agg(rxkad_stats_t *); - -#ifndef BEGIN -#define BEGIN do { -#define END } while(0) -#endif -#define RXKAD_GLOBAL_STATS_LOCK assert(pthread_mutex_lock(&rxkad_global_stats_lock)==0) -#define RXKAD_GLOBAL_STATS_UNLOCK assert(pthread_mutex_unlock(&rxkad_global_stats_lock)==0) -#define GET_RXKAD_STATS(stats) rxkad_stats_agg(stats) -#define GET_RXKAD_THR_STATS(rxkad_stats) \ - BEGIN \ - (rxkad_stats) = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ - if ((rxkad_stats) == NULL) { \ - assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ - } \ - END -#define INC_RXKAD_STATS(stats_elem) \ - BEGIN \ - rxkad_stats_t * rxkad_stats; \ - rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ - if (rxkad_stats == NULL) { \ - assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ - } \ - rxkad_stats->stats_elem++; \ - END -#define DEC_RXKAD_STATS(stats_elem) \ - BEGIN \ - rxkad_stats_t * rxkad_stats; \ - rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ - if (rxkad_stats == NULL) { \ - assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ - } \ - rxkad_stats->stats_elem--; \ - END -#ifndef AFS_OBSD38_ENV -#define ADD_RXKAD_STATS(stats_elem, inc_value) \ - BEGIN \ - rxkad_stats_t * rxkad_stats; \ - rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ - if (rxkad_stats == NULL) { \ - assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ - } \ - rxkad_stats->stats_elem += inc_value; \ - END -#define SUB_RXKAD_STATS(stats_elem, dec_value) \ - BEGIN \ - rxkad_stats_t * rxkad_stats; \ - rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ - if (rxkad_stats == NULL) { \ - assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ - } \ - rxkad_stats->stats_elem -= dec_value; \ - END -#else /* AFS_OBSD38_ENV */ -/* segfaults but we don't know why */ -#define ADD_RXKAD_STATS(stats_elem, inc_value) -#define SUB_RXKAD_STATS(stats_elem, dec_value) -#endif /* AFS_OBSD38_ENV */ -#else /* AFS_PTHREAD_ENV */ -#define INC_RXKAD_STATS(stats_elem) rxkad_stats.stats_elem++ -#define DEC_RXKAD_STATS(stats_elem) rxkad_stats.stats_elem-- -#define ADD_RXKAD_STATS(stats_elem, inc_value) rxkad_stats.stats_elem += (inc_value) -#define SUB_RXKAD_STATS(stats_elem, dec_value) rxkad_stats.stats_elem -= (dec_value) -#define GET_RXKAD_STATS(stats) memcpy((stats), &rxkad_stats, sizeof(rxkad_stats)) -#endif /* AFS_PTHREAD_ENV */ - - -#if defined(AFS_NT40_ENV) && defined(AFS_PTHREAD_ENV) -#ifndef RXKAD_STATS_DECLSPEC -#define RXKAD_STATS_DECLSPEC __declspec(dllimport) extern -#endif -#else -#define RXKAD_STATS_DECLSPEC extern -#endif - -#ifdef AFS_PTHREAD_ENV -RXKAD_STATS_DECLSPEC struct rxkad_global_stats rxkad_global_stats; -#else /* AFS_PTHREAD_ENV */ -RXKAD_STATS_DECLSPEC struct rxkad_stats rxkad_stats; -#endif - - -#endif /* OPENAFS_DES_STATS_H */ diff --git a/src/rxkad/Makefile.in b/src/rxkad/Makefile.in index d458fdf41..625b179ad 100644 --- a/src/rxkad/Makefile.in +++ b/src/rxkad/Makefile.in @@ -41,7 +41,8 @@ generated: \ depinstall: \ ${TOP_INCDIR}/rx/rxkad.h \ ${TOP_INCDIR}/rx/rxkad_prototypes.h \ - ${TOP_INCDIR}/rx/fcrypt.h + ${TOP_INCDIR}/rx/fcrypt.h \ + ${TOP_INCDIR}/rx/rxkad_stats.h ${TOP_LIBDIR}/librxkad.a: librxkad.a ${INSTALL_DATA} $? $@ @@ -55,6 +56,9 @@ ${TOP_INCDIR}/rx/rxkad.h: rxkad.h ${TOP_INCDIR}/rx/rxkad_prototypes.h: rxkad_prototypes.h ${INSTALL_DATA} $? $@ +${TOP_INCDIR}/rx/rxkad_stats.h: stats.h + ${INSTALL_DATA} $? $@ + # # Build targets # diff --git a/src/rxkad/NTMakefile b/src/rxkad/NTMakefile index 00e71f130..faba33aa2 100644 --- a/src/rxkad/NTMakefile +++ b/src/rxkad/NTMakefile @@ -48,6 +48,7 @@ $(LIBFILE): $(LIBOBJS) $(INCFILES):$$(@F) $(COPY) $** $(INCFILEDIR)\. $(COPY) fcrypt.h $(INCFILEDIR)\. + $(COPY) stats.h $(INCFILEDIR)\rxkad_stats.h rxkad.h rxkad_errs.c : rxkad_errs.et rxkad.p.h $(DEL) rxkad_errs.c diff --git a/src/rxkad/bg-fcrypt.c b/src/rxkad/bg-fcrypt.c index 37fce4b0f..3318cb192 100644 --- a/src/rxkad/bg-fcrypt.c +++ b/src/rxkad/bg-fcrypt.c @@ -70,7 +70,7 @@ #include "rxkad.h" #include "fcrypt.h" #include "private_data.h" -#include +#include "stats.h" /* * Unrolling of the inner loops helps the most on pentium chips diff --git a/src/rxkad/crypt_conn.c b/src/rxkad/crypt_conn.c index 4f78e0d69..e5356553c 100644 --- a/src/rxkad/crypt_conn.c +++ b/src/rxkad/crypt_conn.c @@ -44,7 +44,7 @@ #endif #endif /* KERNEL */ -#include +#include #include "private_data.h" #define XPRT_RXKAD_CRYPT diff --git a/src/rxkad/fcrypt.c b/src/rxkad/fcrypt.c index baa785fc9..e6afb20c5 100644 --- a/src/rxkad/fcrypt.c +++ b/src/rxkad/fcrypt.c @@ -55,7 +55,7 @@ #include "sboxes.h" #include "fcrypt.h" #include -#include +#include #ifdef TCRYPT int ROUNDS = 16; diff --git a/src/rxkad/rxkad_client.c b/src/rxkad/rxkad_client.c index 6643cdae5..a17787b5a 100644 --- a/src/rxkad/rxkad_client.c +++ b/src/rxkad/rxkad_client.c @@ -59,7 +59,7 @@ #endif /* AFS_PTHREAD_ENV */ #endif /* KERNEL */ -#include +#include "stats.h" #include "private_data.h" #define XPRT_RXKAD_CLIENT diff --git a/src/rxkad/rxkad_common.c b/src/rxkad/rxkad_common.c index d1259f649..de57f424c 100644 --- a/src/rxkad/rxkad_common.c +++ b/src/rxkad/rxkad_common.c @@ -63,7 +63,7 @@ #include #endif /* KERNEL */ -#include +#include "stats.h" #include "private_data.h" #define XPRT_RXKAD_COMMON @@ -81,11 +81,7 @@ struct rxkad_global_stats rxkad_global_stats = { 0 }; pthread_mutex_t rxkad_global_stats_lock; pthread_key_t rxkad_stats_key; #else /* AFS_PTHREAD_ENV */ -#if defined(KERNEL) && !defined(UKERNEL) struct rxkad_stats rxkad_stats = { { 0 } }; -#else -/* Move delaration of this to des/key_sched.c */ -#endif #endif /* AFS_PTHREAD_ENV */ #ifdef AFS_PTHREAD_ENV diff --git a/src/rxkad/rxkad_server.c b/src/rxkad/rxkad_server.c index 7ba99fb05..a0ca53435 100644 --- a/src/rxkad/rxkad_server.c +++ b/src/rxkad/rxkad_server.c @@ -31,10 +31,10 @@ #include #include #include -#include #ifdef HAVE_STDINT_H # include #endif +#include "stats.h" #include "private_data.h" #define XPRT_RXKAD_SERVER diff --git a/src/rxkad/stats.h b/src/rxkad/stats.h new file mode 100644 index 000000000..9e878c187 --- /dev/null +++ b/src/rxkad/stats.h @@ -0,0 +1,157 @@ +/* + * Copyright 2000, International Business Machines Corporation and others. + * All Rights Reserved. + * + * This software has been released under the terms of the IBM Public + * License. For details, see the LICENSE file in the top-level source + * directory or online at http://www.openafs.org/dl/license10.html + */ + +/* Some Cheap statistics which should be shared with the rxkad definitions, but + * aren't. The layout should match the layout in rxkad/rxkad.p.h. */ + +#ifndef AFS_SRC_RXKAD_STATS_H +#define AFS_SRC_RXKAD_STATS_H + + +/* this is an optimization for pthreads environments. Instead of having global + rxkad statistics, make them thread-specific, and only perform aggregation on + the stats structures when necessary. Furthermore, don't do any locking, and + live with the nearly accurate aggregation (e.g. you might miss a few increments, + but the resulting aggregation should be almost correct). */ + +#ifdef AFS_PTHREAD_ENV +typedef struct rxkad_stats_t { +#else +struct rxkad_stats { +#endif + afs_uint32 connections[3]; /* client side only */ + afs_uint32 destroyObject; /* client security objects */ + afs_uint32 destroyClient; /* client connections */ + afs_uint32 destroyUnused; /* unused server conn */ + afs_uint32 destroyUnauth; /* unauthenticated server conn */ + afs_uint32 destroyConn[3]; /* server conn per level */ + afs_uint32 expired; /* server packets rejected */ + afs_uint32 challengesSent; /* server challenges sent */ + afs_uint32 challenges[3]; /* challenges seen by client */ + afs_uint32 responses[3]; /* responses seen by server */ + afs_uint32 preparePackets[6]; + afs_uint32 checkPackets[6]; + afs_uint32 bytesEncrypted[2]; /* index just by type */ + afs_uint32 bytesDecrypted[2]; + afs_uint32 fc_encrypts[2]; /* DECRYPT==0, ENCRYPT==1 */ + afs_uint32 fc_key_scheds; /* key schedule creations */ + afs_uint32 des_encrypts[2]; /* DECRYPT==0, ENCRYPT==1 */ + afs_uint32 des_key_scheds; /* key schedule creations */ + afs_uint32 des_randoms; /* random blocks generated */ + afs_uint32 clientObjects; + afs_uint32 serverObjects; + long spares[8]; +#ifdef AFS_PTHREAD_ENV + struct rxkad_stats_t * next; + struct rxkad_stats_t * prev; +} rxkad_stats_t; /* put these here for convenience */ +#else /* AFS_PTHREAD_ENV */ +}; +#ifdef AFS_NT40_ENV +struct rxkad_stats rxkad_stats; /* put this here for convenience */ +#endif +#endif /* AFS_PTHREAD_ENV */ + + +#ifdef AFS_PTHREAD_ENV +struct rxkad_global_stats { + rxkad_stats_t * first; + rxkad_stats_t * last; +}; + +#include +#include +extern pthread_mutex_t rxkad_global_stats_lock; +extern pthread_key_t rxkad_stats_key; + +extern void rxkad_global_stats_init(void); +extern rxkad_stats_t * rxkad_thr_stats_init(void); +extern int rxkad_stats_agg(rxkad_stats_t *); + +#ifndef BEGIN +#define BEGIN do { +#define END } while(0) +#endif +#define RXKAD_GLOBAL_STATS_LOCK assert(pthread_mutex_lock(&rxkad_global_stats_lock)==0) +#define RXKAD_GLOBAL_STATS_UNLOCK assert(pthread_mutex_unlock(&rxkad_global_stats_lock)==0) +#define GET_RXKAD_STATS(stats) rxkad_stats_agg(stats) +#define GET_RXKAD_THR_STATS(rxkad_stats) \ + BEGIN \ + (rxkad_stats) = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ + if ((rxkad_stats) == NULL) { \ + assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ + } \ + END +#define INC_RXKAD_STATS(stats_elem) \ + BEGIN \ + rxkad_stats_t * rxkad_stats; \ + rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ + if (rxkad_stats == NULL) { \ + assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ + } \ + rxkad_stats->stats_elem++; \ + END +#define DEC_RXKAD_STATS(stats_elem) \ + BEGIN \ + rxkad_stats_t * rxkad_stats; \ + rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ + if (rxkad_stats == NULL) { \ + assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ + } \ + rxkad_stats->stats_elem--; \ + END +#ifndef AFS_OBSD38_ENV +#define ADD_RXKAD_STATS(stats_elem, inc_value) \ + BEGIN \ + rxkad_stats_t * rxkad_stats; \ + rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ + if (rxkad_stats == NULL) { \ + assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ + } \ + rxkad_stats->stats_elem += inc_value; \ + END +#define SUB_RXKAD_STATS(stats_elem, dec_value) \ + BEGIN \ + rxkad_stats_t * rxkad_stats; \ + rxkad_stats = ((rxkad_stats_t*)pthread_getspecific(rxkad_stats_key)); \ + if (rxkad_stats == NULL) { \ + assert(((rxkad_stats) = rxkad_thr_stats_init()) != NULL); \ + } \ + rxkad_stats->stats_elem -= dec_value; \ + END +#else /* AFS_OBSD38_ENV */ +/* segfaults but we don't know why */ +#define ADD_RXKAD_STATS(stats_elem, inc_value) +#define SUB_RXKAD_STATS(stats_elem, dec_value) +#endif /* AFS_OBSD38_ENV */ +#else /* AFS_PTHREAD_ENV */ +#define INC_RXKAD_STATS(stats_elem) rxkad_stats.stats_elem++ +#define DEC_RXKAD_STATS(stats_elem) rxkad_stats.stats_elem-- +#define ADD_RXKAD_STATS(stats_elem, inc_value) rxkad_stats.stats_elem += (inc_value) +#define SUB_RXKAD_STATS(stats_elem, dec_value) rxkad_stats.stats_elem -= (dec_value) +#define GET_RXKAD_STATS(stats) memcpy((stats), &rxkad_stats, sizeof(rxkad_stats)) +#endif /* AFS_PTHREAD_ENV */ + + +#if defined(AFS_NT40_ENV) && defined(AFS_PTHREAD_ENV) +#ifndef RXKAD_STATS_DECLSPEC +#define RXKAD_STATS_DECLSPEC __declspec(dllimport) extern +#endif +#else +#define RXKAD_STATS_DECLSPEC extern +#endif + +#ifdef AFS_PTHREAD_ENV +RXKAD_STATS_DECLSPEC struct rxkad_global_stats rxkad_global_stats; +#else /* AFS_PTHREAD_ENV */ +RXKAD_STATS_DECLSPEC struct rxkad_stats rxkad_stats; +#endif + + +#endif /* AFS_SRC_DES_STATS_H */ diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 0226e8f9f..dfcc7d7a1 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -19,7 +19,7 @@ objects = assert.o base64.o casestrcpy.o config_file.o ktime.o volparse.o \ hputil.o kreltime.o isathing.o get_krbrlm.o uuid.o serverLog.o \ dirpath.o fileutil.o netutils.o flipbase64.o fstab.o \ afs_atomlist.o afs_lhash.o snprintf.o strlcat.o strlcpy.o strnlen.o \ - pthread_glock.o daemon.o rxkstats.o ${REGEX_OBJ} + pthread_glock.o daemon.o ${REGEX_OBJ} includes = \ ${TOP_INCDIR}/afs/dirpath.h \ @@ -219,9 +219,6 @@ strnlen.o: ${srcdir}/strnlen.c ${includes} daemon.o: ${srcdir}/daemon.c ${includes} ${CCOBJ} ${CFLAGS} -c ${srcdir}/daemon.c -rxkstats.o: ${srcdir}/rxkstats.c ${includes} - ${CCOBJ} ${CFLAGS} -c ${srcdir}/rxkstats.c - # # Install targets # diff --git a/src/util/rxkstats.c b/src/util/rxkstats.c deleted file mode 100644 index 82e93f08d..000000000 --- a/src/util/rxkstats.c +++ /dev/null @@ -1,11 +0,0 @@ -#include -#include - -#include -#include - -#ifndef AFS_PTHREAD_ENV -struct rxkad_stats rxkad_stats = { { 0 } }; -#else -rxkad_stats_t rxkad_stats = { { 0 } }; -#endif