aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Graf <tgraf@suug.ch>2005-04-01 19:01:24 +0200
committerThomas Graf <tgraf@suug.ch>2005-04-01 19:01:24 +0200
commitcd4e48c6a593a106c89173d9c1e7901e2f820290 (patch)
tree58604d2b875cd0f8c7a110d43601e8bbb9390981
parent80458f046daa6dd6f9a0f8cd2b6a5d3ac766cd28 (diff)
downloadhistory-cd4e48c6a593a106c89173d9c1e7901e2f820290.tar.gz
[NET]: Improve gnet_stats_* dumping logic to be less error prone
The recent additions to make gnet_stats_* useable for action statistics dumping in two steps introcuded a few error prone assumptions which can easly be forgotten. This patch fixes this up by simplifying the process of adding new fields to struct gnet_dump or adding additional backward compatibility TLVs. Signed-off-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/core/gen_stats.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index 92eaceb064d81e..8f21490355fa5b 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -26,9 +26,7 @@
static inline int
gnet_stats_copy(struct gnet_dump *d, int type, void *buf, int size)
{
- if (type)
- RTA_PUT(d->skb, type, size, buf);
-
+ RTA_PUT(d->skb, type, size, buf);
return 0;
rtattr_failure:
@@ -58,6 +56,8 @@ int
gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
int xstats_type, spinlock_t *lock, struct gnet_dump *d)
{
+ memset(d, 0, sizeof(*d));
+
spin_lock_bh(lock);
d->lock = lock;
if (type)
@@ -65,12 +65,11 @@ gnet_stats_start_copy_compat(struct sk_buff *skb, int type, int tc_stats_type,
d->skb = skb;
d->compat_tc_stats = tc_stats_type;
d->compat_xstats = xstats_type;
- d->xstats = NULL;
- if (d->compat_tc_stats)
- memset(&d->tc_stats, 0, sizeof(d->tc_stats));
+ if (d->tail)
+ return gnet_stats_copy(d, type, NULL, 0);
- return gnet_stats_copy(d, type, NULL, 0);
+ return 0;
}
/**
@@ -111,8 +110,11 @@ gnet_stats_copy_basic(struct gnet_dump *d, struct gnet_stats_basic *b)
d->tc_stats.bytes = b->bytes;
d->tc_stats.packets = b->packets;
}
-
- return gnet_stats_copy(d, TCA_STATS_BASIC, b, sizeof(*b));
+
+ if (d->tail)
+ return gnet_stats_copy(d, TCA_STATS_BASIC, b, sizeof(*b));
+
+ return 0;
}
/**
@@ -134,7 +136,10 @@ gnet_stats_copy_rate_est(struct gnet_dump *d, struct gnet_stats_rate_est *r)
d->tc_stats.pps = r->pps;
}
- return gnet_stats_copy(d, TCA_STATS_RATE_EST, r, sizeof(*r));
+ if (d->tail)
+ return gnet_stats_copy(d, TCA_STATS_RATE_EST, r, sizeof(*r));
+
+ return 0;
}
/**
@@ -157,8 +162,11 @@ gnet_stats_copy_queue(struct gnet_dump *d, struct gnet_stats_queue *q)
d->tc_stats.backlog = q->backlog;
d->tc_stats.overlimits = q->overlimits;
}
-
- return gnet_stats_copy(d, TCA_STATS_QUEUE, q, sizeof(*q));
+
+ if (d->tail)
+ return gnet_stats_copy(d, TCA_STATS_QUEUE, q, sizeof(*q));
+
+ return 0;
}
/**
@@ -182,7 +190,10 @@ gnet_stats_copy_app(struct gnet_dump *d, void *st, int len)
d->xstats_len = len;
}
- return gnet_stats_copy(d, TCA_STATS_APP, st, len);
+ if (d->tail)
+ return gnet_stats_copy(d, TCA_STATS_APP, st, len);
+
+ return 0;
}
/**