Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149953831
D31748.id95945.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D31748.id95945.diff
View Options
Index: sbin/pfctl/pfctl.c
===================================================================
--- sbin/pfctl/pfctl.c
+++ sbin/pfctl/pfctl.c
@@ -98,7 +98,7 @@
char *);
void pfctl_print_eth_rule_counters(struct pfctl_eth_rule *, int);
void pfctl_print_rule_counters(struct pfctl_rule *, int);
-int pfctl_show_eth_rules(int, int);
+int pfctl_show_eth_rules(int, int, enum pfctl_show);
int pfctl_show_rules(int, char *, int, enum pfctl_show, char *, int);
int pfctl_show_nat(int, int, char *);
int pfctl_show_src_nodes(int, int);
@@ -1052,7 +1052,7 @@
}
int
-pfctl_show_eth_rules(int dev, int opts)
+pfctl_show_eth_rules(int dev, int opts, enum pfctl_show format)
{
struct pfctl_eth_rules_info info;
struct pfctl_eth_rule rule;
@@ -1063,8 +1063,8 @@
return (-1);
}
for (int nr = 0; nr < info.nr; nr++) {
- if (pfctl_get_eth_rule(dev, nr, info.ticket, &rule, false)
- != 0) {
+ if (pfctl_get_eth_rule(dev, nr, info.ticket, &rule,
+ opts & PF_OPT_CLRRULECTRS) != 0) {
warn("DIOCGETETHRULE");
return (-1);
}
@@ -2632,13 +2632,13 @@
pfctl_show_limits(dev, opts);
break;
case 'e':
- pfctl_show_eth_rules(dev, opts);
+ pfctl_show_eth_rules(dev, opts, 0);
break;
case 'a':
opts |= PF_OPT_SHOWALL;
pfctl_load_fingerprints(dev, opts);
- pfctl_show_eth_rules(dev, opts);
+ pfctl_show_eth_rules(dev, opts, 0);
pfctl_show_nat(dev, opts, anchorname);
pfctl_show_rules(dev, path, opts, 0, anchorname, 0);
@@ -2665,9 +2665,11 @@
}
}
- if ((opts & PF_OPT_CLRRULECTRS) && showopt == NULL)
+ if ((opts & PF_OPT_CLRRULECTRS) && showopt == NULL) {
+ pfctl_show_eth_rules(dev, opts, PFCTL_SHOW_NOTHING);
pfctl_show_rules(dev, path, opts, PFCTL_SHOW_NOTHING,
anchorname, 0);
+ }
if (clearopt != NULL) {
if (anchorname[0] == '_' || strstr(anchorname, "/_") != NULL)
Index: sys/netpfil/pf/pf_ioctl.c
===================================================================
--- sys/netpfil/pf/pf_ioctl.c
+++ sys/netpfil/pf/pf_ioctl.c
@@ -2551,6 +2551,7 @@
void *nvlpacked = NULL;
struct pf_keth_rule *rule = NULL;
u_int32_t ticket, nr;
+ bool clear = false;
#define ERROUT(x) do { error = (x); goto DIOCGETETHRULE_error; } while (0)
@@ -2567,6 +2568,13 @@
ERROUT(EBADMSG);
ticket = nvlist_get_number(nvl, "ticket");
+ if (nvlist_exists_bool(nvl, "clear")) {
+ clear = nvlist_get_bool(nvl, "clear");
+ }
+
+ if (clear && !(flags & FWRITE))
+ ERROUT(EACCES);
+
if (! nvlist_exists_number(nvl, "nr"))
ERROUT(EBADMSG);
nr = nvlist_get_number(nvl, "nr");
@@ -2608,6 +2616,13 @@
ERROUT(ENOSPC);
error = copyout(nvlpacked, nv->data, nv->len);
+ if (error == 0 && clear) {
+ counter_u64_zero(rule->evaluations);
+ for (int i = 0; i < 2; i++) {
+ counter_u64_zero(rule->packets[i]);
+ counter_u64_zero(rule->bytes[i]);
+ }
+ }
#undef ERROUT
DIOCGETETHRULE_error:
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 29, 8:49 AM (2 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30519631
Default Alt Text
D31748.id95945.diff (2 KB)
Attached To
Mode
D31748: pf: Support clearing ether counters
Attached
Detach File
Event Timeline
Log In to Comment