diff options
author | JP Abgrall <jpa@google.com> | 2011-09-15 00:56:20 -0700 |
---|---|---|
committer | Dan Willemsen <dwillemsen@nvidia.com> | 2011-11-30 21:39:06 -0800 |
commit | edbd09a6f47f62a4a58730b56d6fc4c2d460b68f (patch) | |
tree | 49368029b0d543d168cf66c486b92d9fbc76865f /net/netfilter/xt_qtaguid_print.c | |
parent | 09a6b855bd70cca4bcbb1b4602b079b27ea369c8 (diff) |
netfilter: xt_qtaguid: work around devices that reset their stats
Most net devs will not reset their stats when just going down/up,
unless a NETDEV_UNREGISTER was notified.
But some devs will not send out a NETDEV_UNREGISTER but still
reset their stats just before a NETDEV_UP.
Now we just track the dev stats during NETDEV_DOWN... just in case.
Then on NETDEV_UP we check the stats: if the device didn't do a
NETDEV_UNREGISTER and a prior NETDEV_DOWN captured stats, then we treat
it as an UNREGISTER and save the totals from the stashed values.
Added extra netdev event debugging.
Change-Id: Iec79e74bfd40269aa3e5892f161be71e09de6946
Signed-off-by: JP Abgrall <jpa@google.com>
Diffstat (limited to 'net/netfilter/xt_qtaguid_print.c')
-rw-r--r-- | net/netfilter/xt_qtaguid_print.c | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/net/netfilter/xt_qtaguid_print.c b/net/netfilter/xt_qtaguid_print.c index 3d054474f9a2..7fef3a3f212a 100644 --- a/net/netfilter/xt_qtaguid_print.c +++ b/net/netfilter/xt_qtaguid_print.c @@ -146,19 +146,29 @@ char *pp_iface_stat(struct iface_stat *is) return kasprintf(GFP_ATOMIC, "iface_stat@%p{" "list=list_head{...}, " "ifname=%s, " - "rx_bytes=%llu, " - "rx_packets=%llu, " - "tx_bytes=%llu, " - "tx_packets=%llu, " + "total={rx={bytes=%llu, " + "packets=%llu}, " + "tx={bytes=%llu, " + "packets=%llu}}, " + "last_known_valid=%d, " + "last_known={rx={bytes=%llu, " + "packets=%llu}, " + "tx={bytes=%llu, " + "packets=%llu}}, " "active=%d, " "proc_ptr=%p, " "tag_stat_tree=rb_root{...}}", is, is->ifname, - is->rx_bytes, - is->rx_packets, - is->tx_bytes, - is->tx_packets, + is->totals[IFS_RX].bytes, + is->totals[IFS_RX].packets, + is->totals[IFS_TX].bytes, + is->totals[IFS_TX].packets, + is->last_known_valid, + is->last_known[IFS_RX].bytes, + is->last_known[IFS_RX].packets, + is->last_known[IFS_TX].bytes, + is->last_known[IFS_TX].packets, is->active, is->proc_ptr); } @@ -395,3 +405,36 @@ void prdebug_iface_stat_list(int indent_level, str = "}"; CT_DEBUG("%*d: %s\n", indent_level*2, indent_level, str); } + +/*------------------------------------------*/ +static const char * const netdev_event_strings[] = { + "netdev_unknown", + "NETDEV_UP", + "NETDEV_DOWN", + "NETDEV_REBOOT", + "NETDEV_CHANGE", + "NETDEV_REGISTER", + "NETDEV_UNREGISTER", + "NETDEV_CHANGEMTU", + "NETDEV_CHANGEADDR", + "NETDEV_GOING_DOWN", + "NETDEV_CHANGENAME", + "NETDEV_FEAT_CHANGE", + "NETDEV_BONDING_FAILOVER", + "NETDEV_PRE_UP", + "NETDEV_PRE_TYPE_CHANGE", + "NETDEV_POST_TYPE_CHANGE", + "NETDEV_POST_INIT", + "NETDEV_UNREGISTER_BATCH", + "NETDEV_RELEASE", + "NETDEV_NOTIFY_PEERS", + "NETDEV_JOIN", +}; + +const char *netdev_evt_str(int netdev_event) +{ + if (netdev_event < 0 + || netdev_event >= ARRAY_SIZE(netdev_event_strings)) + return "bad event num"; + return netdev_event_strings[netdev_event]; +} |