- Use github for port fetching
- Remove included patches - Add patch to lock pcbinfo hash [1] - Update version to 20150304 Submitted by: Eugene Grossbein via IRC [1]
This commit is contained in:
parent
62ad7fd2df
commit
5afb323def
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=380427
5 changed files with 9 additions and 216 deletions
|
@ -2,28 +2,28 @@
|
|||
# $FreeBSD$
|
||||
|
||||
PORTNAME= ng_ipacct
|
||||
PORTVERSION= 20061223
|
||||
PORTREVISION= 3
|
||||
PORTVERSION= 20150304
|
||||
CATEGORIES= net-mgmt
|
||||
MASTER_SITES= ${MASTER_SITE_LOCAL:S!$!skv/!} \
|
||||
http://highsecure.ru/distfiles/
|
||||
|
||||
MAINTAINER= vsevolod@FreeBSD.org
|
||||
COMMENT= Netgraph IP accounting
|
||||
|
||||
LICENSE= BSD2CLAUSE
|
||||
|
||||
USE_GITHUB= yes
|
||||
USES= kmod uidfix
|
||||
|
||||
GH_ACCOUNT= vstakhov
|
||||
GH_PROJECT= ng_ipacct
|
||||
GH_TAGNAME= ${PORTVERSION}
|
||||
GH_COMMIT= 68ff97c
|
||||
|
||||
MAKE_ENV= BINDIR="${PREFIX}/sbin"
|
||||
|
||||
USE_RC_SUBR= ng_ipacct
|
||||
SUB_FILES= pkg-message
|
||||
CFLAGS+= -DMEM_USE_ZONE
|
||||
|
||||
post-extract:
|
||||
@${MV} ${WRKDIR}/${PORTNAME} ${WRKSRC}
|
||||
|
||||
post-patch:
|
||||
@${REINPLACE_CMD} 's,{MANDIR},{DESTDIR}$$&,' ${WRKSRC}/man_ru/Makefile
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
SHA256 (ng_ipacct-20061223.tar.gz) = 5c0d1f8626c80d9bc0ec0a5296adcc88645c4309f9accd2619ed852a5a9356e2
|
||||
SIZE (ng_ipacct-20061223.tar.gz) = 25543
|
||||
SHA256 (ng_ipacct-20150304.tar.gz) = 10d0ca1d77cd836edbc0fa258c7db2a428a59a772ec96de4c9213a598e8108cc
|
||||
SIZE (ng_ipacct-20150304.tar.gz) = 24569
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
--- ipacctctl/ipacctctl.c.orig 2010-03-29 23:36:30.000000000 +0700
|
||||
+++ ipacctctl/ipacctctl.c 2010-03-29 23:37:38.000000000 +0700
|
||||
@@ -53,6 +53,10 @@
|
||||
|
||||
#include "../ng_ipacct/ng_ipacct.h"
|
||||
|
||||
+#ifndef NG_PATHLEN
|
||||
+#define NG_PATHLEN (NG_PATHSIZ - 1)
|
||||
+#endif
|
||||
+
|
||||
#define TIME_FMT "%Y/%m/%d %H:%M:%S" /* used in strftime() */
|
||||
#define IN_HOOK 0
|
||||
#define OUT_HOOK 1
|
||||
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
--- ng_ipacct/ng_ipacct.c.orig 2006-12-05 23:46:04.000000000 +0300
|
||||
+++ ng_ipacct/ng_ipacct.c 2013-08-13 16:21:16.000000000 +0400
|
||||
@@ -140,9 +140,6 @@
|
||||
struct ipacct_hook {
|
||||
hook_p hook;
|
||||
node_p node;
|
||||
-#if __FreeBSD_version >= 503000
|
||||
- struct mtx h_mtx; /* protects hook data */
|
||||
-#endif
|
||||
struct ip_acct_hash *active; /* active database */
|
||||
struct ip_acct_hash *checked; /* checkpointed database */
|
||||
struct ng_ipacct_hinfo hi; /* hook info */
|
||||
@@ -242,9 +239,6 @@
|
||||
|
||||
if (!strncmp(name + strlen(name) - 3, "_in", 3))
|
||||
hip->hi.hi_flags |= HI_INCOMING_HOOK;
|
||||
-#if __FreeBSD_version >= 503000
|
||||
- mtx_init(&hip->h_mtx, "ng_ipacct hash", NULL, MTX_DEF);
|
||||
-#endif
|
||||
NG_HOOK_SET_PRIVATE(hook, hip);
|
||||
hip->hi.hi_debug = 0;
|
||||
#ifdef VERBOSE
|
||||
@@ -531,13 +525,7 @@
|
||||
if (!error) {
|
||||
Dbg_print(DBG_DLT, ("IP packet, m_pkthdr.len = %d, m_len = %d\n",
|
||||
m->m_pkthdr.len, m->m_len));
|
||||
-#if __FreeBSD_version >= 503000
|
||||
- mtx_lock(&hip->h_mtx);
|
||||
-#endif
|
||||
error = ip_account_add(hip, &m);
|
||||
-#if __FreeBSD_version >= 503000
|
||||
- mtx_unlock(&hip->h_mtx);
|
||||
-#endif
|
||||
}
|
||||
|
||||
#if __FreeBSD_version >= 503000
|
||||
@@ -581,9 +569,6 @@
|
||||
|
||||
ip_account_stop(hip);
|
||||
NG_HOOK_SET_PRIVATE(hook, NULL);
|
||||
-#if __FreeBSD_version >= 503000
|
||||
- mtx_destroy(&hip->h_mtx);
|
||||
-#endif
|
||||
FREE(hip, M_NETGRAPH);
|
||||
#ifdef VERBOSE
|
||||
printf("NG_ipacct: disconnect hook %s\n", NG_HOOK_NAME(hook));
|
||||
@@ -902,7 +899,11 @@
|
||||
int i;
|
||||
|
||||
for (i = 0, ina = r->r_dst, port = r->r_dport; i < 2; i++) {
|
||||
+#if __FreeBSD_version >= 700110
|
||||
+ pcb = in_pcblookup_local(pcbinfo, ina, port, 1, NOCRED);
|
||||
+#else
|
||||
pcb = in_pcblookup_local(pcbinfo, ina, port, 1);
|
||||
+#endif
|
||||
if ((pcb != NULL) &&
|
||||
(pcb->inp_laddr.s_addr == ina.s_addr)) {
|
||||
break;
|
|
@ -1,134 +0,0 @@
|
|||
--- ng_ipacct/ng_ipacct_hash.h.orig 2004-11-27 23:35:19.000000000 +0300
|
||||
+++ ng_ipacct/ng_ipacct_hash.h 2013-08-13 20:50:07.000000000 +0400
|
||||
@@ -26,7 +26,10 @@
|
||||
* $Id: ng_ipacct_hash.h,v 1.6 2004/11/27 20:35:19 romanp Exp $
|
||||
*/
|
||||
|
||||
-#define NBUCKETS (256) /* must be power of 2 */
|
||||
+#define NBUCKETS (512) /* must be power of 2 */
|
||||
+
|
||||
+#include <sys/lock.h>
|
||||
+#include <sys/rmlock.h>
|
||||
|
||||
#define NG_IPACCT_HASH3(faddr, fport, lport)\
|
||||
((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport)))
|
||||
@@ -34,6 +37,7 @@
|
||||
((faddr ^ (faddr >> 23) ^ (faddr >> 17)))
|
||||
|
||||
struct ip_acct_hash {
|
||||
+ struct rmlock bl;
|
||||
SLIST_HEAD( ,ip_acct_chunk) head;
|
||||
};
|
||||
|
||||
@@ -42,12 +46,20 @@
|
||||
static __inline int
|
||||
ip_hash_init(struct ip_acct_hash **h)
|
||||
{
|
||||
+ int i;
|
||||
+ struct ip_acct_hash *ph;
|
||||
+
|
||||
MALLOC(*h, struct ip_acct_hash *,
|
||||
NBUCKETS * sizeof(struct ip_acct_hash),
|
||||
M_NETGRAPH, M_NOWAIT | M_ZERO);
|
||||
if (*h == NULL)
|
||||
return (ENOMEM);
|
||||
|
||||
+ ph = *h;
|
||||
+ for (i = 0; i < NBUCKETS; i ++) {
|
||||
+ rm_init(&ph[i].bl, "ng_ipacct hash lock");
|
||||
+ }
|
||||
+
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -59,15 +71,18 @@
|
||||
struct ip_acct_chunk *pe, *lastpe;
|
||||
struct ip_acct_record *pr;
|
||||
int i;
|
||||
+ struct rm_priotracker track;
|
||||
#ifdef HASH_DEBUG
|
||||
int nchunk = 0;
|
||||
#endif
|
||||
|
||||
pe = lastpe = NULL;
|
||||
+ rm_rlock(&h[slot].bl, &track);
|
||||
SLIST_FOREACH(pe, &(h[slot].head), next) {
|
||||
lastpe = pe;
|
||||
for (i = 0; i < pe->nrecs; i++) {
|
||||
if(bcmp(s, &pe->recs[i].s, sizeof(struct ip_acct_stream)) == 0) {
|
||||
+ rm_runlock(&h[slot].bl, &track);
|
||||
return (&pe->recs[i]);
|
||||
}
|
||||
}
|
||||
@@ -75,12 +90,29 @@
|
||||
nchunk ++;
|
||||
#endif
|
||||
}
|
||||
+ rm_runlock(&h[slot].bl, &track);
|
||||
#ifdef HASH_DEBUG
|
||||
if (nchunk)
|
||||
nchunk --;
|
||||
#endif
|
||||
/* stream is not in hash. Add it if we allowed to do so. */
|
||||
if (ok_to_insert) {
|
||||
+
|
||||
+ rm_wlock(&h[slot].bl);
|
||||
+ if (lastpe != NULL && SLIST_NEXT(lastpe, next) != NULL) {
|
||||
+ /* It has been changed, need to scan again */
|
||||
+ pe = lastpe;
|
||||
+ while (pe != NULL) {
|
||||
+ lastpe = pe;
|
||||
+ for (i = 0; i < pe->nrecs; i++) {
|
||||
+ if(bcmp(s, &pe->recs[i].s, sizeof(struct ip_acct_stream)) == 0) {
|
||||
+ rm_wunlock(&h[slot].bl);
|
||||
+ return (&pe->recs[i]);
|
||||
+ }
|
||||
+ }
|
||||
+ pe = SLIST_NEXT(pe, next);
|
||||
+ }
|
||||
+ }
|
||||
/*
|
||||
* This is first chunk in slot or no
|
||||
* more space left in current chunk ?
|
||||
@@ -92,8 +124,10 @@
|
||||
sizeof(*pe));
|
||||
#endif
|
||||
/* allocate new accounting chunk */
|
||||
- if ((pe = HASH_ALLOC()) == NULL)
|
||||
+ if ((pe = HASH_ALLOC()) == NULL) {
|
||||
+ rm_wunlock(&h[slot].bl);
|
||||
return (NULL);
|
||||
+ }
|
||||
if (lastpe == NULL)
|
||||
SLIST_INSERT_HEAD(&(h[slot].head), pe, next);
|
||||
else
|
||||
@@ -109,6 +143,7 @@
|
||||
pr->when = time_second;
|
||||
bcopy(s, &pr->s, sizeof(pr->s));
|
||||
(*nrecs) ++;
|
||||
+ rm_wunlock(&h[slot].bl);
|
||||
return (pr);
|
||||
} else {
|
||||
return (NULL);
|
||||
@@ -120,6 +155,7 @@
|
||||
{
|
||||
int i;
|
||||
struct ip_acct_chunk *ipe, *nxt;
|
||||
+ struct ip_acct_hash *ph = *h;
|
||||
|
||||
/* sanity check */
|
||||
if (*h == NULL)
|
||||
@@ -127,10 +163,13 @@
|
||||
|
||||
/* walk down through *next and free all memory */
|
||||
for(i = 0; i < NBUCKETS; i++) {
|
||||
+ rm_wlock(&ph[i].bl);
|
||||
for(ipe = SLIST_FIRST(&((*h)[i].head)); ipe; ipe = nxt) {
|
||||
nxt = SLIST_NEXT(ipe, next);
|
||||
HASH_FREE(ipe);
|
||||
}
|
||||
+ rm_wunlock(&ph[i].bl);
|
||||
+ rm_destroy(&ph[i].bl);
|
||||
}
|
||||
FREE(*h, M_NETGRAPH);
|
||||
*h = NULL;
|
Loading…
Reference in a new issue