Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F174153238
D60161.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D60161.diff
View Options
diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c
--- a/sys/netpfil/pf/pf_nl.c
+++ b/sys/netpfil/pf/pf_nl.c
@@ -1044,6 +1044,17 @@
struct pf_krule *rule;
int rs_num;
int error;
+ PF_RULES_RLOCK_TRACKER;
+
+/* The write lock to clear counters, the read lock to only read them. */
+#define PF_GETRULE_LOCKOP(op) do { \
+ if (attrs.clear) \
+ PF_RULES_W##op(); \
+ else \
+ PF_RULES_R##op(); \
+} while (0)
+#define PF_GETRULE_LOCK() PF_GETRULE_LOCKOP(LOCK)
+#define PF_GETRULE_UNLOCK() PF_GETRULE_LOCKOP(UNLOCK)
error = nl_parse_nlmsg(hdr, &getrule_parser, npt, &attrs);
if (error != 0)
@@ -1055,23 +1066,23 @@
ghdr_new = nlmsg_reserve_object(nw, struct genlmsghdr);
ghdr_new->cmd = PFNL_CMD_GETRULE;
- PF_RULES_WLOCK();
+ PF_GETRULE_LOCK();
ruleset = pf_find_kruleset(attrs.anchor);
if (ruleset == NULL) {
- PF_RULES_WUNLOCK();
+ PF_GETRULE_UNLOCK();
error = ENOENT;
goto out;
}
rs_num = pf_get_ruleset_number(attrs.action);
if (rs_num >= PF_RULESET_MAX) {
- PF_RULES_WUNLOCK();
+ PF_GETRULE_UNLOCK();
error = EINVAL;
goto out;
}
if (attrs.ticket != ruleset->rules[rs_num].active.ticket) {
- PF_RULES_WUNLOCK();
+ PF_GETRULE_UNLOCK();
error = EBUSY;
goto out;
}
@@ -1080,7 +1091,7 @@
while ((rule != NULL) && (rule->nr != attrs.nr))
rule = TAILQ_NEXT(rule, entries);
if (rule == NULL) {
- PF_RULES_WUNLOCK();
+ PF_GETRULE_UNLOCK();
error = EBUSY;
goto out;
}
@@ -1095,7 +1106,10 @@
if (attrs.clear)
pf_krule_clear_counters(rule);
- PF_RULES_WUNLOCK();
+ PF_GETRULE_UNLOCK();
+#undef PF_GETRULE_LOCKOP
+#undef PF_GETRULE_LOCK
+#undef PF_GETRULE_UNLOCK
if (!nlmsg_end(nw)) {
error = ENOMEM;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 1, 11:32 PM (15 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39988610
Default Alt Text
D60161.diff (1 KB)
Attached To
Mode
D60161: pf: take the rules read lock in pf_handle_getrule()
Attached
Detach File
Event Timeline
Log In to Comment