Commit ec220224 authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[PKT_SCHED]: Add dump_stats class op

Adds a new class operation dump_stats which classes can use
to dump statistics. Unlike in qdiscs, there are no common
statistics therefore classes must dump all statistics on their
own. The qdisc stats_lock is being used for locking.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ae193ab7
...@@ -42,6 +42,7 @@ struct Qdisc_class_ops ...@@ -42,6 +42,7 @@ struct Qdisc_class_ops
/* rtnetlink specific */ /* rtnetlink specific */
int (*dump)(struct Qdisc *, unsigned long, struct sk_buff *skb, struct tcmsg*); int (*dump)(struct Qdisc *, unsigned long, struct sk_buff *skb, struct tcmsg*);
int (*dump_stats)(struct Qdisc *, unsigned long, struct gnet_dump *);
}; };
struct module; struct module;
......
...@@ -985,6 +985,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q, ...@@ -985,6 +985,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
struct tcmsg *tcm; struct tcmsg *tcm;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
unsigned char *b = skb->tail; unsigned char *b = skb->tail;
struct gnet_dump d;
struct Qdisc_class_ops *cl_ops = q->ops->cl_ops;
nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*tcm)); nlh = NLMSG_PUT(skb, pid, seq, event, sizeof(*tcm));
nlh->nlmsg_flags = flags; nlh->nlmsg_flags = flags;
...@@ -995,8 +997,19 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q, ...@@ -995,8 +997,19 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q,
tcm->tcm_handle = q->handle; tcm->tcm_handle = q->handle;
tcm->tcm_info = 0; tcm->tcm_info = 0;
RTA_PUT(skb, TCA_KIND, IFNAMSIZ, q->ops->id); RTA_PUT(skb, TCA_KIND, IFNAMSIZ, q->ops->id);
if (q->ops->cl_ops->dump && q->ops->cl_ops->dump(q, cl, skb, tcm) < 0) if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0)
goto rtattr_failure;
if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS,
TCA_XSTATS, q->stats_lock, &d) < 0)
goto rtattr_failure; goto rtattr_failure;
if (cl_ops->dump_stats && cl_ops->dump_stats(q, cl, &d) < 0)
goto rtattr_failure;
if (gnet_stats_finish_copy(&d) < 0)
goto rtattr_failure;
nlh->nlmsg_len = skb->tail - b; nlh->nlmsg_len = skb->tail - b;
return skb->len; return skb->len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment