From 4b0126b8e6b8b3c5377e1f001be0987d7046da9a Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Wed, 16 Mar 2011 12:55:19 +0100 Subject: prefix ipv6 link statistics identifiers with IP6 --- include/netlink/route/link.h | 60 ++++++++++++++++++------------------ lib/route/link.c | 60 ++++++++++++++++++------------------ lib/route/link/inet6.c | 72 +++++++++++++++++++++++--------------------- 3 files changed, 97 insertions(+), 95 deletions(-) diff --git a/include/netlink/route/link.h b/include/netlink/route/link.h index 6b0b45c..dcd32f3 100644 --- a/include/netlink/route/link.h +++ b/include/netlink/route/link.h @@ -46,36 +46,36 @@ enum rtnl_link_st { RTNL_LINK_TX_WIN_ERR, RTNL_LINK_COLLISIONS, RTNL_LINK_MULTICAST, - RTNL_LINK_INPKTS, /* InReceives */ - RTNL_LINK_INHDRERRORS, /* InHdrErrors */ - RTNL_LINK_INTOOBIGERRORS, /* InTooBigErrors */ - RTNL_LINK_INNOROUTES, /* InNoRoutes */ - RTNL_LINK_INADDRERRORS, /* InAddrErrors */ - RTNL_LINK_INUNKNOWNPROTOS, /* InUnknownProtos */ - RTNL_LINK_INTRUNCATEDPKTS, /* InTruncatedPkts */ - RTNL_LINK_INDISCARDS, /* InDiscards */ - RTNL_LINK_INDELIVERS, /* InDelivers */ - RTNL_LINK_OUTFORWDATAGRAMS, /* OutForwDatagrams */ - RTNL_LINK_OUTPKTS, /* OutRequests */ - RTNL_LINK_OUTDISCARDS, /* OutDiscards */ - RTNL_LINK_OUTNOROUTES, /* OutNoRoutes */ - RTNL_LINK_REASMTIMEOUT, /* ReasmTimeout */ - RTNL_LINK_REASMREQDS, /* ReasmReqds */ - RTNL_LINK_REASMOKS, /* ReasmOKs */ - RTNL_LINK_REASMFAILS, /* ReasmFails */ - RTNL_LINK_FRAGOKS, /* FragOKs */ - RTNL_LINK_FRAGFAILS, /* FragFails */ - RTNL_LINK_FRAGCREATES, /* FragCreates */ - RTNL_LINK_INMCASTPKTS, /* InMcastPkts */ - RTNL_LINK_OUTMCASTPKTS, /* OutMcastPkts */ - RTNL_LINK_INBCASTPKTS, /* InBcastPkts */ - RTNL_LINK_OUTBCASTPKTS, /* OutBcastPkts */ - RTNL_LINK_INOCTETS, /* InOctets */ - RTNL_LINK_OUTOCTETS, /* OutOctets */ - RTNL_LINK_INMCASTOCTETS, /* InMcastOctets */ - RTNL_LINK_OUTMCASTOCTETS, /* OutMcastOctets */ - RTNL_LINK_INBCASTOCTETS, /* InBcastOctets */ - RTNL_LINK_OUTBCASTOCTETS, /* OutBcastOctets */ + RTNL_LINK_IP6_INPKTS, /* InReceives */ + RTNL_LINK_IP6_INHDRERRORS, /* InHdrErrors */ + RTNL_LINK_IP6_INTOOBIGERRORS, /* InTooBigErrors */ + RTNL_LINK_IP6_INNOROUTES, /* InNoRoutes */ + RTNL_LINK_IP6_INADDRERRORS, /* InAddrErrors */ + RTNL_LINK_IP6_INUNKNOWNPROTOS, /* InUnknownProtos */ + RTNL_LINK_IP6_INTRUNCATEDPKTS, /* InTruncatedPkts */ + RTNL_LINK_IP6_INDISCARDS, /* InDiscards */ + RTNL_LINK_IP6_INDELIVERS, /* InDelivers */ + RTNL_LINK_IP6_OUTFORWDATAGRAMS, /* OutForwDatagrams */ + RTNL_LINK_IP6_OUTPKTS, /* OutRequests */ + RTNL_LINK_IP6_OUTDISCARDS, /* OutDiscards */ + RTNL_LINK_IP6_OUTNOROUTES, /* OutNoRoutes */ + RTNL_LINK_IP6_REASMTIMEOUT, /* ReasmTimeout */ + RTNL_LINK_IP6_REASMREQDS, /* ReasmReqds */ + RTNL_LINK_IP6_REASMOKS, /* ReasmOKs */ + RTNL_LINK_IP6_REASMFAILS, /* ReasmFails */ + RTNL_LINK_IP6_FRAGOKS, /* FragOKs */ + RTNL_LINK_IP6_FRAGFAILS, /* FragFails */ + RTNL_LINK_IP6_FRAGCREATES, /* FragCreates */ + RTNL_LINK_IP6_INMCASTPKTS, /* InMcastPkts */ + RTNL_LINK_IP6_OUTMCASTPKTS, /* OutMcastPkts */ + RTNL_LINK_IP6_INBCASTPKTS, /* InBcastPkts */ + RTNL_LINK_IP6_OUTBCASTPKTS, /* OutBcastPkts */ + RTNL_LINK_IP6_INOCTETS, /* InOctets */ + RTNL_LINK_IP6_OUTOCTETS, /* OutOctets */ + RTNL_LINK_IP6_INMCASTOCTETS, /* InMcastOctets */ + RTNL_LINK_IP6_OUTMCASTOCTETS, /* OutMcastOctets */ + RTNL_LINK_IP6_INBCASTOCTETS, /* InBcastOctets */ + RTNL_LINK_IP6_OUTBCASTOCTETS, /* OutBcastOctets */ RTNL_LINK_ICMP6_INMSGS, /* InMsgs */ RTNL_LINK_ICMP6_INERRORS, /* InErrors */ RTNL_LINK_ICMP6_OUTMSGS, /* OutMsgs */ diff --git a/lib/route/link.c b/lib/route/link.c index c583917..00c9781 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -1287,36 +1287,36 @@ static const struct trans_tbl link_stats[] = { __ADD(RTNL_LINK_TX_WIN_ERR, tx_win_err) __ADD(RTNL_LINK_COLLISIONS, collisions) __ADD(RTNL_LINK_MULTICAST, multicast) - __ADD(RTNL_LINK_INPKTS, InReceives) - __ADD(RTNL_LINK_INHDRERRORS, InHdrErrors) - __ADD(RTNL_LINK_INTOOBIGERRORS, InTooBigErrors) - __ADD(RTNL_LINK_INNOROUTES, InNoRoutes) - __ADD(RTNL_LINK_INADDRERRORS, InAddrErrors) - __ADD(RTNL_LINK_INUNKNOWNPROTOS, InUnknownProtos) - __ADD(RTNL_LINK_INTRUNCATEDPKTS, InTruncatedPkts) - __ADD(RTNL_LINK_INDISCARDS, InDiscards) - __ADD(RTNL_LINK_INDELIVERS, InDelivers) - __ADD(RTNL_LINK_OUTFORWDATAGRAMS, OutForwDatagrams) - __ADD(RTNL_LINK_OUTPKTS, OutRequests) - __ADD(RTNL_LINK_OUTDISCARDS, OutDiscards) - __ADD(RTNL_LINK_OUTNOROUTES, OutNoRoutes) - __ADD(RTNL_LINK_REASMTIMEOUT, ReasmTimeout) - __ADD(RTNL_LINK_REASMREQDS, ReasmReqds) - __ADD(RTNL_LINK_REASMOKS, ReasmOKs) - __ADD(RTNL_LINK_REASMFAILS, ReasmFails) - __ADD(RTNL_LINK_FRAGOKS, FragOKs) - __ADD(RTNL_LINK_FRAGFAILS, FragFails) - __ADD(RTNL_LINK_FRAGCREATES, FragCreates) - __ADD(RTNL_LINK_INMCASTPKTS, InMcastPkts) - __ADD(RTNL_LINK_OUTMCASTPKTS, OutMcastPkts) - __ADD(RTNL_LINK_INBCASTPKTS, InBcastPkts) - __ADD(RTNL_LINK_OUTBCASTPKTS, OutBcastPkts) - __ADD(RTNL_LINK_INOCTETS, InOctets) - __ADD(RTNL_LINK_OUTOCTETS, OutOctets) - __ADD(RTNL_LINK_INMCASTOCTETS, InMcastOctets) - __ADD(RTNL_LINK_OUTMCASTOCTETS, OutMcastOctets) - __ADD(RTNL_LINK_INBCASTOCTETS, InBcastOctets) - __ADD(RTNL_LINK_OUTBCASTOCTETS, OutBcastOctets) + __ADD(RTNL_LINK_IP6_INPKTS, Ip6InReceives) + __ADD(RTNL_LINK_IP6_INHDRERRORS, Ip6InHdrErrors) + __ADD(RTNL_LINK_IP6_INTOOBIGERRORS, Ip6InTooBigErrors) + __ADD(RTNL_LINK_IP6_INNOROUTES, Ip6InNoRoutes) + __ADD(RTNL_LINK_IP6_INADDRERRORS, Ip6InAddrErrors) + __ADD(RTNL_LINK_IP6_INUNKNOWNPROTOS, Ip6InUnknownProtos) + __ADD(RTNL_LINK_IP6_INTRUNCATEDPKTS, Ip6InTruncatedPkts) + __ADD(RTNL_LINK_IP6_INDISCARDS, Ip6InDiscards) + __ADD(RTNL_LINK_IP6_INDELIVERS, Ip6InDelivers) + __ADD(RTNL_LINK_IP6_OUTFORWDATAGRAMS, Ip6OutForwDatagrams) + __ADD(RTNL_LINK_IP6_OUTPKTS, Ip6OutRequests) + __ADD(RTNL_LINK_IP6_OUTDISCARDS, Ip6OutDiscards) + __ADD(RTNL_LINK_IP6_OUTNOROUTES, Ip6OutNoRoutes) + __ADD(RTNL_LINK_IP6_REASMTIMEOUT, Ip6ReasmTimeout) + __ADD(RTNL_LINK_IP6_REASMREQDS, Ip6ReasmReqds) + __ADD(RTNL_LINK_IP6_REASMOKS, Ip6ReasmOKs) + __ADD(RTNL_LINK_IP6_REASMFAILS, Ip6ReasmFails) + __ADD(RTNL_LINK_IP6_FRAGOKS, Ip6FragOKs) + __ADD(RTNL_LINK_IP6_FRAGFAILS, Ip6FragFails) + __ADD(RTNL_LINK_IP6_FRAGCREATES, Ip6FragCreates) + __ADD(RTNL_LINK_IP6_INMCASTPKTS, Ip6InMcastPkts) + __ADD(RTNL_LINK_IP6_OUTMCASTPKTS, Ip6OutMcastPkts) + __ADD(RTNL_LINK_IP6_INBCASTPKTS, Ip6InBcastPkts) + __ADD(RTNL_LINK_IP6_OUTBCASTPKTS, Ip6OutBcastPkts) + __ADD(RTNL_LINK_IP6_INOCTETS, Ip6InOctets) + __ADD(RTNL_LINK_IP6_OUTOCTETS, Ip6OutOctets) + __ADD(RTNL_LINK_IP6_INMCASTOCTETS, Ip6InMcastOctets) + __ADD(RTNL_LINK_IP6_OUTMCASTOCTETS, Ip6OutMcastOctets) + __ADD(RTNL_LINK_IP6_INBCASTOCTETS, Ip6InBcastOctets) + __ADD(RTNL_LINK_IP6_OUTBCASTOCTETS, Ip6OutBcastOctets) __ADD(RTNL_LINK_ICMP6_INMSGS, ICMP6_InMsgs) __ADD(RTNL_LINK_ICMP6_INERRORS, ICMP6_InErrors) __ADD(RTNL_LINK_ICMP6_OUTMSGS, ICMP6_OutMsgs) diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c index cca308f..cfb0e44 100644 --- a/lib/route/link/inet6.c +++ b/lib/route/link/inet6.c @@ -76,16 +76,18 @@ static int inet6_parse_protinfo(struct rtnl_link *link, struct nlattr *attr, uint64_t *cnt = nla_data(tb[IFLA_INET6_STATS]); int i; - for (i = 1; i < __IPSTATS_MIB_MAX; i++) - rtnl_link_set_stat(link, RTNL_LINK_INPKTS, cnt[i-1]); + for (i = 1; i <= __IPSTATS_MIB_MAX; i++) + rtnl_link_set_stat(link, RTNL_LINK_IP6_INPKTS + i - 1, + cnt[i]); } if (tb[IFLA_INET6_ICMP6STATS]) { - uint64_t *cnt = nla_data(tb[IFLA_INET6_STATS]); + uint64_t *cnt = nla_data(tb[IFLA_INET6_ICMP6STATS]); int i; - for (i = 1; i < __ICMP6_MIB_MAX; i++) - rtnl_link_set_stat(link, RTNL_LINK_ICMP6_INMSGS, cnt[i-1]); + for (i = 1; i <= __ICMP6_MIB_MAX; i++) + rtnl_link_set_stat(link, RTNL_LINK_ICMP6_INMSGS + i - 1, + cnt[i]); } return 0; @@ -230,9 +232,9 @@ static void inet6_dump_stats(struct rtnl_link *link, nl_dump(p, " IPv6: InPkts InOctets " " InDiscards InDelivers\n"); - nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_INPKTS]); + nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_IP6_INPKTS]); - octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_INOCTETS], + octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_IP6_INOCTETS], &octetsUnit); if (octets) nl_dump(p, "%14.2f %3s ", octets, octetsUnit); @@ -240,15 +242,15 @@ static void inet6_dump_stats(struct rtnl_link *link, nl_dump(p, "%16llu B ", 0); nl_dump(p, "%18llu %18llu\n", - link->l_stats[RTNL_LINK_INDISCARDS], - link->l_stats[RTNL_LINK_INDELIVERS]); + link->l_stats[RTNL_LINK_IP6_INDISCARDS], + link->l_stats[RTNL_LINK_IP6_INDELIVERS]); nl_dump(p, " OutPkts OutOctets " " OutDiscards OutForwards\n"); - nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_OUTPKTS]); + nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_IP6_OUTPKTS]); - octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_OUTOCTETS], + octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_IP6_OUTOCTETS], &octetsUnit); if (octets) nl_dump(p, "%14.2f %3s ", octets, octetsUnit); @@ -256,23 +258,23 @@ static void inet6_dump_stats(struct rtnl_link *link, nl_dump(p, "%16llu B ", 0); nl_dump(p, "%18llu %18llu\n", - link->l_stats[RTNL_LINK_OUTDISCARDS], - link->l_stats[RTNL_LINK_OUTFORWDATAGRAMS]); + link->l_stats[RTNL_LINK_IP6_OUTDISCARDS], + link->l_stats[RTNL_LINK_IP6_OUTFORWDATAGRAMS]); nl_dump(p, " InMcastPkts InMcastOctets " " InBcastPkts InBcastOctests\n"); - nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_INMCASTPKTS]); + nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_IP6_INMCASTPKTS]); - octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_INMCASTOCTETS], + octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_IP6_INMCASTOCTETS], &octetsUnit); if (octets) nl_dump(p, "%14.2f %3s ", octets, octetsUnit); else nl_dump(p, "%16llu B ", 0); - nl_dump(p, "%18llu ", link->l_stats[RTNL_LINK_INBCASTPKTS]); - octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_INBCASTOCTETS], + nl_dump(p, "%18llu ", link->l_stats[RTNL_LINK_IP6_INBCASTPKTS]); + octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_IP6_INBCASTOCTETS], &octetsUnit); if (octets) nl_dump(p, "%14.2f %3s\n", octets, octetsUnit); @@ -282,17 +284,17 @@ static void inet6_dump_stats(struct rtnl_link *link, nl_dump(p, " OutMcastPkts OutMcastOctets " " OutBcastPkts OutBcastOctests\n"); - nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_OUTMCASTPKTS]); + nl_dump(p, " %18llu ", link->l_stats[RTNL_LINK_IP6_OUTMCASTPKTS]); - octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_OUTMCASTOCTETS], + octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_IP6_OUTMCASTOCTETS], &octetsUnit); if (octets) nl_dump(p, "%14.2f %3s ", octets, octetsUnit); else nl_dump(p, "%16llu B ", 0); - nl_dump(p, "%18llu ", link->l_stats[RTNL_LINK_OUTBCASTPKTS]); - octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_OUTBCASTOCTETS], + nl_dump(p, "%18llu ", link->l_stats[RTNL_LINK_IP6_OUTBCASTPKTS]); + octets = nl_cancel_down_bytes(link->l_stats[RTNL_LINK_IP6_OUTBCASTOCTETS], &octetsUnit); if (octets) nl_dump(p, "%14.2f %3s\n", octets, octetsUnit); @@ -302,32 +304,32 @@ static void inet6_dump_stats(struct rtnl_link *link, nl_dump(p, " ReasmOKs ReasmFails " " ReasmReqds ReasmTimeout\n"); nl_dump(p, " %18llu %18llu %18llu %18llu\n", - link->l_stats[RTNL_LINK_REASMOKS], - link->l_stats[RTNL_LINK_REASMFAILS], - link->l_stats[RTNL_LINK_REASMREQDS], - link->l_stats[RTNL_LINK_REASMTIMEOUT]); + link->l_stats[RTNL_LINK_IP6_REASMOKS], + link->l_stats[RTNL_LINK_IP6_REASMFAILS], + link->l_stats[RTNL_LINK_IP6_REASMREQDS], + link->l_stats[RTNL_LINK_IP6_REASMTIMEOUT]); nl_dump(p, " FragOKs FragFails " " FragCreates\n"); nl_dump(p, " %18llu %18llu %18llu\n", - link->l_stats[RTNL_LINK_FRAGOKS], - link->l_stats[RTNL_LINK_FRAGFAILS], - link->l_stats[RTNL_LINK_FRAGCREATES]); + link->l_stats[RTNL_LINK_IP6_FRAGOKS], + link->l_stats[RTNL_LINK_IP6_FRAGFAILS], + link->l_stats[RTNL_LINK_IP6_FRAGCREATES]); nl_dump(p, " InHdrErrors InTooBigErrors " " InNoRoutes InAddrErrors\n"); nl_dump(p, " %18llu %18llu %18llu %18llu\n", - link->l_stats[RTNL_LINK_INHDRERRORS], - link->l_stats[RTNL_LINK_INTOOBIGERRORS], - link->l_stats[RTNL_LINK_INNOROUTES], - link->l_stats[RTNL_LINK_INADDRERRORS]); + link->l_stats[RTNL_LINK_IP6_INHDRERRORS], + link->l_stats[RTNL_LINK_IP6_INTOOBIGERRORS], + link->l_stats[RTNL_LINK_IP6_INNOROUTES], + link->l_stats[RTNL_LINK_IP6_INADDRERRORS]); nl_dump(p, " InUnknownProtos InTruncatedPkts " " OutNoRoutes\n"); nl_dump(p, " %18llu %18llu %18llu\n", - link->l_stats[RTNL_LINK_INUNKNOWNPROTOS], - link->l_stats[RTNL_LINK_INTRUNCATEDPKTS], - link->l_stats[RTNL_LINK_OUTNOROUTES]); + link->l_stats[RTNL_LINK_IP6_INUNKNOWNPROTOS], + link->l_stats[RTNL_LINK_IP6_INTRUNCATEDPKTS], + link->l_stats[RTNL_LINK_IP6_OUTNOROUTES]); nl_dump(p, " ICMPv6: InMsgs InErrors " " OutMsgs OutErrors\n"); -- cgit v0.12