summaryrefslogtreecommitdiff
path: root/usr.bin/systat
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2011-11-29 10:17:53 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2011-11-29 10:17:53 +0000
commite10fd0f6269e09e343c373e11984718fe4d3910e (patch)
treea9f5b03d3c7e0601fcbe4047fed16039f7a865b3 /usr.bin/systat
parentc1bc07b4e505bf0e75a7ec3d4f6ed5322db04d91 (diff)
use a u_int64_t for the state id in pfsync_state. this makes it consistent
with every other thing that stores the state id (including other pfsync messages). includes improvements to the systat code to consider the creatorid as well as the state id in its cache to avoid collisions between states created on different hosts. tested by me in production and on amd64 talking to sparc64. ok henning@
Diffstat (limited to 'usr.bin/systat')
-rw-r--r--usr.bin/systat/cache.c18
-rw-r--r--usr.bin/systat/cache.h5
2 files changed, 12 insertions, 11 deletions
diff --git a/usr.bin/systat/cache.c b/usr.bin/systat/cache.c
index f199919df75..5c9a2a89d6f 100644
--- a/usr.bin/systat/cache.c
+++ b/usr.bin/systat/cache.c
@@ -1,4 +1,4 @@
-/* $Id: cache.c,v 1.3 2008/12/07 02:56:06 canacar Exp $ */
+/* $Id: cache.c,v 1.4 2011/11/29 10:17:52 dlg Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
*
@@ -118,8 +118,8 @@ add_state(struct pfsync_state *st)
cache_size--;
- ent->id[0] = st->id[0];
- ent->id[1] = st->id[1];
+ ent->id = st->id;
+ ent->creatorid = st->creatorid;
ent->bytes = COUNTER(st->bytes[0]) + COUNTER(st->bytes[1]);
ent->peak = 0;
ent->rate = 0;
@@ -139,8 +139,8 @@ cache_state(struct pfsync_state *st)
if (cache_max == 0)
return (NULL);
- ent.id[0] = st->id[0];
- ent.id[1] = st->id[1];
+ ent.id = st->id;
+ ent.creatorid = st->creatorid;
old = RB_FIND(sc_tree, &sctree, &ent);
if (old == NULL) {
@@ -189,13 +189,13 @@ cache_endupdate(void)
static __inline int
sc_cmp(struct sc_ent *a, struct sc_ent *b)
{
- if (a->id[0] > b->id[0])
+ if (a->id > b->id)
return (1);
- if (a->id[0] < b->id[0])
+ if (a->id < b->id)
return (-1);
- if (a->id[1] > b->id[1])
+ if (a->creatorid > b->creatorid)
return (1);
- if (a->id[1] < b->id[1])
+ if (a->creatorid < b->creatorid)
return (-1);
return (0);
}
diff --git a/usr.bin/systat/cache.h b/usr.bin/systat/cache.h
index d09620dd20e..abc72cfe2cb 100644
--- a/usr.bin/systat/cache.h
+++ b/usr.bin/systat/cache.h
@@ -1,4 +1,4 @@
-/* $Id: cache.h,v 1.2 2008/07/16 10:23:39 canacar Exp $ */
+/* $Id: cache.h,v 1.3 2011/11/29 10:17:52 dlg Exp $ */
/*
* Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org>
*
@@ -25,7 +25,8 @@
struct sc_ent {
RB_ENTRY(sc_ent) tlink;
TAILQ_ENTRY(sc_ent) qlink;
- u_int32_t id[2];
+ u_int64_t id;
+ u_int32_t creatorid;
double peak;
double rate;
time_t t;