diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-09-08 18:10:02 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-09-08 18:10:02 +0000 |
commit | 07a039e83c4084e6831cd7c1deb1a732654f4d64 (patch) | |
tree | d3712b4f5c4540052f64e5eb0ca4a2b5606520fd | |
parent | 00a072a4784b0244f1059f20f996ef3b876e6e4b (diff) |
When logging a packet to a listener on the pflog0 interface, the
function pflog_bpfcopy() is setting up a packet description with
pf_setup_pdesc(). When pf_setup_pdesc() is droppig a bad packet,
it increments the the pf status counters. This way bad packets
could be accounted multiple times. Now pflog_bpfcopy() passes a
reason pointer NULL to indicate that no accounting should be done.
From Florian Riehm; OK henning@
-rw-r--r-- | sys/net/if_pflog.c | 10 | ||||
-rw-r--r-- | sys/net/pfvar.h | 9 |
2 files changed, 11 insertions, 8 deletions
diff --git a/sys/net/if_pflog.c b/sys/net/if_pflog.c index 8d10cc32fcd..193541f9983 100644 --- a/sys/net/if_pflog.c +++ b/sys/net/if_pflog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflog.c,v 1.63 2014/09/08 06:24:13 jsg Exp $ */ +/* $OpenBSD: if_pflog.c,v 1.64 2014/09/08 18:10:01 bluhm Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -311,7 +311,6 @@ pflog_bpfcopy(const void *src_arg, void *dst_arg, size_t len) struct pfloghdr *pfloghdr; u_int count; u_char *dst, *mdst; - u_short reason; int afto, hlen, mlen, off; union pf_headers { struct tcphdr tcp; @@ -424,9 +423,12 @@ pflog_bpfcopy(const void *src_arg, void *dst_arg, size_t len) mhdr->m_pkthdr.len += m->m_pkthdr.len - hlen; } - /* rewrite addresses if needed */ + /* + * Rewrite addresses if needed. Reason pointer must be NULL to avoid + * counting the packet here again. + */ if (pf_setup_pdesc(&pd, &pdhdrs, pfloghdr->af, pfloghdr->dir, NULL, - mhdr, &reason) != PF_PASS) + mhdr, NULL) != PF_PASS) goto copy; pd.naf = pfloghdr->naf; diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 222c885a529..7f2fb488edb 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pfvar.h,v 1.402 2014/08/12 15:29:33 mikeb Exp $ */ +/* $OpenBSD: pfvar.h,v 1.403 2014/09/08 18:10:01 bluhm Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -1397,10 +1397,11 @@ struct pf_pdesc { #define REASON_SET(a, x) \ do { \ - if ((void *)(a) != NULL) \ + if ((void *)(a) != NULL) { \ *(a) = (x); \ - if (x < PFRES_MAX) \ - pf_status.counters[x]++; \ + if (x < PFRES_MAX) \ + pf_status.counters[x]++; \ + } \ } while (0) struct pf_status { |