PERFORCE change 146036 for review
Gleb Kurtsou
gk at FreeBSD.org
Sun Jul 27 11:09:15 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=146036
Change 146036 by gk at gk_h1 on 2008/07/27 11:08:24
add per state flag to mark ethernet state check
not to derefernce rule pointer on every state check and to improve
state dump in user space
note. flag is added into local_flags field wich is FreeBSD only
Affected files ...
.. //depot/projects/soc2008/gk_l2filter/sys-pf/net/pf.c#8 edit
.. //depot/projects/soc2008/gk_l2filter/sys-pf/net/pfvar.h#7 edit
Differences ...
==== //depot/projects/soc2008/gk_l2filter/sys-pf/net/pf.c#8 (text+ko) ====
@@ -706,8 +706,14 @@
{
struct pf_addr_ether *src, *dst;
+#ifdef __FreeBSD__
+ if ((state->local_flags & PFSTATE_ETHER) == 0)
+ return (1);
+#else
+ /* XXX only FreeBSD is supported */
if ((state->rule.ptr->rule_flag & PFRULE_ETHERSTATE) == 0)
return (1);
+#endif
if (direction == PF_IN) {
src = &state->ext.addr_ether;
@@ -3549,6 +3555,10 @@
s->proto = IPPROTO_TCP;
s->direction = direction;
s->af = af;
+#ifdef __FreeBSD__
+ if (r->rule_flag & PFRULE_ETHERSTATE)
+ s->local_flags |= PFSTATE_ETHER;
+#endif
if (direction == PF_OUT) {
PF_ACPY(&s->gwy.addr, saddr, af);
s->gwy.port = th->th_sport; /* sport */
@@ -3950,6 +3960,10 @@
s->proto = IPPROTO_UDP;
s->direction = direction;
s->af = af;
+#ifdef __FreeBSD__
+ if (r->rule_flag & PFRULE_ETHERSTATE)
+ s->local_flags |= PFSTATE_ETHER;
+#endif
if (direction == PF_OUT) {
PF_ACPY(&s->gwy.addr, saddr, af);
s->gwy.port = uh->uh_sport;
@@ -4267,6 +4281,10 @@
s->proto = pd->proto;
s->direction = direction;
s->af = af;
+#ifdef __FreeBSD__
+ if (r->rule_flag & PFRULE_ETHERSTATE)
+ s->local_flags |= PFSTATE_ETHER;
+#endif
if (direction == PF_OUT) {
PF_ACPY(&s->gwy.addr, saddr, af);
s->gwy.port = nport;
@@ -4558,6 +4576,10 @@
s->proto = pd->proto;
s->direction = direction;
s->af = af;
+#ifdef __FreeBSD__
+ if (r->rule_flag & PFRULE_ETHERSTATE)
+ s->local_flags |= PFSTATE_ETHER;
+#endif
if (direction == PF_OUT) {
PF_ACPY(&s->gwy.addr, saddr, af);
s->gwy.addr_ether = pd->src_ether;
==== //depot/projects/soc2008/gk_l2filter/sys-pf/net/pfvar.h#7 (text+ko) ====
@@ -814,6 +814,7 @@
#ifdef __FreeBSD__
u_int8_t local_flags;
#define PFSTATE_EXPIRING 0x01
+#define PFSTATE_ETHER 0x02
#else
u_int8_t pad;
#endif
More information about the p4-projects
mailing list