Don't print device statistics when exiting tinc.
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 8 Dec 2013 19:23:44 +0000 (20:23 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 8 Dec 2013 19:23:44 +0000 (20:23 +0100)
Much more detailed statistics are now kept per node, which can be queried at
any time, which makes the device statistics obsolete.

12 files changed:
src/bsd/device.c
src/cygwin/device.c
src/device.h
src/dummy_device.c
src/linux/device.c
src/mingw/device.c
src/multicast_device.c
src/raw_socket_device.c
src/solaris/device.c
src/tincd.c
src/uml_device.c
src/vde_device.c

index e083519..145b79e 100644 (file)
@@ -54,8 +54,6 @@ int device_fd = -1;
 char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
 #if defined(ENABLE_TUNEMU)
 static device_type_t device_type = DEVICE_TYPE_TUNEMU;
 #elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD) || defined(HAVE_DRAGONFLY)
 #if defined(ENABLE_TUNEMU)
 static device_type_t device_type = DEVICE_TYPE_TUNEMU;
 #elif defined(HAVE_OPENBSD) || defined(HAVE_FREEBSD) || defined(HAVE_DRAGONFLY)
@@ -290,8 +288,6 @@ static bool read_packet(vpn_packet_t *packet) {
                        return false;
        }
 
                        return false;
        }
 
-       device_total_in += packet->len;
-
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s",
                           packet->len, device_info);
 
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s",
                           packet->len, device_info);
 
@@ -362,21 +358,12 @@ static bool write_packet(vpn_packet_t *packet) {
                        return false;
        }
 
                        return false;
        }
 
-       device_total_out += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
index f4dcae4..a110f7f 100644 (file)
@@ -40,9 +40,6 @@ char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 
 char *iface = NULL;
 static char *device_info = NULL;
 
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
-
 static pid_t reader_pid;
 static int sp[2];
 
 static pid_t reader_pid;
 static int sp[2];
 
@@ -237,8 +234,6 @@ static bool read_packet(vpn_packet_t *packet) {
 
        packet->len = inlen;
 
 
        packet->len = inlen;
 
-       device_total_in += packet->len;
-
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
@@ -256,21 +251,12 @@ static bool write_packet(vpn_packet_t *packet) {
                return false;
        }
 
                return false;
        }
 
-       device_total_out += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
index c91f035..85112ff 100644 (file)
@@ -37,7 +37,6 @@ typedef struct devops_t {
        void (*close)(void);
        bool (*read)(struct vpn_packet_t *);
        bool (*write)(struct vpn_packet_t *);
        void (*close)(void);
        bool (*read)(struct vpn_packet_t *);
        bool (*write)(struct vpn_packet_t *);
-       void (*dump_stats)(void);
 } devops_t;
 
 extern const devops_t os_devops;
 } devops_t;
 
 extern const devops_t os_devops;
