From owner-p4-projects@FreeBSD.ORG Sun Jul 27 11:09:15 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1EA461065673; Sun, 27 Jul 2008 11:09:15 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D710E1065671 for ; Sun, 27 Jul 2008 11:09:14 +0000 (UTC) (envelope-from gk@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C8F4E8FC12 for ; Sun, 27 Jul 2008 11:09:14 +0000 (UTC) (envelope-from gk@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m6RB9EWj081555 for ; Sun, 27 Jul 2008 11:09:14 GMT (envelope-from gk@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6RB9ENO081553 for perforce@freebsd.org; Sun, 27 Jul 2008 11:09:14 GMT (envelope-from gk@FreeBSD.org) Date: Sun, 27 Jul 2008 11:09:14 GMT Message-Id: <200807271109.m6RB9ENO081553@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to gk@FreeBSD.org using -f From: Gleb Kurtsou To: Perforce Change Reviews Cc: Subject: PERFORCE change 146036 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2008 11:09:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=146036 Change 146036 by gk@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