Skip to contentSkip to conversation

ulogd2 / DBI / table name

PATCH Applied Harald Welte 2 participants 3 messages Feb 12, 2012 – Feb 24, 2012 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ulogd2 / DBI / table name

Hi!

I've tried to use the DBI plugin of ulogd2 for NFCT based accounting, and despite using table="conntrack", it always insisted in using the table "ulog" for deriving the keys/columns to be stored.

I've hacked up a quick fix, and it seems to work as expected (though no proper null temrmination after strncpy).

As I've been absent from ulogd and netfilter hacking for some time, I tohught I'd post it here rather than pushing something to the git repo...

Regards,
Harald

Signature · 5 lines
- Harald Welte <[email protected]>                 http://netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
output/dbi/ulogd_output_DBI.c +4 -1
index 88730e6..4b3ec16 100644
@@ -102,7 +102,8 @@ static void str_tolower(char *s)
 static int get_columns_dbi(struct ulogd_pluginstance *upi)
 {
 	struct dbi_instance *pi = (struct dbi_instance *) upi->private;
-	char query[256] = "SELECT * FROM ulog\0";
+	char *table = table_ce(upi->config_kset).u.string;
+	char query[256];
 	unsigned int ui;
 
 	if (!pi->dbh) {
@@ -110,6 +111,8 @@ static int get_columns_dbi(struct ulogd_pluginstance *upi)
 		return 1;
 	}
 
+	snprintf(query, 256, "SELECT * FROM %s", table);
+
 	ulogd_log(ULOGD_DEBUG, "%s\n", query);
 	pi->result = dbi_conn_query(pi->dbh,query);
 	if (!pi->result) {
#1 lore raw

Hi Harald!

Quoted 6 lines · Harald Welte

Hi!

I've tried to use the DBI plugin of ulogd2 for NFCT based accounting, and despite using table="conntrack", it always insisted in using the table "ulog" for deriving the keys/columns to be stored.

Quoted 6 lines

I've hacked up a quick fix, and it seems to work as expected (though no proper null temrmination after strncpy).

As I've been absent from ulogd and netfilter hacking for some time, I tohught I'd post it here rather than pushing something to the git repo...

Please, feel free to push it!

Thanks!

maintainer Applied
#2 lore raw
In reply to Harald Welte
Quoted 6 lines · Harald Welte

Hi!

I've tried to use the DBI plugin of ulogd2 for NFCT based accounting, and despite using table="conntrack", it always insisted in using the table "ulog" for deriving the keys/columns to be stored.

Quoted 6 lines

I've hacked up a quick fix, and it seems to work as expected (though no proper null temrmination after strncpy).

As I've been absent from ulogd and netfilter hacking for some time, I tohught I'd post it here rather than pushing something to the git repo...

Applied, thanks Harald!