update to pmacct-1.7.6

This commit is contained in:
sthen 2021-02-18 13:24:04 +00:00
parent 1f76244d7e
commit 284e5b1f7d
17 changed files with 56 additions and 708 deletions

View File

@ -1,9 +1,8 @@
# $OpenBSD: Makefile,v 1.33 2021/02/03 23:14:18 sthen Exp $
# $OpenBSD: Makefile,v 1.34 2021/02/18 13:24:04 sthen Exp $
COMMENT= passive IP network monitoring tools: traffic accounting, etc
DISTNAME= pmacct-1.7.5
REVISION= 2
DISTNAME= pmacct-1.7.6
CATEGORIES= net
HOMEPAGE= http://www.pmacct.net/
@ -12,28 +11,33 @@ MASTER_SITES= http://www.pmacct.net/
# partly GPLv2 partly ISC (in transition to ISC)
PERMIT_PACKAGE= Yes
WANTLIB += c jansson m maxminddb pcap pthread sodium sqlite3 z zmq
WANTLIB += ${COMPILER_LIBCXX} c cdada jansson m maxminddb pcap pthread
WANTLIB += sodium sqlite3 z zmq
FLAVORS= mysql postgresql
FLAVOR?=
LIB_DEPENDS+= databases/sqlite3 \
devel/jansson \
devel/libcdada \
net/libmaxminddb \
net/zeromq
COMPILER= base-clang ports-gcc
COMPILER_LANGS= c
CONFIGURE_STYLE= autoconf no-autoheader
CONFIGURE_STYLE= autoreconf
AUTOCONF_VERSION= 2.69
AUTOMAKE_VERSION= 1.16
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include"
CONFIGURE_ARGS= --enable-ipv6 \
--enable-geoipv2 \
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib" \
CXXLIB="${CXXLIB}"
CONFIGURE_ARGS= --enable-geoipv2 \
--enable-jansson \
--enable-sqlite3 \
--enable-zmq
--enable-zmq \
--without-external-deps
MAKE_ENV= ${AUTOCONF_ENV}
USE_GMAKE= Yes
NO_TEST= Yes
@ -63,7 +67,14 @@ post-install:
cd ${WRKSRC}/examples; \
${INSTALL_PROGRAM} lg/pmbgp ${PREFIX}/share/examples/pmacct/lg/; \
${INSTALL_DATA} lg/pmbgp.py ${PREFIX}/share/examples/pmacct/lg/
#${INSTALL_DATA} ${WRKSRC}/sql/!(README*) \
${PREFIX}/share/examples/pmacct/sql/
.if !${FLAVOR:Mmysql}
rm ${PREFIX}/share/pmacct/sql/*.mysql
.endif
.if !${FLAVOR:Mpostgresql}
rm ${PREFIX}/share/pmacct/sql/*.pgsql
.endif
.include <bsd.port.mk>
.for i in ${COMPILER_LIBCXX}
CXXLIB+= -l$i
.endfor

View File

@ -1,2 +1,2 @@
SHA256 (pmacct-1.7.5.tar.gz) = LneL083ZaMS58i4oAIubcvIpmAIB0swu4EywL2sL3NU=
SIZE (pmacct-1.7.5.tar.gz) = 1626770
SHA256 (pmacct-1.7.6.tar.gz) = qkQH/lUkEvVnkO8bj94BpT6AE2SIyJ+R5DyEgl8TV/M=
SIZE (pmacct-1.7.6.tar.gz) = 2126837

View File

@ -1,9 +1,14 @@
$OpenBSD: patch-configure_ac,v 1.2 2021/01/18 10:24:49 sthen Exp $
$OpenBSD: patch-configure_ac,v 1.3 2021/02/18 13:24:04 sthen Exp $
drop forced -O2
handle libcdada dependency on C++ standard library
only linux requires libnuma for mysql
Index: configure.ac
--- configure.ac.orig
+++ configure.ac
@@ -26,12 +26,6 @@ AC_MSG_RESULT($host_os)
@@ -30,12 +30,6 @@ AC_MSG_RESULT($host_os)
AC_MSG_CHECKING(hardware)
AC_MSG_RESULT($host_cpu)
@ -16,3 +21,23 @@ Index: configure.ac
AC_CHECK_FUNCS([strlcpy])
dnl: shared object handling
@@ -406,10 +400,6 @@ AC_ARG_ENABLE(mysql,
CFLAGS="$CFLAGS $MYSQL_CFLAGS"
AC_CHECK_HEADERS([mysql.h mysql/mysql.h])
CFLAGS="$_save_CFLAGS"
-
- AC_CHECK_LIB([numa], [numa_bind], [], [AC_MSG_ERROR([
- ERROR: missing libnuma. Requirement for building MySQL.
- ])])
;;
no)
AC_MSG_RESULT(no)
@@ -1138,7 +1128,7 @@ AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[])],[AC_MSG_RESULT(yes)],[AC_MSG_ERROR([No C++ compiler found])])
AC_LANG_POP([C++])
-LIBS="-lcdada -lstdc++ ${LIBS}"
+LIBS="-lcdada ${CXXLIB} ${LIBS}"
AS_CASE(["$WITH_EXTERNAL_DEPS"],
[yes], [],
[no], [AC_CHECK_LIB([cdada], [cdada_get_ver], [], [AC_MSG_ERROR([Could not find libcdada])])],

View File

@ -1,9 +1,9 @@
$OpenBSD: patch-src_isis_isis_c,v 1.4 2021/01/18 10:24:49 sthen Exp $
$OpenBSD: patch-src_isis_isis_c,v 1.5 2021/02/18 13:24:04 sthen Exp $
Index: src/isis/isis.c
--- src/isis/isis.c.orig
+++ src/isis/isis.c
@@ -806,7 +806,7 @@ void igp_daemon_map_initialize(char *filename, struct
@@ -808,7 +808,7 @@ void igp_daemon_map_initialize(char *filename, struct
pcap_t *p;
if (config.debug && config.igp_daemon_map_msglog) {

View File

@ -1,72 +0,0 @@
$OpenBSD: patch-src_mysql_plugin_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/mysql_plugin.c
--- src/mysql_plugin.c.orig
+++ src/mysql_plugin.c
@@ -170,7 +170,7 @@ void mysql_plugin(int pipe_fd, struct configuration *c
/* lazy sql refresh handling */
if (idata.now > refresh_deadline) {
- if (qq_ptr) sql_cache_flush(sql_queries_queue, qq_ptr, &idata, FALSE);
+ if (sql_qq_ptr) sql_cache_flush(sql_queries_queue, sql_qq_ptr, &idata, FALSE);
sql_cache_handle_flush_event(&idata, &refresh_deadline, &pt);
}
else {
@@ -272,7 +272,7 @@ void mysql_plugin(int pipe_fd, struct configuration *c
}
prim_ptrs.data = data;
- (*insert_func)(&prim_ptrs, &idata);
+ (*sql_insert_func)(&prim_ptrs, &idata);
((struct ch_buf_hdr *)pipebuf)->num--;
if (((struct ch_buf_hdr *)pipebuf)->num) {
@@ -469,7 +469,7 @@ void MY_cache_purge(struct db_cache *queue[], int inde
/* re-using pending queries queue stuff from parent and saving clauses */
memcpy(sql_pending_queries_queue, queue, index*sizeof(struct db_cache *));
- pqq_ptr = index;
+ sql_pqq_ptr = index;
strlcpy(orig_insert_clause, insert_clause, LONGSRVBUFLEN);
strlcpy(orig_update_clause, update_clause, LONGSRVBUFLEN);
@@ -477,9 +477,9 @@ void MY_cache_purge(struct db_cache *queue[], int inde
start:
memset(&idata->mv, 0, sizeof(struct multi_values));
- memcpy(queue, sql_pending_queries_queue, pqq_ptr*sizeof(struct db_cache *));
- memset(sql_pending_queries_queue, 0, pqq_ptr*sizeof(struct db_cache *));
- index = pqq_ptr; pqq_ptr = 0;
+ memcpy(queue, sql_pending_queries_queue, sql_pqq_ptr*sizeof(struct db_cache *));
+ memset(sql_pending_queries_queue, 0, sql_pqq_ptr*sizeof(struct db_cache *));
+ index = sql_pqq_ptr; sql_pqq_ptr = 0;
/* We check for variable substitution in SQL table */
if (idata->dyn_table) {
@@ -526,9 +526,9 @@ void MY_cache_purge(struct db_cache *queue[], int inde
pm_strftime_same(tmptable, LONGSRVBUFLEN, tmpbuf, &stamp, config.timestamps_utc);
if (strncmp(idata->dyn_table_name, tmptable, SRVBUFLEN)) {
- sql_pending_queries_queue[pqq_ptr] = queue[idata->current_queue_elem];
+ sql_pending_queries_queue[sql_pqq_ptr] = queue[idata->current_queue_elem];
- pqq_ptr++;
+ sql_pqq_ptr++;
go_to_pending = TRUE;
}
}
@@ -553,7 +553,7 @@ void MY_cache_purge(struct db_cache *queue[], int inde
if (b.fail) Log(LOG_ALERT, "ALERT ( %s/%s ): recovery for MySQL daemon failed.\n", config.name, config.type);
/* If we have pending queries then start again */
- if (pqq_ptr) goto start;
+ if (sql_pqq_ptr) goto start;
idata->elap_time = time(NULL)-start;
Log(LOG_INFO, "INFO ( %s/%s ): *** Purging cache - END (PID: %u, QN: %u/%u, ET: %lu) ***\n",

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-src_nfacctd_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/nfacctd.c
--- src/nfacctd.c.orig
+++ src/nfacctd.c
@@ -49,7 +49,6 @@ struct template_cache tpl_cache;
struct host_addr debug_a;
char debug_agent_addr[50];
u_int16_t debug_agent_port;
-struct channels_list_entry channels_list[MAX_N_PLUGINS]; /* communication channels: core <-> plugins */
/* Functions */
void usage_daemon(char *prog_name)

View File

@ -1,72 +0,0 @@
$OpenBSD: patch-src_pgsql_plugin_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/pgsql_plugin.c
--- src/pgsql_plugin.c.orig
+++ src/pgsql_plugin.c
@@ -178,7 +178,7 @@ void pgsql_plugin(int pipe_fd, struct configuration *c
}
if (idata.now > refresh_deadline) {
- if (qq_ptr) sql_cache_flush(sql_queries_queue, qq_ptr, &idata, FALSE);
+ if (sql_qq_ptr) sql_cache_flush(sql_queries_queue, sql_qq_ptr, &idata, FALSE);
sql_cache_handle_flush_event(&idata, &refresh_deadline, &pt);
}
else {
@@ -281,7 +281,7 @@ void pgsql_plugin(int pipe_fd, struct configuration *c
}
prim_ptrs.data = data;
- (*insert_func)(&prim_ptrs, &idata);
+ (*sql_insert_func)(&prim_ptrs, &idata);
((struct ch_buf_hdr *)pipebuf)->num--;
if (((struct ch_buf_hdr *)pipebuf)->num) {
@@ -473,7 +473,7 @@ void PG_cache_purge(struct db_cache *queue[], int inde
/* re-using pending queries queue stuff from parent and saving clauses */
memcpy(sql_pending_queries_queue, queue, index*sizeof(struct db_cache *));
- pqq_ptr = index;
+ sql_pqq_ptr = index;
strlcpy(orig_copy_clause, copy_clause, LONGSRVBUFLEN);
strlcpy(orig_insert_clause, insert_clause, LONGSRVBUFLEN);
@@ -481,9 +481,9 @@ void PG_cache_purge(struct db_cache *queue[], int inde
strlcpy(orig_lock_clause, lock_clause, LONGSRVBUFLEN);
start:
- memcpy(queue, sql_pending_queries_queue, pqq_ptr*sizeof(struct db_cache *));
- memset(sql_pending_queries_queue, 0, pqq_ptr*sizeof(struct db_cache *));
- index = pqq_ptr; pqq_ptr = 0;
+ memcpy(queue, sql_pending_queries_queue, sql_pqq_ptr*sizeof(struct db_cache *));
+ memset(sql_pending_queries_queue, 0, sql_pqq_ptr*sizeof(struct db_cache *));
+ index = sql_pqq_ptr; sql_pqq_ptr = 0;
/* We check for variable substitution in SQL table */
if (idata->dyn_table) {
@@ -544,9 +544,9 @@ void PG_cache_purge(struct db_cache *queue[], int inde
pm_strftime_same(tmptable, LONGSRVBUFLEN, tmpbuf, &stamp, config.timestamps_utc);
if (strncmp(idata->dyn_table_name, tmptable, SRVBUFLEN)) {
- sql_pending_queries_queue[pqq_ptr] = queue[idata->current_queue_elem];
+ sql_pending_queries_queue[sql_pqq_ptr] = queue[idata->current_queue_elem];
- pqq_ptr++;
+ sql_pqq_ptr++;
go_to_pending = TRUE;
}
}
@@ -608,7 +608,7 @@ void PG_cache_purge(struct db_cache *queue[], int inde
}
/* If we have pending queries then start again */
- if (pqq_ptr) goto start;
+ if (sql_pqq_ptr) goto start;
idata->elap_time = time(NULL)-start;
Log(LOG_INFO, "INFO ( %s/%s ): *** Purging cache - END (PID: %u, QN: %u/%u, ET: %lu) ***\n",

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-src_pmacctd_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/pmacctd.c
--- src/pmacctd.c.orig
+++ src/pmacctd.c
@@ -40,9 +40,6 @@
#endif
#include "jhash.h"
-/* variables to be exported away */
-struct channels_list_entry channels_list[MAX_N_PLUGINS]; /* communication channels: core <-> plugins */
-
/* Functions */
void usage_daemon(char *prog_name)
{

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-src_pmbgpd_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/pmbgpd.c
--- src/pmbgpd.c.orig
+++ src/pmbgpd.c
@@ -34,9 +34,6 @@
#include "net_aggr.h"
#include "thread_pool.h"
-/* global var */
-struct channels_list_entry channels_list[MAX_N_PLUGINS]; /* communication channels: core <-> plugins */
-
/* Functions */
void usage_daemon(char *prog_name)
{

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-src_pmbmpd_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/pmbmpd.c
--- src/pmbmpd.c.orig
+++ src/pmbmpd.c
@@ -32,9 +32,6 @@
#include "classifier.h"
#include "net_aggr.h"
-/* global var */
-struct channels_list_entry channels_list[MAX_N_PLUGINS]; /* communication channels: core <-> plugins */
-
/* Functions */
void usage_daemon(char *prog_name)
{

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-src_pmtelemetryd_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/pmtelemetryd.c
--- src/pmtelemetryd.c.orig
+++ src/pmtelemetryd.c
@@ -32,9 +32,6 @@
#include "classifier.h"
#include "net_aggr.h"
-/* global var */
-struct channels_list_entry channels_list[MAX_N_PLUGINS]; /* communication channels: core <-> plugins */
-
/* Functions */
void usage_daemon(char *prog_name)
{

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-src_sfacctd_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/sfacctd.c
--- src/sfacctd.c.orig
+++ src/sfacctd.c
@@ -50,7 +50,6 @@
#endif
/* variables to be exported away */
-struct channels_list_entry channels_list[MAX_N_PLUGINS]; /* communication channels: core <-> plugins */
int sfacctd_counter_backend_methods;
struct bgp_misc_structs *sf_cnt_misc_db;
struct host_addr debug_a;

View File

@ -1,290 +0,0 @@
$OpenBSD: patch-src_sql_common_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/sql_common.c
--- src/sql_common.c.orig
+++ src/sql_common.c
@@ -45,8 +45,8 @@ unsigned char *pipebuf;
struct db_cache *sql_cache;
struct db_cache **sql_queries_queue, **sql_pending_queries_queue;
struct db_cache *collision_queue;
-int cq_ptr, qq_ptr, qq_size, pp_size, pb_size, pn_size, pm_size, pt_size;
-int pc_size, dbc_size, cq_size, pqq_ptr;
+int cq_ptr, sql_qq_ptr, qq_size, sql_pp_size, sql_pb_size, sql_pn_size, sql_pm_size, sql_pt_size;
+int sql_pc_size, sql_dbc_size, cq_size, sql_pqq_ptr;
struct db_cache lru_head, *lru_tail;
struct frags where[N_PRIMITIVES+2];
struct frags values[N_PRIMITIVES+2];
@@ -61,7 +61,7 @@ int glob_dyn_table, glob_dyn_table_time_only; /* last
int glob_timeslot; /* last resort for sql handlers */
struct sqlfunc_cb_registry sqlfunc_cbr;
-void (*insert_func)(struct primitives_ptrs *, struct insert_data *);
+void (*sql_insert_func)(struct primitives_ptrs *, struct insert_data *);
struct DBdesc p;
struct DBdesc b;
struct BE_descs bed;
@@ -82,13 +82,13 @@ void sql_set_signals()
void sql_set_insert_func()
{
if (config.what_to_count & (COUNT_SUM_HOST|COUNT_SUM_NET))
- insert_func = sql_sum_host_insert;
- else if (config.what_to_count & COUNT_SUM_PORT) insert_func = sql_sum_port_insert;
- else if (config.what_to_count & COUNT_SUM_AS) insert_func = sql_sum_as_insert;
+ sql_insert_func = sql_sum_host_insert;
+ else if (config.what_to_count & COUNT_SUM_PORT) sql_insert_func = sql_sum_port_insert;
+ else if (config.what_to_count & COUNT_SUM_AS) sql_insert_func = sql_sum_as_insert;
#if defined (HAVE_L2)
- else if (config.what_to_count & COUNT_SUM_MAC) insert_func = sql_sum_mac_insert;
+ else if (config.what_to_count & COUNT_SUM_MAC) sql_insert_func = sql_sum_mac_insert;
#endif
- else insert_func = sql_cache_insert;
+ else sql_insert_func = sql_cache_insert;
}
void sql_init_maps(struct extra_primitives *extras, struct primitives_ptrs *prim_ptrs,
@@ -195,16 +195,16 @@ void sql_init_default_values(struct extra_primitives *
}
}
- qq_ptr = 0;
- pqq_ptr = 0;
+ sql_qq_ptr = 0;
+ sql_pqq_ptr = 0;
qq_size = config.sql_cache_entries+(config.sql_refresh_time*REASONABLE_NUMBER);
- pp_size = sizeof(struct pkt_primitives);
- pb_size = sizeof(struct pkt_bgp_primitives);
- pn_size = sizeof(struct pkt_nat_primitives);
- pm_size = sizeof(struct pkt_mpls_primitives);
- pt_size = sizeof(struct pkt_tunnel_primitives);
- pc_size = config.cpptrs.len;
- dbc_size = sizeof(struct db_cache);
+ sql_pp_size = sizeof(struct pkt_primitives);
+ sql_pb_size = sizeof(struct pkt_bgp_primitives);
+ sql_pn_size = sizeof(struct pkt_nat_primitives);
+ sql_pm_size = sizeof(struct pkt_mpls_primitives);
+ sql_pt_size = sizeof(struct pkt_tunnel_primitives);
+ sql_pc_size = config.cpptrs.len;
+ sql_dbc_size = sizeof(struct db_cache);
/* handling purge preprocessor */
set_preprocess_funcs(config.sql_preprocess, &prep, PREP_DICT_SQL);
@@ -327,12 +327,12 @@ void sql_cache_modulo(struct primitives_ptrs *prim_ptr
u_char *pcust = prim_ptrs->pcust;
struct pkt_vlen_hdr_primitives *pvlen = prim_ptrs->pvlen;
- idata->hash = cache_crc32((unsigned char *)srcdst, pp_size);
- if (pbgp) idata->hash ^= cache_crc32((unsigned char *)pbgp, pb_size);
- if (pnat) idata->hash ^= cache_crc32((unsigned char *)pnat, pn_size);
- if (pmpls) idata->hash ^= cache_crc32((unsigned char *)pmpls, pm_size);
- if (ptun) idata->hash ^= cache_crc32((unsigned char *)ptun, pt_size);
- if (pcust) idata->hash ^= cache_crc32((unsigned char *)pcust, pc_size);
+ idata->hash = cache_crc32((unsigned char *)srcdst, sql_pp_size);
+ if (pbgp) idata->hash ^= cache_crc32((unsigned char *)pbgp, sql_pb_size);
+ if (pnat) idata->hash ^= cache_crc32((unsigned char *)pnat, sql_pn_size);
+ if (pmpls) idata->hash ^= cache_crc32((unsigned char *)pmpls, sql_pm_size);
+ if (ptun) idata->hash ^= cache_crc32((unsigned char *)ptun, sql_pt_size);
+ if (pcust) idata->hash ^= cache_crc32((unsigned char *)pcust, sql_pc_size);
if (pvlen) idata->hash ^= cache_crc32((unsigned char *)pvlen, (PvhdrSz + pvlen->tot_len));
idata->modulo = idata->hash % config.sql_cache_entries;
@@ -360,14 +360,14 @@ int sql_cache_flush(struct db_cache *queue[], int inde
else idata->committed_basetime = idata->basetime;
if (!exiting) {
- for (j = 0, pqq_ptr = 0; j < index; j++) {
+ for (j = 0, sql_pqq_ptr = 0; j < index; j++) {
if (new_basetime && queue[j]->basetime+delay >= idata->basetime) {
- sql_pending_queries_queue[pqq_ptr] = queue[j];
- pqq_ptr++;
+ sql_pending_queries_queue[sql_pqq_ptr] = queue[j];
+ sql_pqq_ptr++;
}
else if (!new_basetime && queue[j]->basetime+delay > idata->basetime) {
- sql_pending_queries_queue[pqq_ptr] = queue[j];
- pqq_ptr++;
+ sql_pending_queries_queue[sql_pqq_ptr] = queue[j];
+ sql_pqq_ptr++;
}
else queue[j]->valid = SQL_CACHE_COMMITTED;
}
@@ -456,7 +456,7 @@ void sql_cache_handle_flush_event(struct insert_data *
pm_setproctitle("%s %s [%s]", config.type, "Plugin -- DB Writer", config.name);
config.is_forked = TRUE;
- if (qq_ptr) {
+ if (sql_qq_ptr) {
if (dump_writers_get_flags() == CHLD_WARNING) sql_db_fail(&p);
if (!strcmp(config.type, "mysql"))
(*sqlfunc_cbr.connect)(&p, config.sql_host);
@@ -464,10 +464,10 @@ void sql_cache_handle_flush_event(struct insert_data *
(*sqlfunc_cbr.connect)(&p, NULL);
}
- /* qq_ptr check inside purge function along with a Log() call */
- (*sqlfunc_cbr.purge)(sql_queries_queue, qq_ptr, idata);
+ /* sql_qq_ptr check inside purge function along with a Log() call */
+ (*sqlfunc_cbr.purge)(sql_queries_queue, sql_qq_ptr, idata);
- if (qq_ptr) (*sqlfunc_cbr.close)(&bed);
+ if (sql_qq_ptr) (*sqlfunc_cbr.close)(&bed);
if (config.sql_trigger_exec) {
if (idata->now > idata->triggertime) sql_trigger_exec(config.sql_trigger_exec);
@@ -483,7 +483,7 @@ void sql_cache_handle_flush_event(struct insert_data *
}
else Log(LOG_WARNING, "WARN ( %s/%s ): Maximum number of writer processes reached (%d).\n", config.name, config.type, dump_writers_get_active());
- if (pqq_ptr) sql_cache_flush_pending(sql_pending_queries_queue, pqq_ptr, idata);
+ if (sql_pqq_ptr) sql_cache_flush_pending(sql_pending_queries_queue, sql_pqq_ptr, idata);
gettimeofday(&idata->flushtime, NULL);
while (idata->now > *refresh_deadline)
*refresh_deadline += config.sql_refresh_time;
@@ -495,8 +495,8 @@ void sql_cache_handle_flush_event(struct insert_data *
idata->new_basetime = FALSE;
glob_new_basetime = FALSE;
- qq_ptr = pqq_ptr;
- memcpy(sql_queries_queue, sql_pending_queries_queue, qq_ptr*sizeof(struct db_cache *));
+ sql_qq_ptr = sql_pqq_ptr;
+ memcpy(sql_queries_queue, sql_pending_queries_queue, sql_qq_ptr*sizeof(struct db_cache *));
if (reload_map) {
load_networks(config.networks_file, &nt, &nc);
@@ -773,9 +773,9 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
}
if (insert_status == SQL_INSERT_INSERT) {
- if (qq_ptr < qq_size) {
- sql_queries_queue[qq_ptr] = Cursor;
- qq_ptr++;
+ if (sql_qq_ptr < qq_size) {
+ sql_queries_queue[sql_qq_ptr] = Cursor;
+ sql_qq_ptr++;
}
else SafePtr = Cursor;
@@ -784,10 +784,10 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
if (pbgp) {
if (!Cursor->pbgp) {
- Cursor->pbgp = (struct pkt_bgp_primitives *) malloc(pb_size);
+ Cursor->pbgp = (struct pkt_bgp_primitives *) malloc(sql_pb_size);
if (!Cursor->pbgp) goto safe_action;
}
- memcpy(Cursor->pbgp, pbgp, pb_size);
+ memcpy(Cursor->pbgp, pbgp, sql_pb_size);
}
else {
if (Cursor->pbgp) free(Cursor->pbgp);
@@ -796,10 +796,10 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
if (pnat) {
if (!Cursor->pnat) {
- Cursor->pnat = (struct pkt_nat_primitives *) malloc(pn_size);
+ Cursor->pnat = (struct pkt_nat_primitives *) malloc(sql_pn_size);
if (!Cursor->pnat) goto safe_action;
}
- memcpy(Cursor->pnat, pnat, pn_size);
+ memcpy(Cursor->pnat, pnat, sql_pn_size);
}
else {
if (Cursor->pnat) free(Cursor->pnat);
@@ -808,10 +808,10 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
if (pmpls) {
if (!Cursor->pmpls) {
- Cursor->pmpls = (struct pkt_mpls_primitives *) malloc(pm_size);
+ Cursor->pmpls = (struct pkt_mpls_primitives *) malloc(sql_pm_size);
if (!Cursor->pmpls) goto safe_action;
}
- memcpy(Cursor->pmpls, pmpls, pm_size);
+ memcpy(Cursor->pmpls, pmpls, sql_pm_size);
}
else {
if (Cursor->pmpls) free(Cursor->pmpls);
@@ -820,10 +820,10 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
if (ptun) {
if (!Cursor->ptun) {
- Cursor->ptun = (struct pkt_tunnel_primitives *) malloc(pt_size);
+ Cursor->ptun = (struct pkt_tunnel_primitives *) malloc(sql_pt_size);
if (!Cursor->ptun) goto safe_action;
}
- memcpy(Cursor->ptun, ptun, pt_size);
+ memcpy(Cursor->ptun, ptun, sql_pt_size);
}
else {
if (Cursor->ptun) free(Cursor->ptun);
@@ -832,10 +832,10 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
if (pcust) {
if (!Cursor->pcust) {
- Cursor->pcust = malloc(pc_size);
+ Cursor->pcust = malloc(sql_pc_size);
if (!Cursor->pcust) goto safe_action;
}
- memcpy(Cursor->pcust, pcust, pc_size);
+ memcpy(Cursor->pcust, pcust, sql_pc_size);
}
else {
if (Cursor->pcust) free(Cursor->pcust);
@@ -948,7 +948,7 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
Log(LOG_INFO, "INFO ( %s/%s ): Finished cache entries (ie. sql_cache_entries). Purging.\n", config.name, config.type);
- if (qq_ptr) sql_cache_flush(sql_queries_queue, qq_ptr, idata, FALSE);
+ if (sql_qq_ptr) sql_cache_flush(sql_queries_queue, sql_qq_ptr, idata, FALSE);
dump_writers_count();
if (dump_writers_get_flags() != CHLD_ALERT) {
@@ -959,10 +959,10 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
pm_setproctitle("%s [%s]", "SQL Plugin -- DB Writer (urgent)", config.name);
config.is_forked = TRUE;
- if (qq_ptr) {
+ if (sql_qq_ptr) {
if (dump_writers_get_flags() == CHLD_WARNING) sql_db_fail(&p);
(*sqlfunc_cbr.connect)(&p, config.sql_host);
- (*sqlfunc_cbr.purge)(sql_queries_queue, qq_ptr, idata);
+ (*sqlfunc_cbr.purge)(sql_queries_queue, sql_qq_ptr, idata);
(*sqlfunc_cbr.close)(&bed);
}
@@ -976,12 +976,12 @@ void sql_cache_insert(struct primitives_ptrs *prim_ptr
}
else Log(LOG_WARNING, "WARN ( %s/%s ): Maximum number of writer processes reached (%d).\n", config.name, config.type, dump_writers_get_active());
- qq_ptr = pqq_ptr;
+ sql_qq_ptr = sql_pqq_ptr;
memcpy(sql_queries_queue, sql_pending_queries_queue, sizeof(*sql_queries_queue));
if (SafePtr) {
- sql_queries_queue[qq_ptr] = Cursor;
- qq_ptr++;
+ sql_queries_queue[sql_qq_ptr] = Cursor;
+ sql_qq_ptr++;
}
else {
Cursor = &sql_cache[idata->modulo];
@@ -1105,13 +1105,13 @@ void sql_exit_gracefully(int signum)
if (config.sql_backup_host) idata.recover = TRUE;
if (config.sql_locking_style) idata.locks = sql_select_locking_style(config.sql_locking_style);
- sql_cache_flush(sql_queries_queue, qq_ptr, &idata, TRUE);
+ sql_cache_flush(sql_queries_queue, sql_qq_ptr, &idata, TRUE);
dump_writers_count();
if (dump_writers_get_flags() != CHLD_ALERT) {
if (dump_writers_get_flags() == CHLD_WARNING) sql_db_fail(&p);
(*sqlfunc_cbr.connect)(&p, config.sql_host);
- (*sqlfunc_cbr.purge)(sql_queries_queue, qq_ptr, &idata);
+ (*sqlfunc_cbr.purge)(sql_queries_queue, sql_qq_ptr, &idata);
(*sqlfunc_cbr.close)(&bed);
}
else Log(LOG_WARNING, "WARN ( %s/%s ): Maximum number of writer processes reached (%d).\n", config.name, config.type, dump_writers_get_active());

View File

@ -1,39 +0,0 @@
$OpenBSD: patch-src_sql_common_h,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/sql_common.h
--- src/sql_common.h.orig
+++ src/sql_common.h
@@ -1,6 +1,6 @@
/*
pmacct (Promiscuous mode IP Accounting package)
- pmacct is Copyright (C) 2003-2019 by Paolo Lucente
+ pmacct is Copyright (C) 2003-2020 by Paolo Lucente
*/
/*
@@ -374,8 +374,8 @@ extern unsigned char *pipebuf;
extern struct db_cache *sql_cache;
extern struct db_cache **sql_queries_queue, **sql_pending_queries_queue;
extern struct db_cache *collision_queue;
-extern int cq_ptr, qq_ptr, qq_size, pp_size, pb_size, pn_size, pm_size, pt_size;
-extern int pc_size, dbc_size, cq_size, pqq_ptr;
+extern int cq_ptr, sql_qq_ptr, qq_size, sql_pp_size, sql_pb_size, sql_pn_size, sql_pm_size, sql_pt_size;
+extern int sql_pc_size, sql_dbc_size, cq_size, sql_pqq_ptr;
extern struct db_cache lru_head, *lru_tail;
extern struct frags where[N_PRIMITIVES+2];
extern struct frags values[N_PRIMITIVES+2];
@@ -390,7 +390,7 @@ extern int glob_dyn_table, glob_dyn_table_time_only; /
extern int glob_timeslot; /* last resort for sql handlers */
extern struct sqlfunc_cb_registry sqlfunc_cbr;
-extern void (*insert_func)(struct primitives_ptrs *, struct insert_data *);
+extern void (*sql_insert_func)(struct primitives_ptrs *, struct insert_data *);
extern struct DBdesc p;
extern struct DBdesc b;
extern struct BE_descs bed;

View File

@ -1,72 +0,0 @@
$OpenBSD: patch-src_sqlite3_plugin_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/sqlite3_plugin.c
--- src/sqlite3_plugin.c.orig
+++ src/sqlite3_plugin.c
@@ -164,7 +164,7 @@ void sqlite3_plugin(int pipe_fd, struct configuration
}
if (idata.now > refresh_deadline) {
- if (qq_ptr) sql_cache_flush(sql_queries_queue, qq_ptr, &idata, FALSE);
+ if (sql_qq_ptr) sql_cache_flush(sql_queries_queue, sql_qq_ptr, &idata, FALSE);
sql_cache_handle_flush_event(&idata, &refresh_deadline, &pt);
}
else {
@@ -266,7 +266,7 @@ void sqlite3_plugin(int pipe_fd, struct configuration
}
prim_ptrs.data = data;
- (*insert_func)(&prim_ptrs, &idata);
+ (*sql_insert_func)(&prim_ptrs, &idata);
((struct ch_buf_hdr *)pipebuf)->num--;
if (((struct ch_buf_hdr *)pipebuf)->num) {
@@ -449,7 +449,7 @@ void SQLI_cache_purge(struct db_cache *queue[], int in
/* re-using pending queries queue stuff from parent and saving clauses */
memcpy(sql_pending_queries_queue, queue, index*sizeof(struct db_cache *));
- pqq_ptr = index;
+ sql_pqq_ptr = index;
strlcpy(orig_insert_clause, insert_clause, LONGSRVBUFLEN);
strlcpy(orig_update_clause, update_clause, LONGSRVBUFLEN);
@@ -457,9 +457,9 @@ void SQLI_cache_purge(struct db_cache *queue[], int in
start:
memset(&idata->mv, 0, sizeof(struct multi_values));
- memcpy(queue, sql_pending_queries_queue, pqq_ptr*sizeof(struct db_cache *));
- memset(sql_pending_queries_queue, 0, pqq_ptr*sizeof(struct db_cache *));
- index = pqq_ptr; pqq_ptr = 0;
+ memcpy(queue, sql_pending_queries_queue, sql_pqq_ptr*sizeof(struct db_cache *));
+ memset(sql_pending_queries_queue, 0, sql_pqq_ptr*sizeof(struct db_cache *));
+ index = sql_pqq_ptr; sql_pqq_ptr = 0;
/* We check for variable substitution in SQL table */
if (idata->dyn_table) {
@@ -507,9 +507,9 @@ void SQLI_cache_purge(struct db_cache *queue[], int in
pm_strftime_same(tmptable, LONGSRVBUFLEN, tmpbuf, &stamp, config.timestamps_utc);
if (strncmp(idata->dyn_table_name, tmptable, SRVBUFLEN)) {
- sql_pending_queries_queue[pqq_ptr] = queue[idata->current_queue_elem];
+ sql_pending_queries_queue[sql_pqq_ptr] = queue[idata->current_queue_elem];
- pqq_ptr++;
+ sql_pqq_ptr++;
go_to_pending = TRUE;
}
}
@@ -534,7 +534,7 @@ void SQLI_cache_purge(struct db_cache *queue[], int in
if (b.fail) Log(LOG_ALERT, "ALERT ( %s/%s ): recovery for SQLite3 daemon failed.\n", config.name, config.type);
/* If we have pending queries then start again */
- if (pqq_ptr) goto start;
+ if (sql_pqq_ptr) goto start;
idata->elap_time = time(NULL)-start;
Log(LOG_INFO, "INFO ( %s/%s ): *** Purging cache - END (PID: %u, QN: %u/%u, ET: %lu) ***\n",

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-src_uacctd_c,v 1.1 2021/02/03 23:14:18 sthen Exp $
From abc6a2fd647aa97707acd7ae3e44785de3aea4d3 Mon Sep 17 00:00:00 2001
From: Paolo Lucente <pl+github@pmacct.net>
Date: Mon, 18 May 2020 11:56:46 +0000
Subject: [PATCH] * fix, renamed some variables and unified declaration of
others in order to be more gcc10 friendly. Related to Issue #394
Index: src/uacctd.c
--- src/uacctd.c.orig
+++ src/uacctd.c
@@ -41,9 +41,6 @@
#include "ndpi/ndpi.h"
#endif
-/* variables to be exported away */
-struct channels_list_entry channels_list[MAX_N_PLUGINS]; /* communication channels: core <-> plugins */
-
/* Functions */
static int nflog_incoming(struct nflog_g_handle *gh, struct nfgenmsg *nfmsg,
struct nflog_data *nfa, void *p)

View File

@ -1,4 +1,5 @@
@comment $OpenBSD: PFRAG.mysql,v 1.6 2021/01/18 10:24:49 sthen Exp $
@comment $OpenBSD: PFRAG.mysql,v 1.7 2021/02/18 13:24:04 sthen Exp $
share/pmacct/sql/README.mysql
share/pmacct/sql/pmacct-create-db_bgp_v1.mysql
share/pmacct/sql/pmacct-create-db_v1.mysql
share/pmacct/sql/pmacct-create-db_v2.mysql
@ -10,4 +11,3 @@ share/pmacct/sql/pmacct-create-db_v7.mysql
share/pmacct/sql/pmacct-create-db_v8.mysql
share/pmacct/sql/pmacct-create-db_v9.mysql
share/pmacct/sql/pmacct-grant-db.mysql
share/pmacct/sql/README.mysql