Commit d72133e6 authored by Taehee Yoo's avatar Taehee Yoo Committed by Pablo Neira Ayuso

netfilter: ebtables: use ADD_COUNTER macro

xtables uses ADD_COUNTER macro to increase
packet and byte count. ebtables also can use this.
Signed-off-by: default avatarTaehee Yoo <ap420073@gmail.com>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 5b4c6e38
...@@ -223,9 +223,7 @@ unsigned int ebt_do_table(struct sk_buff *skb, ...@@ -223,9 +223,7 @@ unsigned int ebt_do_table(struct sk_buff *skb,
return NF_DROP; return NF_DROP;
} }
/* increase counter */ ADD_COUNTER(*(counter_base + i), 1, skb->len);
(*(counter_base + i)).pcnt++;
(*(counter_base + i)).bcnt += skb->len;
/* these should only watch: not modify, nor tell us /* these should only watch: not modify, nor tell us
* what to do with the packet * what to do with the packet
...@@ -968,10 +966,9 @@ static void get_counters(const struct ebt_counter *oldcounters, ...@@ -968,10 +966,9 @@ static void get_counters(const struct ebt_counter *oldcounters,
if (cpu == 0) if (cpu == 0)
continue; continue;
counter_base = COUNTER_BASE(oldcounters, nentries, cpu); counter_base = COUNTER_BASE(oldcounters, nentries, cpu);
for (i = 0; i < nentries; i++) { for (i = 0; i < nentries; i++)
counters[i].pcnt += counter_base[i].pcnt; ADD_COUNTER(counters[i], counter_base[i].pcnt,
counters[i].bcnt += counter_base[i].bcnt; counter_base[i].bcnt);
}
} }
} }
...@@ -1324,10 +1321,8 @@ static int do_update_counters(struct net *net, const char *name, ...@@ -1324,10 +1321,8 @@ static int do_update_counters(struct net *net, const char *name,
write_lock_bh(&t->lock); write_lock_bh(&t->lock);
/* we add to the counters of the first cpu */ /* we add to the counters of the first cpu */
for (i = 0; i < num_counters; i++) { for (i = 0; i < num_counters; i++)
t->private->counters[i].pcnt += tmp[i].pcnt; ADD_COUNTER(t->private->counters[i], tmp[i].pcnt, tmp[i].bcnt);
t->private->counters[i].bcnt += tmp[i].bcnt;
}
write_unlock_bh(&t->lock); write_unlock_bh(&t->lock);
ret = 0; ret = 0;
......
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