Skip to content

Commit d72133e

Browse files
TaeheeYooummakynes
authored andcommitted
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: Taehee Yoo <ap420073@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 5b4c6e3 commit d72133e

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

net/bridge/netfilter/ebtables.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,7 @@ unsigned int ebt_do_table(struct sk_buff *skb,
223223
return NF_DROP;
224224
}
225225

226-
/* increase counter */
227-
(*(counter_base + i)).pcnt++;
228-
(*(counter_base + i)).bcnt += skb->len;
226+
ADD_COUNTER(*(counter_base + i), 1, skb->len);
229227

230228
/* these should only watch: not modify, nor tell us
231229
* what to do with the packet
@@ -968,10 +966,9 @@ static void get_counters(const struct ebt_counter *oldcounters,
968966
if (cpu == 0)
969967
continue;
970968
counter_base = COUNTER_BASE(oldcounters, nentries, cpu);
971-
for (i = 0; i < nentries; i++) {
972-
counters[i].pcnt += counter_base[i].pcnt;
973-
counters[i].bcnt += counter_base[i].bcnt;
974-
}
969+
for (i = 0; i < nentries; i++)
970+
ADD_COUNTER(counters[i], counter_base[i].pcnt,
971+
counter_base[i].bcnt);
975972
}
976973
}
977974

@@ -1324,10 +1321,8 @@ static int do_update_counters(struct net *net, const char *name,
13241321
write_lock_bh(&t->lock);
13251322

13261323
/* we add to the counters of the first cpu */
1327-
for (i = 0; i < num_counters; i++) {
1328-
t->private->counters[i].pcnt += tmp[i].pcnt;
1329-
t->private->counters[i].bcnt += tmp[i].bcnt;
1330-
}
1324+
for (i = 0; i < num_counters; i++)
1325+
ADD_COUNTER(t->private->counters[i], tmp[i].pcnt, tmp[i].bcnt);
13311326

13321327
write_unlock_bh(&t->lock);
13331328
ret = 0;

0 commit comments

Comments
 (0)