Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108564025
D27763.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D27763.diff
View Options
diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h
--- a/sys/net/pfvar.h
+++ b/sys/net/pfvar.h
@@ -879,8 +879,8 @@
} _pfik_glue;
#define pfik_tree _pfik_glue._pfik_tree
#define pfik_list _pfik_glue._pfik_list
- u_int64_t pfik_packets[2][2][2];
- u_int64_t pfik_bytes[2][2][2];
+ counter_u64_t pfik_packets[2][2][2];
+ counter_u64_t pfik_bytes[2][2][2];
u_int32_t pfik_tzero;
u_int pfik_flags;
struct ifnet *pfik_ifp;
@@ -1678,6 +1678,7 @@
struct pfi_kkif *pf_kkif_create(int);
void pf_kkif_free(struct pfi_kkif *);
+void pf_kkif_zero(struct pfi_kkif *);
#endif /* _KERNEL */
#endif /* _NET_PFVAR_H_ */
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c
--- a/sys/netpfil/pf/pf.c
+++ b/sys/netpfil/pf/pf.c
@@ -6196,8 +6196,10 @@
(s == NULL));
}
- kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS] += pd.tot_len;
- kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS]++;
+ counter_u64_add(kif->pfik_bytes[0][dir == PF_OUT][action != PF_PASS],
+ pd.tot_len);
+ counter_u64_add(kif->pfik_packets[0][dir == PF_OUT][action != PF_PASS],
+ 1);
if (action == PF_PASS || r->action == PF_DROP) {
dirndx = (dir == PF_OUT);
@@ -6598,8 +6600,10 @@
&pd, (s == NULL));
}
- kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS] += pd.tot_len;
- kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS]++;
+ counter_u64_add(kif->pfik_bytes[1][dir == PF_OUT][action != PF_PASS],
+ pd.tot_len);
+ counter_u64_add(kif->pfik_packets[1][dir == PF_OUT][action != PF_PASS],
+ 1);
if (action == PF_PASS || r->action == PF_DROP) {
dirndx = (dir == PF_OUT);
diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c
--- a/sys/netpfil/pf/pf_if.c
+++ b/sys/netpfil/pf/pf_if.c
@@ -223,7 +223,26 @@
{
struct pfi_kkif *kif;
- kif = malloc(sizeof(*kif), PFI_MTYPE, flags);
+ kif = malloc(sizeof(*kif), PFI_MTYPE, flags | M_ZERO);
+ if (! kif)
+ return (kif);
+
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 2; j++) {
+ for (int k = 0; k < 2; k++) {
+ kif->pfik_packets[i][j][k] =
+ counter_u64_alloc(flags);
+ kif->pfik_bytes[i][j][k] =
+ counter_u64_alloc(flags);
+
+ if (! kif->pfik_packets[i][j][k] ||
+ ! kif->pfik_bytes[i][j][k]) {
+ pf_kkif_free(kif);
+ return (NULL);
+ }
+ }
+ }
+ }
return (kif);
}
@@ -234,9 +253,35 @@
if (! kif)
return;
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 2; j++) {
+ for (int k = 0; k < 2; k++) {
+ if (kif->pfik_packets[i][j][k])
+ counter_u64_free(kif->pfik_packets[i][j][k]);
+ if (kif->pfik_bytes[i][j][k])
+ counter_u64_free(kif->pfik_bytes[i][j][k]);
+ }
+ }
+ }
+
free(kif, PFI_MTYPE);
}
+void
+pf_kkif_zero(struct pfi_kkif *kif)
+{
+
+ for (int i = 0; i < 2; i++) {
+ for (int j = 0; j < 2; j++) {
+ for (int k = 0; k < 2; k++) {
+ counter_u64_zero(kif->pfik_packets[i][j][k]);
+ counter_u64_zero(kif->pfik_bytes[i][j][k]);
+ }
+ }
+ }
+ kif->pfik_tzero = time_second;
+}
+
struct pfi_kkif *
pfi_kkif_find(const char *kif_name)
{
@@ -264,7 +309,7 @@
return (kif1);
}
- bzero(kif, sizeof(*kif));
+ pf_kkif_zero(kif);
strlcpy(kif->pfik_name, kif_name, sizeof(kif->pfik_name));
/*
* It seems that the value of time_second is in unintialzied state
@@ -754,18 +799,16 @@
/* just clear statistics */
if (pfs == NULL) {
- bzero(p->pfik_packets, sizeof(p->pfik_packets));
- bzero(p->pfik_bytes, sizeof(p->pfik_bytes));
- p->pfik_tzero = time_second;
+ pf_kkif_zero(p);
continue;
}
for (i = 0; i < 2; i++)
for (j = 0; j < 2; j++)
for (k = 0; k < 2; k++) {
pfs->pcounters[i][j][k] +=
- p->pfik_packets[i][j][k];
+ counter_u64_fetch(p->pfik_packets[i][j][k]);
pfs->bcounters[i][j] +=
- p->pfik_bytes[i][j][k];
+ counter_u64_fetch(p->pfik_bytes[i][j][k]);
}
}
}
@@ -780,9 +823,9 @@
for (int j = 0; j < 2; j++) {
for (int k = 0; k < 2; k++) {
kif->pfik_packets[i][j][k] =
- kkif->pfik_packets[i][j][k];
+ counter_u64_fetch(kkif->pfik_packets[i][j][k]);
kif->pfik_bytes[i][j][k] =
- kkif->pfik_bytes[i][j][k];
+ counter_u64_fetch(kkif->pfik_bytes[i][j][k]);
}
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 9:30 AM (3 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16193579
Default Alt Text
D27763.diff (4 KB)
Attached To
Mode
D27763: pf: Convert pfi_kkif to use counter_u64
Attached
Detach File
Event Timeline
Log In to Comment