net_sched: act_gact: read tcfg_ptype once
authorEric Dumazet <edumazet@google.com>
Mon, 6 Jul 2015 12:18:07 +0000 (05:18 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Jul 2015 20:50:42 +0000 (13:50 -0700)
Third step for gact RCU operation :

Following patch will get rid of spinlock protection,
so we need to read tcfg_ptype once.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_gact.c

index 2f9bec584b3fcaca1a549cd8ec2d8ec540e1ef41..e4eb88d3d8dc71c2a8707169e57eca37c22d98ff 100644 (file)
@@ -127,16 +127,16 @@ static int tcf_gact(struct sk_buff *skb, const struct tc_action *a,
                    struct tcf_result *res)
 {
        struct tcf_gact *gact = a->priv;
-       int action = TC_ACT_SHOT;
+       int action = gact->tcf_action;
 
        spin_lock(&gact->tcf_lock);
 #ifdef CONFIG_GACT_PROB
-       if (gact->tcfg_ptype)
-               action = gact_rand[gact->tcfg_ptype](gact);
-       else
-               action = gact->tcf_action;
-#else
-       action = gact->tcf_action;
+       {
+       u32 ptype = READ_ONCE(gact->tcfg_ptype);
+
+       if (ptype)
+               action = gact_rand[ptype](gact);
+       }
 #endif
        gact->tcf_bstats.bytes += qdisc_pkt_len(skb);
        gact->tcf_bstats.packets++;