Skip to contentSkip to conversation

src: cache in tree and use x_tables.h

PATCH New Pablo Neira Ayuso 1 participant 2 messages Apr 2, 2015 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/2 src: cache in tree and use x_tables.h

---
 include/libarptc/libarptc.h              |    1 +
 include/linux/netfilter/x_tables.h       |  185 +++++++++++++++++++++++++
 include/linux/netfilter_arp/arp_tables.h |  222 ++++++------------------------
 libarptc/libarptc_incl.c                 |   17 +--
 4 files changed, 233 insertions(+), 192 deletions(-)
 create mode 100644 include/linux/netfilter/x_tables.h
include/libarptc/libarptc.h +1 -0
index e4f1175..ff4606f 100644
@@ -3,6 +3,7 @@
 /* Library which manipulates filtering rules. */
 
 #include <libarptc/arpt_kernel_headers.h>
+#include <linux/netfilter/x_tables.h>
 #include <linux/netfilter_arp/arp_tables.h>
 
 #ifndef ARPT_MIN_ALIGN
include/linux/netfilter/x_tables.h new file +185 -0

185 lines not on this page · raw message

include/linux/netfilter_arp/arp_tables.h +42 -180

326 lines not on this page · raw message

libarptc/libarptc_incl.c +5 -12
index 1d2e8b7..a034930 100644
@@ -40,13 +40,6 @@ struct counter_map
 	unsigned int mappos;
 };
 
-/* Convenience structures */
-struct arpt_error_target
-{
-	STRUCT_ENTRY_TARGET t;
-	char error[TABLE_MAXNAMELEN];
-};
-
 struct chain_cache
 {
 	char name[TABLE_MAXNAMELEN];
@@ -1342,9 +1335,9 @@ TC_CREATE_CHAIN(const ARPT_CHAINLABEL chain, TC_HANDLE_T *handle)
 	newc.head.next_offset
 		= sizeof(STRUCT_ENTRY)
 		+ ALIGN(sizeof(struct arpt_error_target));
-	strcpy(newc.name.t.u.user.name, ERROR_TARGET);
-	newc.name.t.u.target_size = ALIGN(sizeof(struct arpt_error_target));
-	strcpy(newc.name.error, chain);
+	strcpy(newc.name.target.u.user.name, ERROR_TARGET);
+	newc.name.target.u.target_size = ALIGN(sizeof(struct arpt_error_target));
+	strcpy(newc.name.errorname, chain);
 
 	newc.ret.target_offset = sizeof(STRUCT_ENTRY);
 	newc.ret.next_offset
@@ -1482,8 +1475,8 @@ int TC_RENAME_CHAIN(const ARPT_CHAINLABEL oldname,
 	t = (struct arpt_error_target *)
 		GET_TARGET(get_entry(*handle, labeloff));
 
-	memset(t->error, 0, sizeof(t->error));
-	strcpy(t->error, newname);
+	memset(t->errorname, 0, sizeof(t->errorname));
+	strcpy(t->errorname, newname);
 	set_changed(*handle);
 
 	return 1;
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH 2/2 src: fix compilation warning

libarptc/libarptc.c: In function ‘dump_entry’:
libarptc/libarptc.c:137:9: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘__u64’ [-Wformat] libarptc/libarptc.c:137:9: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘__u64’ [-Wformat]

---
 arptables.c         |    7 ++++---
 libarptc/libarptc.c |    2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)
arptables.c +4 -3
index 845e226..f820ffa 100644
@@ -2164,16 +2164,17 @@ int do_command(int argc, char *argv[], char **table, arptc_handle_t *handle)
 					"-%c requires packet and byte counter",
 					opt2char(OPT_COUNTERS));
 
-			if (sscanf(pcnt, "%"PRIu64, &fw.counters.pcnt) != 1)
+			if (sscanf(pcnt, "%"PRIu64,
+				   (uint64_t *)&fw.counters.pcnt) != 1)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c packet counter not numeric",
 					opt2char(OPT_COUNTERS));
 
-			if (sscanf(bcnt, "%"PRIu64, &fw.counters.bcnt) != 1)
+			if (sscanf(bcnt, "%"PRIu64,
+				   (uint64_t *)&fw.counters.bcnt) != 1)
 				exit_error(PARAMETER_PROBLEM,
 					"-%c byte counter not numeric",
 					opt2char(OPT_COUNTERS));
-			
 			break;
 
 
libarptc/libarptc.c +1 -1
index 2dcaaef..0025a75 100644
@@ -134,7 +134,7 @@ dump_entry(STRUCT_ENTRY *e, const TC_HANDLE_T handle)
 	printf("Flags: %02X\n", e->arp.flags);
 	printf("Invflags: %02X\n", e->arp.invflags);
 	printf("Counters: %"PRIu64" packets, %"PRIu64" bytes\n",
-	       e->counters.pcnt, e->counters.bcnt);
+	       (uint64_t)e->counters.pcnt, (uint64_t)e->counters.bcnt);
 /*
 	printf("Cache: %08X ", e->nfcache);
 	if (e->nfcache & NFC_ALTERED) printf("ALTERED ");
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html