net: cls_bpf: allow offloaded filters to update stats
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 21 Sep 2016 10:44:02 +0000 (11:44 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Sep 2016 23:50:03 +0000 (19:50 -0400)
Call into offloaded filters to update stats.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/pkt_cls.h
net/sched/cls_bpf.c

index 57af9f3032ff76fb6ab94221b8b2ff8104e7b8cb..5ccaa4be7d9646765d1ab59803756a3dcbce91fc 100644 (file)
@@ -490,6 +490,7 @@ enum tc_clsbpf_command {
        TC_CLSBPF_ADD,
        TC_CLSBPF_REPLACE,
        TC_CLSBPF_DESTROY,
+       TC_CLSBPF_STATS,
 };
 
 struct tc_cls_bpf_offload {
index 1becc2fe1bc5e33470b1dd1cb020e84c142fbbc8..bb1d5a487081f21f80a3042cd424cf7caedf6b37 100644 (file)
@@ -221,6 +221,15 @@ static void cls_bpf_stop_offload(struct tcf_proto *tp,
        prog->offloaded = false;
 }
 
+static void cls_bpf_offload_update_stats(struct tcf_proto *tp,
+                                        struct cls_bpf_prog *prog)
+{
+       if (!prog->offloaded)
+               return;
+
+       cls_bpf_offload_cmd(tp, prog, TC_CLSBPF_STATS);
+}
+
 static int cls_bpf_init(struct tcf_proto *tp)
 {
        struct cls_bpf_head *head;
@@ -577,6 +586,8 @@ static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
 
        tm->tcm_handle = prog->handle;
 
+       cls_bpf_offload_update_stats(tp, prog);
+
        nest = nla_nest_start(skb, TCA_OPTIONS);
        if (nest == NULL)
                goto nla_put_failure;