index d508180..c43d586 100644 (file)
@@ -25,9 +25,6 @@
 
 static char *device_info = "dummy device";
 
 
 static char *device_info = "dummy device";
 
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
-
 static bool setup_device(void) {
        device = "dummy";
        iface = "dummy";
 static bool setup_device(void) {
        device = "dummy";
        iface = "dummy";
@@ -43,20 +40,12 @@ static bool read_packet(vpn_packet_t *packet) {
 }
 
 static bool write_packet(vpn_packet_t *packet) {
 }
 
 static bool write_packet(vpn_packet_t *packet) {
-       device_total_out += packet->len;
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t dummy_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t dummy_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
index 127e3e8..6ed1622 100644 (file)
@@ -46,11 +46,6 @@ static char *type = NULL;
 static char ifrname[IFNAMSIZ];
 static char *device_info;
 
 static char ifrname[IFNAMSIZ];
 static char *device_info;
 
-uint64_t device_in_packets = 0;
-uint64_t device_in_bytes = 0;
-uint64_t device_out_packets = 0;
-uint64_t device_out_bytes = 0;
-
 static bool setup_device(void) {
        if(!get_config_string(lookup_config(config_tree, "Device"), &device))
                device = xstrdup(DEFAULT_DEVICE);
 static bool setup_device(void) {
        if(!get_config_string(lookup_config(config_tree, "Device"), &device))
                device = xstrdup(DEFAULT_DEVICE);
@@ -152,9 +147,6 @@ static bool read_packet(vpn_packet_t *packet) {
                        abort();
        }
 
                        abort();
        }
 
-       device_in_packets++;
-       device_in_bytes += packet->len;
-
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
@@ -185,22 +177,12 @@ static bool write_packet(vpn_packet_t *packet) {
                        abort();
        }
 
                        abort();
        }
 
-       device_out_packets++;
-       device_out_bytes += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_in_bytes);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_out_bytes);
-}
-
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
index abe544e..9744196 100644 (file)
@@ -40,9 +40,6 @@ char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 
 char *iface = NULL;
 static char *device_info = NULL;
 
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
-
 extern char *myport;
 
 static DWORD WINAPI tapreader(void *bla) {
 extern char *myport;
 
 static DWORD WINAPI tapreader(void *bla) {
@@ -235,21 +232,12 @@ static bool write_packet(vpn_packet_t *packet) {
                return false;
        }
 
                return false;
        }
 
-       device_total_out += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
index 600b77c..48e1200 100644 (file)
@@ -31,9 +31,6 @@
 
 static char *device_info;
 
 
 static char *device_info;
 
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
-
 static struct addrinfo *ai = NULL;
 static mac_t ignore_src = {{0}};
 
 static struct addrinfo *ai = NULL;
 static mac_t ignore_src = {{0}};
 
@@ -176,8 +173,6 @@ static bool read_packet(vpn_packet_t *packet) {
 
        packet->len = lenin;
 
 
        packet->len = lenin;
 
-       device_total_in += packet->len;
-
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
@@ -194,39 +189,14 @@ static bool write_packet(vpn_packet_t *packet) {
                return false;
        }
 
                return false;
        }
 
-       device_total_out += packet->len;
-
        memcpy(&ignore_src, packet->data + 6, sizeof ignore_src);
 
        return true;
 }
 
        memcpy(&ignore_src, packet->data + 6, sizeof ignore_src);
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t multicast_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t multicast_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
-
-#if 0
-
-static bool not_supported(void) {
-       logger(DEBUG_ALWAYS, LOG_ERR, "Raw socket device not supported on this platform");
-       return false;
-}
-
-const devops_t multicast_devops = {
-       .setup = not_supported,
-       .close = NULL,
-       .read = NULL,
-       .write = NULL,
-       .dump_stats = NULL,
-};
-#endif
index 00fdef0..57df5b7 100644 (file)
@@ -35,9 +35,6 @@
 #if defined(PF_PACKET) && defined(ETH_P_ALL) && defined(AF_PACKET) && defined(SIOCGIFINDEX)
 static char *device_info;
 
 #if defined(PF_PACKET) && defined(ETH_P_ALL) && defined(AF_PACKET) && defined(SIOCGIFINDEX)
 static char *device_info;
 
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
-
 static bool setup_device(void) {
        struct ifreq ifr;
        struct sockaddr_ll sa;
 static bool setup_device(void) {
        struct ifreq ifr;
        struct sockaddr_ll sa;
@@ -103,8 +100,6 @@ static bool read_packet(vpn_packet_t *packet) {
 
        packet->len = inlen;
 
 
        packet->len = inlen;
 
-       device_total_in += packet->len;
-
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                           device_info);
 
@@ -121,23 +116,14 @@ static bool write_packet(vpn_packet_t *packet) {
                return false;
        }
 
                return false;
        }
 
-       device_total_out += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t raw_socket_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t raw_socket_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 
 #else
 };
 
 #else
@@ -152,6 +138,5 @@ const devops_t raw_socket_devops = {
        .close = NULL,
        .read = NULL,
        .write = NULL,
        .close = NULL,
        .read = NULL,
        .write = NULL,
-       .dump_stats = NULL,
 };
 #endif
 };
 #endif
