Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177952745
D60537.1795635770.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D60537.1795635770.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
@@ -2916,7 +2916,7 @@
int pf_translate(struct pf_pdesc *, struct pf_addr *, u_int16_t,
struct pf_addr *, u_int16_t, u_int16_t, int);
bool pf_init_threshold(struct pf_kthreshold *, uint32_t, uint32_t);
-uint16_t pf_tagname2tag(const char *);
+uint16_t pf_tagname2tag(const char *, bool);
#ifdef ALTQ
uint16_t pf_qname2qid(const char *, bool);
#endif /* ALTQ */
diff --git a/sys/netpfil/pf/if_pfsync.c b/sys/netpfil/pf/if_pfsync.c
--- a/sys/netpfil/pf/if_pfsync.c
+++ b/sys/netpfil/pf/if_pfsync.c
@@ -851,7 +851,8 @@
bcopy(&sp->pfs_1500.rt_addr, &st->act.rt_addr,
sizeof(st->act.rt_addr));
if (sp->pfs_1500.tagname[0] != 0)
- st->tag = pf_tagname2tag(sp->pfs_1500.tagname);
+ st->tag = pf_tagname2tag(
+ sp->pfs_1500.tagname, false);
break;
default:
panic("%s: Unsupported pfsync_msg_version %d",
diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c
--- a/sys/netpfil/pf/pf_ioctl.c
+++ b/sys/netpfil/pf/pf_ioctl.c
@@ -706,20 +706,19 @@
index = tagname2hashindex(ts, tagname);
TAILQ_FOREACH(tag, &ts->namehash[index], namehash_entries)
if (strcmp(tagname, tag->name) == 0) {
- tag->ref++;
+ if (add_new)
+ tag->ref++;
new_tagid = tag->tag;
PF_TAGS_RUNLOCK();
return (new_tagid);
}
/*
- * When used for pfsync with queues we must not create new entries.
- * Pf tags can be created just fine by this function, but queues
- * require additional configuration. If they are missing on the target
- * system we just ignore them
+ * Without add_new, the name is only looked up, for a state that pfsync
+ * imports. States do not hold a reference on their tag or queue, so
+ * none was taken above, and a name that no rule uses is not created.
*/
if (add_new == false) {
- printf("%s: Not creating a new tag\n", __func__);
PF_TAGS_RUNLOCK();
return (0);
}
@@ -831,9 +830,9 @@
}
uint16_t
-pf_tagname2tag(const char *tagname)
+pf_tagname2tag(const char *tagname, bool add_new)
{
- return (tagname2tag(&V_pf_tags, tagname, true));
+ return (tagname2tag(&V_pf_tags, tagname, add_new));
}
static const char *
@@ -3143,11 +3142,11 @@
}
#endif
if (rule->tagname[0])
- if ((rule->tag = pf_tagname2tag(rule->tagname)) == 0)
+ if ((rule->tag = pf_tagname2tag(rule->tagname, true)) == 0)
ERROUT(EBUSY);
if (rule->match_tagname[0])
if ((rule->match_tag =
- pf_tagname2tag(rule->match_tagname)) == 0)
+ pf_tagname2tag(rule->match_tagname, true)) == 0)
ERROUT(EBUSY);
if (rule->rt && !rule->direction)
ERROUT(EINVAL);
@@ -4252,11 +4251,12 @@
}
#endif
if (rule->tagname[0])
- if ((rule->tag = pf_tagname2tag(rule->tagname)) == 0)
+ if ((rule->tag = pf_tagname2tag(rule->tagname,
+ true)) == 0)
error = EBUSY;
if (rule->match_tagname[0])
if ((rule->match_tag = pf_tagname2tag(
- rule->match_tagname)) == 0)
+ rule->match_tagname, true)) == 0)
error = EBUSY;
if (error == 0 && rule->ipdst.addr.type == PF_ADDR_TABLE)
@@ -4801,12 +4801,12 @@
}
#endif /* ALTQ */
if (newrule->tagname[0])
- if ((newrule->tag =
- pf_tagname2tag(newrule->tagname)) == 0)
+ if ((newrule->tag = pf_tagname2tag(
+ newrule->tagname, true)) == 0)
error = EBUSY;
if (newrule->match_tagname[0])
if ((newrule->match_tag = pf_tagname2tag(
- newrule->match_tagname)) == 0)
+ newrule->match_tagname, true)) == 0)
error = EBUSY;
if (newrule->rt && !newrule->direction)
error = EINVAL;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 25, 7:42 PM (22 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41997650
Default Alt Text
D60537.1795635770.diff (3 KB)
Attached To
Mode
D60537: pfsync: Do not reference the tag of an imported state
Attached
Detach File
Event Timeline