summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/net/tc_act/tc_gact.h7
-rw-r--r--net/sched/act_gact.c4
2 files changed, 7 insertions, 4 deletions
diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h
index 9fc9b578908a..592a6bc02b0b 100644
--- a/include/net/tc_act/tc_gact.h
+++ b/include/net/tc_act/tc_gact.h
@@ -6,9 +6,10 @@
struct tcf_gact {
struct tcf_common common;
#ifdef CONFIG_GACT_PROB
- u16 tcfg_ptype;
- u16 tcfg_pval;
- int tcfg_paction;
+ u16 tcfg_ptype;
+ u16 tcfg_pval;
+ int tcfg_paction;
+ atomic_t packets;
#endif
};
#define to_gact(a) \
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c
index 22a3a61aa090..2f9bec584b3f 100644
--- a/net/sched/act_gact.c
+++ b/net/sched/act_gact.c
@@ -36,8 +36,10 @@ static int gact_net_rand(struct tcf_gact *gact)
static int gact_determ(struct tcf_gact *gact)
{
+ u32 pack = atomic_inc_return(&gact->packets);
+
smp_rmb(); /* coupled with smp_wmb() in tcf_gact_init() */
- if (gact->tcf_bstats.packets % gact->tcfg_pval)
+ if (pack % gact->tcfg_pval)
return gact->tcf_action;
return gact->tcfg_paction;
}