From a3bddc5448c8cd7830120c3313bdf8b38e444ad7 Mon Sep 17 00:00:00 2001 From: seb Date: Mon, 10 Dec 2012 22:02:12 +0100 Subject: [PATCH] Changed IPv6 counters (used by sar -n {IP6 | EIP6 }) to unsigned long long to keep in sync with current kernels. Keep in sync with recent kernels (3.7rc8 used here): Now use unsigned long long for SNMP IPv6 statistics. WARNING: This breaks compatibility with older sar data files format for IPv6 statistics. --- CHANGES | 4 ++++ activity.c | 4 ++-- rd_stats.c | 42 +++++++++++++++++++++--------------------- rd_stats.h | 42 +++++++++++++++++++++--------------------- 4 files changed, 48 insertions(+), 44 deletions(-) diff --git a/CHANGES b/CHANGES index 5880762..b05f701 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,10 @@ xxxx/xx/xx: Version 10.1.3 - Sebastien Godard (sysstat orange.fr) unsigned long long to keep in sync with current kernels. WARNING: This breaks compatibility with older sar data files format for IPv4 statistics. + * Changed IPv6 counters (used by sar -n { IP6 | EIP6}) to + unsigned long long to keep in sync with current kernels. + WARNING: This breaks compatibility with older sar data + files format for IPv6 statistics. * [Peter Schiffer]: Added option -y to iostat. This option prevents iostat from displaying its first report with statistics since system boot. diff --git a/activity.c b/activity.c index ed9c21c..103df7a 100644 --- a/activity.c +++ b/activity.c @@ -822,7 +822,7 @@ struct activity net_sock6_act = { struct activity net_ip6_act = { .id = A_NET_IP6, .options = AO_NULL, - .magic = ACTIVITY_MAGIC_BASE, + .magic = ACTIVITY_MAGIC_BASE + 1, .group = G_IPV6, #ifdef SOURCE_SADC .f_count = NULL, @@ -854,7 +854,7 @@ struct activity net_ip6_act = { struct activity net_eip6_act = { .id = A_NET_EIP6, .options = AO_NULL, - .magic = ACTIVITY_MAGIC_BASE, + .magic = ACTIVITY_MAGIC_BASE + 1, .group = G_IPV6, #ifdef SOURCE_SADC .f_count = NULL, diff --git a/rd_stats.c b/rd_stats.c index 008f158..dafd975 100644 --- a/rd_stats.c +++ b/rd_stats.c @@ -1328,34 +1328,34 @@ void read_net_ip6(struct stats_net_ip6 *st_net_ip6) while (fgets(line, 128, fp) != NULL) { if (!strncmp(line, "Ip6InReceives ", 14)) { - sscanf(line + 14, "%lu", &st_net_ip6->InReceives6); + sscanf(line + 14, "%llu", &st_net_ip6->InReceives6); } else if (!strncmp(line, "Ip6OutForwDatagrams ", 20)) { - sscanf(line + 20, "%lu", &st_net_ip6->OutForwDatagrams6); + sscanf(line + 20, "%llu", &st_net_ip6->OutForwDatagrams6); } else if (!strncmp(line, "Ip6InDelivers ", 14)) { - sscanf(line + 14, "%lu", &st_net_ip6->InDelivers6); + sscanf(line + 14, "%llu", &st_net_ip6->InDelivers6); } else if (!strncmp(line, "Ip6OutRequests ", 15)) { - sscanf(line + 15, "%lu", &st_net_ip6->OutRequests6); + sscanf(line + 15, "%llu", &st_net_ip6->OutRequests6); } else if (!strncmp(line, "Ip6ReasmReqds ", 14)) { - sscanf(line + 14, "%lu", &st_net_ip6->ReasmReqds6); + sscanf(line + 14, "%llu", &st_net_ip6->ReasmReqds6); } else if (!strncmp(line, "Ip6ReasmOKs ", 12)) { - sscanf(line + 12, "%lu", &st_net_ip6->ReasmOKs6); + sscanf(line + 12, "%llu", &st_net_ip6->ReasmOKs6); } else if (!strncmp(line, "Ip6InMcastPkts ", 15)) { - sscanf(line + 15, "%lu", &st_net_ip6->InMcastPkts6); + sscanf(line + 15, "%llu", &st_net_ip6->InMcastPkts6); } else if (!strncmp(line, "Ip6OutMcastPkts ", 16)) { - sscanf(line + 16, "%lu", &st_net_ip6->OutMcastPkts6); + sscanf(line + 16, "%llu", &st_net_ip6->OutMcastPkts6); } else if (!strncmp(line, "Ip6FragOKs ", 11)) { - sscanf(line + 11, "%lu", &st_net_ip6->FragOKs6); + sscanf(line + 11, "%llu", &st_net_ip6->FragOKs6); } else if (!strncmp(line, "Ip6FragCreates ", 15)) { - sscanf(line + 15, "%lu", &st_net_ip6->FragCreates6); + sscanf(line + 15, "%llu", &st_net_ip6->FragCreates6); } } @@ -1384,37 +1384,37 @@ void read_net_eip6(struct stats_net_eip6 *st_net_eip6) while (fgets(line, 128, fp) != NULL) { if (!strncmp(line, "Ip6InHdrErrors ", 15)) { - sscanf(line + 15, "%lu", &st_net_eip6->InHdrErrors6); + sscanf(line + 15, "%llu", &st_net_eip6->InHdrErrors6); } else if (!strncmp(line, "Ip6InAddrErrors ", 16)) { - sscanf(line + 16, "%lu", &st_net_eip6->InAddrErrors6); + sscanf(line + 16, "%llu", &st_net_eip6->InAddrErrors6); } else if (!strncmp(line, "Ip6InUnknownProtos ", 19)) { - sscanf(line + 19, "%lu", &st_net_eip6->InUnknownProtos6); + sscanf(line + 19, "%llu", &st_net_eip6->InUnknownProtos6); } else if (!strncmp(line, "Ip6InTooBigErrors ", 18)) { - sscanf(line + 18, "%lu", &st_net_eip6->InTooBigErrors6); + sscanf(line + 18, "%llu", &st_net_eip6->InTooBigErrors6); } else if (!strncmp(line, "Ip6InDiscards ", 14)) { - sscanf(line + 14, "%lu", &st_net_eip6->InDiscards6); + sscanf(line + 14, "%llu", &st_net_eip6->InDiscards6); } else if (!strncmp(line, "Ip6OutDiscards ", 15)) { - sscanf(line + 15, "%lu", &st_net_eip6->OutDiscards6); + sscanf(line + 15, "%llu", &st_net_eip6->OutDiscards6); } else if (!strncmp(line, "Ip6InNoRoutes ", 14)) { - sscanf(line + 14, "%lu", &st_net_eip6->InNoRoutes6); + sscanf(line + 14, "%llu", &st_net_eip6->InNoRoutes6); } else if (!strncmp(line, "Ip6OutNoRoutes ", 15)) { - sscanf(line + 15, "%lu", &st_net_eip6->OutNoRoutes6); + sscanf(line + 15, "%llu", &st_net_eip6->OutNoRoutes6); } else if (!strncmp(line, "Ip6ReasmFails ", 14)) { - sscanf(line + 14, "%lu", &st_net_eip6->ReasmFails6); + sscanf(line + 14, "%llu", &st_net_eip6->ReasmFails6); } else if (!strncmp(line, "Ip6FragFails ", 13)) { - sscanf(line + 13, "%lu", &st_net_eip6->FragFails6); + sscanf(line + 13, "%llu", &st_net_eip6->FragFails6); } else if (!strncmp(line, "Ip6InTruncatedPkts ", 19)) { - sscanf(line + 19, "%lu", &st_net_eip6->InTruncatedPkts6); + sscanf(line + 19, "%llu", &st_net_eip6->InTruncatedPkts6); } } diff --git a/rd_stats.h b/rd_stats.h index 8d4b8b5..0011be4 100644 --- a/rd_stats.h +++ b/rd_stats.h @@ -388,33 +388,33 @@ struct stats_net_udp { /* Structure for IPv6 statistics */ struct stats_net_ip6 { - unsigned long InReceives6 __attribute__ ((aligned (8))); - unsigned long OutForwDatagrams6 __attribute__ ((aligned (8))); - unsigned long InDelivers6 __attribute__ ((aligned (8))); - unsigned long OutRequests6 __attribute__ ((aligned (8))); - unsigned long ReasmReqds6 __attribute__ ((aligned (8))); - unsigned long ReasmOKs6 __attribute__ ((aligned (8))); - unsigned long InMcastPkts6 __attribute__ ((aligned (8))); - unsigned long OutMcastPkts6 __attribute__ ((aligned (8))); - unsigned long FragOKs6 __attribute__ ((aligned (8))); - unsigned long FragCreates6 __attribute__ ((aligned (8))); + unsigned long long InReceives6 __attribute__ ((aligned (16))); + unsigned long long OutForwDatagrams6 __attribute__ ((aligned (16))); + unsigned long long InDelivers6 __attribute__ ((aligned (16))); + unsigned long long OutRequests6 __attribute__ ((aligned (16))); + unsigned long long ReasmReqds6 __attribute__ ((aligned (16))); + unsigned long long ReasmOKs6 __attribute__ ((aligned (16))); + unsigned long long InMcastPkts6 __attribute__ ((aligned (16))); + unsigned long long OutMcastPkts6 __attribute__ ((aligned (16))); + unsigned long long FragOKs6 __attribute__ ((aligned (16))); + unsigned long long FragCreates6 __attribute__ ((aligned (16))); }; #define STATS_NET_IP6_SIZE (sizeof(struct stats_net_ip6)) /* Structure for IPv6 errors statistics */ struct stats_net_eip6 { - unsigned long InHdrErrors6 __attribute__ ((aligned (8))); - unsigned long InAddrErrors6 __attribute__ ((aligned (8))); - unsigned long InUnknownProtos6 __attribute__ ((aligned (8))); - unsigned long InTooBigErrors6 __attribute__ ((aligned (8))); - unsigned long InDiscards6 __attribute__ ((aligned (8))); - unsigned long OutDiscards6 __attribute__ ((aligned (8))); - unsigned long InNoRoutes6 __attribute__ ((aligned (8))); - unsigned long OutNoRoutes6 __attribute__ ((aligned (8))); - unsigned long ReasmFails6 __attribute__ ((aligned (8))); - unsigned long FragFails6 __attribute__ ((aligned (8))); - unsigned long InTruncatedPkts6 __attribute__ ((aligned (8))); + unsigned long long InHdrErrors6 __attribute__ ((aligned (16))); + unsigned long long InAddrErrors6 __attribute__ ((aligned (16))); + unsigned long long InUnknownProtos6 __attribute__ ((aligned (16))); + unsigned long long InTooBigErrors6 __attribute__ ((aligned (16))); + unsigned long long InDiscards6 __attribute__ ((aligned (16))); + unsigned long long OutDiscards6 __attribute__ ((aligned (16))); + unsigned long long InNoRoutes6 __attribute__ ((aligned (16))); + unsigned long long OutNoRoutes6 __attribute__ ((aligned (16))); + unsigned long long ReasmFails6 __attribute__ ((aligned (16))); + unsigned long long FragFails6 __attribute__ ((aligned (16))); + unsigned long long InTruncatedPkts6 __attribute__ ((aligned (16))); }; #define STATS_NET_EIP6_SIZE (sizeof(struct stats_net_eip6)) -- 2.40.0