From cd6a9d9a970c5c2b414da3d5b49acdb130a93c38 Mon Sep 17 00:00:00 2001 From: Fabian Keil Date: Sun, 24 Feb 2013 16:47:24 +0100 Subject: [PATCH] Update sysutils/pftop to 0.7_2 - Unbreak on HEAD after r240233. Reported by Sven Hazejager. - Unbreak on FreeBSD 9 version without pf 4.5. - Import patch from ports/175927 to fix segfaults on FreeBSD 8. Submitted by Renato Botelho (garga@). - Fix rule display in a couple of views on FreeBSD 9 and 10. It's unclear to me whether or not FreeBSD 8 is affected. Reported and tested by Thomas Kinsey. Fix reported to OpenBSD by Robert Mills. - Assume maintainership as mlaier@ seems to be busy. --- sysutils/pftop/Makefile | 12 ++++++++---- sysutils/pftop/files/extra-patch-cache.c | 24 ++++++++++++++++++++---- sysutils/pftop/files/extra-patch-cache.h | 7 ++++++- sysutils/pftop/files/extra-patch-pftop.c | 12 +++++++++--- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/sysutils/pftop/Makefile b/sysutils/pftop/Makefile index 63ef1b2..36b31c6 100644 --- a/sysutils/pftop/Makefile +++ b/sysutils/pftop/Makefile @@ -7,11 +7,11 @@ PORTNAME= pftop PORTVERSION= 0.7 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= sysutils net MASTER_SITES= http://www.eee.metu.edu.tr/~canacar/ -MAINTAINER= mlaier@FreeBSD.org +MAINTAINER= fk@fabiankeil.de COMMENT= Utility for real-time display of statistics for pf MAN8= pftop.8 @@ -23,7 +23,7 @@ MANCOMPRESSED= no .if ${OSVERSION} < 700049 MAKE_ARGS= LOCALBASE="${PREFIX}" OSLEVEL=37 CFLAGS+= -DHAVE_ALTQ=1 -.elif ${OSVERSION} < 900000 +.elif ${OSVERSION} < 900039 MAKE_ARGS= LOCALBASE="${PREFIX}" OSLEVEL=41 CFLAGS+= -DHAVE_ALTQ=1 .else @@ -32,10 +32,14 @@ CFLAGS+= -DHAVE_ALTQ=1 -DHAVE_SNPRINTF=1 -DHAVE_VSNPRINTF=1 EXTRA_PATCHES+= ${FILESDIR}/extra-patch-cache.c \ ${FILESDIR}/extra-patch-cache.h \ ${FILESDIR}/extra-patch-config.h \ - ${FILESDIR}/extra-patch-engine.c \ ${FILESDIR}/extra-patch-pftop.c \ ${FILESDIR}/extra-patch-sf-gencode.c +.if ${OSVERSION} > 1000017 +CFLAGS+= -DHAVE_FINE_GRAINED_LOCKING=1 .endif +.endif + +EXTRA_PATCHES+= ${FILESDIR}/extra-patch-engine.c MAKE_ENV+= __MAKE_CONF=/dev/null diff --git a/sysutils/pftop/files/extra-patch-cache.c b/sysutils/pftop/files/extra-patch-cache.c index a0132cc..8a345a3 100644 --- a/sysutils/pftop/files/extra-patch-cache.c +++ b/sysutils/pftop/files/extra-patch-cache.c @@ -1,13 +1,18 @@ +# Adjusted to work with the changes in r240233. $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ --- cache.c.orig Tue Nov 6 23:34:18 2007 +++ cache.c Wed Jun 11 19:50:07 2008 -@@ -118,12 +118,17 @@ add_state(pf_state_t *st) +@@ -118,12 +118,21 @@ cache_size--; +#ifdef HAVE_PFSYNC_STATE ++#ifdef HAVE_FINE_GRAINED_LOCKING ++ ent->id = st->id; ++#else + ent->id[0] = st->id[0]; + ent->id[1] = st->id[1]; ++#endif +#else ent->addr[0] = st->lan.addr; ent->port[0] = st->lan.port; @@ -19,13 +24,17 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ #ifdef HAVE_INOUT_COUNT ent->bytes = COUNTER(st->bytes[0]) + COUNTER(st->bytes[1]); #else -@@ -147,13 +152,17 @@ cache_state(pf_state_t *st) +@@ -147,13 +156,21 @@ if (cache_max == 0) return (NULL); +#ifdef HAVE_PFSYNC_STATE ++#ifdef HAVE_FINE_GRAINED_LOCKING ++ ent.id = st->id; ++#else + ent.id[0] = st->id[0]; + ent.id[1] = st->id[1]; ++#endif +#else ent.addr[0] = st->lan.addr; ent.port[0] = st->lan.port; @@ -38,11 +47,17 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ old = RB_FIND(sc_tree, &sctree, &ent); if (old == NULL) { -@@ -210,8 +219,18 @@ cache_endupdate(void) +@@ -210,8 +227,25 @@ static __inline int sc_cmp(struct sc_ent *a, struct sc_ent *b) { +#ifdef HAVE_PFSYNC_STATE ++#ifdef HAVE_FINE_GRAINED_LOCKING ++ if (a->id > b->id) ++ return (1); ++ if (a->id < b->id) ++ return (-1); ++#else + if (a->id[0] > b->id[0]) + return (1); + if (a->id[0] < b->id[0]) @@ -51,6 +66,7 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ + return (1); + if (a->id[1] < b->id[1]) + return (-1); ++#endif +#else int diff; - @@ -58,7 +74,7 @@ $OpenBSD: patch-cache_c,v 1.1 2008/06/13 00:38:12 canacar Exp $ if ((diff = a->proto - b->proto) != 0) return (diff); if ((diff = a->af - b->af) != 0) -@@ -269,6 +288,6 @@ sc_cmp(struct sc_ent *a, struct sc_ent *b) +@@ -269,6 +303,6 @@ return (diff); if ((diff = a->port[1] - b->port[1]) != 0) return (diff); diff --git a/sysutils/pftop/files/extra-patch-cache.h b/sysutils/pftop/files/extra-patch-cache.h index 1340351..4d6e3ac 100644 --- a/sysutils/pftop/files/extra-patch-cache.h +++ b/sysutils/pftop/files/extra-patch-cache.h @@ -1,12 +1,17 @@ +# Adjusted to work with FreeBSD r240233. $OpenBSD: patch-cache_h,v 1.1 2008/06/13 00:38:12 canacar Exp $ --- cache.h.orig Tue Nov 6 23:34:18 2007 +++ cache.h Wed Jun 11 19:50:07 2008 -@@ -31,14 +31,20 @@ +@@ -31,14 +31,24 @@ struct sc_ent { RB_ENTRY(sc_ent) tlink; TAILQ_ENTRY(sc_ent) qlink; +#ifdef HAVE_PFSYNC_STATE ++#ifdef HAVE_FINE_GRAINED_LOCKING ++ u_int64_t id; ++#else + u_int32_t id[2]; ++#endif +#else struct pf_addr addr[2]; +#endif diff --git a/sysutils/pftop/files/extra-patch-pftop.c b/sysutils/pftop/files/extra-patch-pftop.c index 2365213..151734a 100644 --- a/sysutils/pftop/files/extra-patch-pftop.c +++ b/sysutils/pftop/files/extra-patch-pftop.c @@ -1,5 +1,6 @@ -# One chunk of this OpenBSD patch has been removed -# as it's already part of patch-pftop.c +# One chunk of this OpenBSD patch has been removed as it's +# already part of patch-pftop.c, another one has been extended +# to fix the rule display in some views. $OpenBSD: patch-pftop_c,v 1.12 2009/12/02 21:16:10 sthen Exp $ --- pftop.c.orig Wed Nov 7 06:36:46 2007 +++ pftop.c Wed Dec 2 21:14:56 2009 @@ -313,7 +314,7 @@ $OpenBSD: patch-pftop_c,v 1.12 2009/12/02 21:16:10 sthen Exp $ #ifdef HAVE_INOUT_COUNT { u_int64_t sz = COUNTER(s->bytes[0]) + COUNTER(s->bytes[1]); -@@ -988,14 +1161,14 @@ print_state(pf_state_t * s, struct sc_ent * ent) +@@ -988,18 +1161,18 @@ print_state(pf_state_t * s, struct sc_ent * ent) print_fld_size(FLD_PKTS, COUNTER(s->packets[0]) + COUNTER(s->packets[1])); print_fld_size(FLD_BYTES, sz); @@ -332,6 +333,11 @@ $OpenBSD: patch-pftop_c,v 1.12 2009/12/02 21:16:10 sthen Exp $ #endif #ifdef HAVE_PFSYNC_STATE +- print_fld_uint(FLD_RULE, s->rule); ++ print_fld_uint(FLD_RULE, ntohl(s->rule)); + #else + #ifdef HAVE_RULE_NUMBER + print_fld_uint(FLD_RULE, s->rule.nr); @@ -1475,8 +1648,12 @@ print_rule(struct pf_rule *pr) print_fld_str(FLD_LABEL, pr->label); #endif -- 1.8.1.3