index 351999c..4940ddb 100644 (file)
@@ -54,11 +54,6 @@ char *device = NULL;
 char *iface = NULL;
 static char *device_info = NULL;
 
 char *iface = NULL;
 static char *device_info = NULL;
 
-uint64_t device_in_packets = 0;
-uint64_t device_in_bytes = 0;
-uint64_t device_out_packets = 0;
-uint64_t device_out_bytes = 0;
-
 static bool setup_device(void) {
        char *type;
 
 static bool setup_device(void) {
        char *type;
 
@@ -340,9 +335,6 @@ static bool read_packet(vpn_packet_t *packet) {
                        abort();
        }
 
                        abort();
        }
 
-       device_in_packets++;
-       device_in_bytes += packet->len;
-
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info);
 
        return true;
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info);
 
        return true;
@@ -370,22 +362,12 @@ static bool write_packet(vpn_packet_t *packet) {
                        abort();
        }
 
                        abort();
        }
 
-       device_out_packets++;
-       device_out_bytes += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_in_bytes);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_out_bytes);
-}
-
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t os_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
index 84036ad..48f344e 100644 (file)
@@ -440,9 +440,6 @@ int main2(int argc, char **argv) {
 
        /* Shutdown properly. */
 
 
        /* Shutdown properly. */
 
-       if(debug_level >= DEBUG_CONNECTIONS)
-               devops.dump_stats();
-
 end:
        close_network_connections();
 
 end:
        close_network_connections();
 
index d06832b..5193fe9 100644 (file)
@@ -38,9 +38,6 @@ static int write_fd = -1;
 static int state = 0;
 static char *device_info;
 
 static int state = 0;
 static char *device_info;
 
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
-
 enum request_type { REQ_NEW_CONTROL };
 
 static struct request {
 enum request_type { REQ_NEW_CONTROL };
 
 static struct request {
@@ -249,8 +246,6 @@ static bool read_packet(vpn_packet_t *packet) {
 
                        packet->len = inlen;
 
 
                        packet->len = inlen;
 
-                       device_total_in += packet->len;
-
                        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                                           device_info);
 
                        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len,
                                           device_info);
 
@@ -282,21 +277,12 @@ static bool write_packet(vpn_packet_t *packet) {
                return false;
        }
 
                return false;
        }
 
-       device_total_out += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t uml_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t uml_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };
index 446ca16..1021f5d 100644 (file)
@@ -36,9 +36,6 @@ static int port = 0;
 static char *group = NULL;
 static char *device_info;
 
 static char *group = NULL;
 static char *device_info;
 
-static uint64_t device_total_in = 0;
-static uint64_t device_total_out = 0;
-
 static bool setup_device(void) {
        libvdeplug_dynopen(plug);
 
 static bool setup_device(void) {
        libvdeplug_dynopen(plug);
 
@@ -105,7 +102,7 @@ static bool read_packet(vpn_packet_t *packet) {
        }
 
        packet->len = lenin;
        }
 
        packet->len = lenin;
-       device_total_in += packet->len;
+
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info);
 
        return true;
        logger(DEBUG_TRAFFIC, LOG_DEBUG, "Read packet of %d bytes from %s", packet->len, device_info);
 
        return true;
@@ -121,21 +118,12 @@ static bool write_packet(vpn_packet_t *packet) {
                return false;
        }
 
                return false;
        }
 
-       device_total_out += packet->len;
-
        return true;
 }
 
        return true;
 }
 
-static void dump_device_stats(void) {
-       logger(DEBUG_ALWAYS, LOG_DEBUG, "Statistics for %s %s:", device_info, device);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes in:  %10"PRIu64, device_total_in);
-       logger(DEBUG_ALWAYS, LOG_DEBUG, " total bytes out: %10"PRIu64, device_total_out);
-}
-
 const devops_t vde_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
 const devops_t vde_devops = {
        .setup = setup_device,
        .close = close_device,
        .read = read_packet,
        .write = write_packet,
-       .dump_stats = dump_device_stats,
 };
 };