diff options
| author | Bart De Schuymer <bart.de.schuymer@pandora.be> | 2002-10-27 13:00:22 -0800 |
|---|---|---|
| committer | David S. Miller <davem@nuts.ninka.net> | 2002-10-27 13:00:22 -0800 |
| commit | 500ae766efda3219964941aba3568af173f85002 (patch) | |
| tree | a1ad40337f8e04635ae3df38d3f130fbeb627e04 | |
| parent | 524c4554beee2b541df90ad2726e91785b698d12 (diff) | |
[EBTABLES]: Add byte counter support, plus header cleanup.
| -rw-r--r-- | include/linux/netfilter_bridge/ebtables.h | 35 | ||||
| -rw-r--r-- | net/bridge/netfilter/ebtables.c | 9 |
2 files changed, 25 insertions, 19 deletions
diff --git a/include/linux/netfilter_bridge/ebtables.h b/include/linux/netfilter_bridge/ebtables.h index 369e6da4171c..72e817524831 100644 --- a/include/linux/netfilter_bridge/ebtables.h +++ b/include/linux/netfilter_bridge/ebtables.h @@ -20,19 +20,6 @@ #define EBT_CHAIN_MAXNAMELEN EBT_TABLE_MAXNAMELEN #define EBT_FUNCTION_MAXNAMELEN EBT_TABLE_MAXNAMELEN -// [gs]etsockopt numbers -#define EBT_BASE_CTL 128 - -#define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) -#define EBT_SO_SET_COUNTERS (EBT_SO_SET_ENTRIES+1) -#define EBT_SO_SET_MAX (EBT_SO_SET_COUNTERS+1) - -#define EBT_SO_GET_INFO (EBT_BASE_CTL) -#define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO+1) -#define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES+1) -#define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO+1) -#define EBT_SO_GET_MAX (EBT_SO_GET_INIT_ENTRIES+1) - // verdicts >0 are "branches" #define EBT_ACCEPT -1 #define EBT_DROP -2 @@ -40,13 +27,10 @@ #define EBT_RETURN -4 #define NUM_STANDARD_TARGETS 4 -// return values for match() functions -#define EBT_MATCH 0 -#define EBT_NOMATCH 1 - struct ebt_counter { uint64_t pcnt; + uint64_t bcnt; }; struct ebt_entries { @@ -178,8 +162,25 @@ struct ebt_replace char *entries; }; +// [gs]etsockopt numbers +#define EBT_BASE_CTL 128 + +#define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) +#define EBT_SO_SET_COUNTERS (EBT_SO_SET_ENTRIES+1) +#define EBT_SO_SET_MAX (EBT_SO_SET_COUNTERS+1) + +#define EBT_SO_GET_INFO (EBT_BASE_CTL) +#define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO+1) +#define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES+1) +#define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO+1) +#define EBT_SO_GET_MAX (EBT_SO_GET_INIT_ENTRIES+1) + #ifdef __KERNEL__ +// return values for match() functions +#define EBT_MATCH 0 +#define EBT_NOMATCH 1 + struct ebt_match { struct list_head list; diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index ab9e4c57789e..8e7d761e2652 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c @@ -194,6 +194,7 @@ unsigned int ebt_do_table (unsigned int hook, struct sk_buff **pskb, // increase counter (*(counter_base + i)).pcnt++; + (*(counter_base + i)).bcnt+=(**pskb).len; // these should only watch: not modify, nor tell us // what to do with the packet @@ -885,8 +886,10 @@ static void get_counters(struct ebt_counter *oldcounters, // add other counters to those of cpu 0 for (cpu = 1; cpu < NR_CPUS; 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; + counters[i].bcnt += counter_base[i].bcnt; + } } } @@ -1245,8 +1248,10 @@ static int update_counters(void *user, unsigned int len) write_lock_bh(&t->lock); // we add to the counters of the first cpu - for (i = 0; i < hlp.num_counters; i++) + for (i = 0; i < hlp.num_counters; i++) { t->private->counters[i].pcnt += tmp[i].pcnt; + t->private->counters[i].bcnt += tmp[i].bcnt; + } write_unlock_bh(&t->lock); ret = 0; |
