[conntrack-tools] network: fix endianess issue in synchronization network header

Pablo Neira netfilter-cvslog-bounces at lists.netfilter.org
Fri Feb 20 19:52:36 CET 2009


Gitweb:		http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=e31823d42a9591021bf5bbe818b530133eb437da
commit e31823d42a9591021bf5bbe818b530133eb437da
Author:     Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Fri Feb 20 19:51:22 2009 +0100
Commit:     Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Fri Feb 20 19:51:22 2009 +0100

    network: fix endianess issue in synchronization network header
    
    This patch fixes an endianess issue in the synchronization network
    header. This breaks backward compatibility if different conntrackd
    versions are used.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

commit 9d67451ca43b0a469f16d0d139e014b9a5fee33d
Author:     Pablo Neira Ayuso <pablo at netfilter.org>
AuthorDate: Fri Feb 20 18:33:52 2009 +0100
Commit:     Pablo Neira Ayuso <pablo at netfilter.org>
CommitDate: Fri Feb 20 18:33:52 2009 +0100

    headers: don't use NFCT_DIR_MAX in statistics structure
    
    This patch removes the use of NFCT_DIR_MAX. This constant is part of
    the old libnetfilter_conntrack API which has been removed from the
    git tree. It was introduced in the early days of conntrackd, thus,
    the use of this constant. Unfortunately, I did not notice until now.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
       via  e31823d42a9591021bf5bbe818b530133eb437da (commit)
       via  9d67451ca43b0a469f16d0d139e014b9a5fee33d (commit)
      from  1606369707325e2f68ffe225917d7ea637ddb9de (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit e31823d42a9591021bf5bbe818b530133eb437da
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date:   Fri Feb 20 19:51:22 2009 +0100

    network: fix endianess issue in synchronization network header
    
    This patch fixes an endianess issue in the synchronization network
    header. This breaks backward compatibility if different conntrackd
    versions are used.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

commit 9d67451ca43b0a469f16d0d139e014b9a5fee33d
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date:   Fri Feb 20 18:33:52 2009 +0100

    headers: don't use NFCT_DIR_MAX in statistics structure
    
    This patch removes the use of NFCT_DIR_MAX. This constant is part of
    the old libnetfilter_conntrack API which has been removed from the
    git tree. It was introduced in the early days of conntrackd, thus,
    the use of this constant. Unfortunately, I did not notice until now.
    
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

-----------------------------------------------------------------------

 include/conntrackd.h |    6 ++++--
 include/network.h    |    7 +++++++
 src/traffic_stats.c  |   15 +++++++--------
 3 files changed, 18 insertions(+), 10 deletions(-)
This patch removes the use of NFCT_DIR_MAX. This constant is part of
the old libnetfilter_conntrack API which has been removed from the
git tree. It was introduced in the early days of conntrackd, thus,
the use of this constant. Unfortunately, I did not notice until now.

Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>

diff --git a/include/conntrackd.h b/include/conntrackd.h
index 9b3cdf2..9615c2e 100644
--- a/include/conntrackd.h
+++ b/include/conntrackd.h
@@ -128,8 +128,10 @@ struct ct_general_state {
 
 	/* statistics */
 	struct {
-		uint64_t 		bytes[NFCT_DIR_MAX];
-		uint64_t 		packets[NFCT_DIR_MAX];
+		uint64_t 		bytes_orig;
+		uint64_t 		bytes_repl;
+		uint64_t 		packets_orig;
+		uint64_t 		packets_repl;
 
 		time_t			daemon_start_time;
 
diff --git a/src/traffic_stats.c b/src/traffic_stats.c
index 52ca09a..6535527 100644
--- a/src/traffic_stats.c
+++ b/src/traffic_stats.c
@@ -21,13 +21,13 @@
 
 void update_traffic_stats(struct nf_conntrack *ct)
 {
-	STATE(stats).bytes[NFCT_DIR_ORIGINAL] +=
+	STATE(stats).bytes_orig +=
 		nfct_get_attr_u32(ct, ATTR_ORIG_COUNTER_BYTES);
-	STATE(stats).bytes[NFCT_DIR_REPLY] +=
+	STATE(stats).bytes_repl +=
 		nfct_get_attr_u32(ct, ATTR_REPL_COUNTER_BYTES);
-	STATE(stats).packets[NFCT_DIR_ORIGINAL] += 
+	STATE(stats).packets_orig += 
 		nfct_get_attr_u32(ct, ATTR_ORIG_COUNTER_PACKETS);
-	STATE(stats).packets[NFCT_DIR_REPLY] +=
+	STATE(stats).packets_repl +=
 		nfct_get_attr_u32(ct, ATTR_REPL_COUNTER_PACKETS);
 }
 
@@ -35,10 +35,9 @@ void dump_traffic_stats(int fd)
 {
 	char buf[512];
 	int size;
-	uint64_t bytes = STATE(stats).bytes[NFCT_DIR_ORIGINAL] +
-			  STATE(stats).bytes[NFCT_DIR_REPLY];
-	uint64_t packets = STATE(stats).packets[NFCT_DIR_ORIGINAL] +
-			    STATE(stats).packets[NFCT_DIR_REPLY];
+	uint64_t bytes = STATE(stats).bytes_orig + STATE(stats).bytes_repl;
+	uint64_t packets = STATE(stats).packets_orig +
+			   STATE(stats).packets_repl;
 
 	size = sprintf(buf, "traffic processed:\n");
 	size += sprintf(buf+size, "%20llu Bytes      ", (unsigned long long)bytes);



More information about the netfilter-cvslog mailing list