Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Feb 2012 16:35:16 +0000
From:      =?ISO-8859-1?Q?Ermal_Lu=E7i?= <eri@freebsd.org>
To:        Gleb Smirnoff <glebius@freebsd.org>
Cc:        svn-src-projects@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r232043 - projects/pf/head/sys/contrib/pf/net
Message-ID:  <CAPBZQG0w%2BkWMC5y3r6gVGs21QjMWj89QRgy829TEjHmTPCAZmw@mail.gmail.com>
In-Reply-To: <201202231018.q1NAISrV099085@svn.freebsd.org>
References:  <201202231018.q1NAISrV099085@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Any reason behind doing this work?

On Thu, Feb 23, 2012 at 10:18 AM, Gleb Smirnoff <glebius@freebsd.org> wrote=
:
> Author: glebius
> Date: Thu Feb 23 10:18:28 2012
> New Revision: 232043
> URL: http://svn.freebsd.org/changeset/base/232043
>
> Log:
> =A0- Cleanup #ifdef.
> =A0- Remove spl(9) calls.
> =A0- Remove #defines that mask FreeBSD API: use uma(9) implicitly,
> =A0 =A0use correct malloc(9) flags, etc..
> =A0- Minor cleanups.
>
> =A0Only compile tested.
>
> Modified:
> =A0projects/pf/head/sys/contrib/pf/net/if_pflog.c
> =A0projects/pf/head/sys/contrib/pf/net/if_pflog.h
> =A0projects/pf/head/sys/contrib/pf/net/if_pflow.h
> =A0projects/pf/head/sys/contrib/pf/net/if_pfsync.c
> =A0projects/pf/head/sys/contrib/pf/net/if_pfsync.h
> =A0projects/pf/head/sys/contrib/pf/net/pf.c
> =A0projects/pf/head/sys/contrib/pf/net/pf_if.c
> =A0projects/pf/head/sys/contrib/pf/net/pf_ioctl.c
> =A0projects/pf/head/sys/contrib/pf/net/pf_lb.c
> =A0projects/pf/head/sys/contrib/pf/net/pf_norm.c
> =A0projects/pf/head/sys/contrib/pf/net/pf_osfp.c
> =A0projects/pf/head/sys/contrib/pf/net/pf_ruleset.c
> =A0projects/pf/head/sys/contrib/pf/net/pf_table.c
> =A0projects/pf/head/sys/contrib/pf/net/pfvar.h
>
> Modified: projects/pf/head/sys/contrib/pf/net/if_pflog.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- projects/pf/head/sys/contrib/pf/net/if_pflog.c =A0 =A0 =A0Thu Feb 23 =
09:23:10 2012 =A0 =A0 =A0 =A0(r232042)
> +++ projects/pf/head/sys/contrib/pf/net/if_pflog.c =A0 =A0 =A0Thu Feb 23 =
10:18:28 2012 =A0 =A0 =A0 =A0(r232043)
> @@ -33,7 +33,6 @@
> =A0* PURPOSE.
> =A0*/
>
> -#ifdef __FreeBSD__
> =A0#include "opt_inet.h"
> =A0#include "opt_inet6.h"
> =A0#include "opt_bpf.h"
> @@ -54,30 +53,20 @@ __FBSDID("$FreeBSD$");
> =A0#define =A0 =A0 =A0 =A0NPFLOG =A0 =A0 =A0 =A0 =A00
> =A0#endif
>
> -#else /* ! __FreeBSD__ */
> -#include "bpfilter.h"
> -#include "pflog.h"
> -#endif /* __FreeBSD__ */
>
> =A0#include <sys/param.h>
> =A0#include <sys/systm.h>
> =A0#include <sys/mbuf.h>
> =A0#include <sys/proc.h>
> =A0#include <sys/socket.h>
> -#ifdef __FreeBSD__
> =A0#include <sys/kernel.h>
> =A0#include <sys/limits.h>
> =A0#include <sys/malloc.h>
> =A0#include <sys/module.h>
> =A0#include <sys/sockio.h>
> -#else
> -#include <sys/ioctl.h>
> -#endif
>
> =A0#include <net/if.h>
> -#ifdef __FreeBSD__
> =A0#include <net/if_clone.h>
> -#endif
> =A0#include <net/if_types.h>
> =A0#include <net/route.h>
> =A0#include <net/bpf.h>
> @@ -99,11 +88,9 @@ __FBSDID("$FreeBSD$");
> =A0#include <net/pfvar.h>
> =A0#include <net/if_pflog.h>
>
> -#ifdef __FreeBSD__
> =A0#ifdef INET
> =A0#include <machine/in_cksum.h>
> =A0#endif /* INET */
> -#endif /* __FreeBSD__ */
>
> =A0#define PFLOGMTU =A0 =A0 =A0 (32768 + MHLEN + MLEN)
>
> @@ -115,28 +102,14 @@ __FBSDID("$FreeBSD$");
>
> =A0void =A0 pflogattach(int);
> =A0int =A0 =A0pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr =
*,
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0 =A0 =A0struct route *);
> -#else
> - =A0 =A0 =A0 =A0 =A0 struct rtentry *);
> -#endif
> =A0int =A0 =A0pflogioctl(struct ifnet *, u_long, caddr_t);
> =A0void =A0 pflogstart(struct ifnet *);
> -#ifdef __FreeBSD__
> =A0static int pflog_clone_create(struct if_clone *, int, caddr_t);
> =A0static void pflog_clone_destroy(struct ifnet *);
> -#else
> -int =A0 =A0pflog_clone_create(struct if_clone *, int);
> -int =A0 =A0pflog_clone_destroy(struct ifnet *);
> -#endif
>
> =A0LIST_HEAD(, pflog_softc) =A0 =A0 =A0 pflogif_list;
> -#ifdef __FreeBSD__
> =A0IFC_SIMPLE_DECLARE(pflog, 1);
> -#else
> -struct if_clone =A0 =A0 =A0 =A0pflog_cloner =3D
> - =A0 =A0IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_de=
stroy);
> -#endif
>
> =A0struct ifnet =A0 *pflogifs[PFLOGIFS_MAX]; =A0 =A0 =A0 =A0/* for fast a=
ccess */
>
> @@ -150,17 +123,11 @@ pflogattach(int npflog)
> =A0 =A0 =A0 =A0if_clone_attach(&pflog_cloner);
> =A0}
>
> -#ifdef __FreeBSD__
> =A0static int
> =A0pflog_clone_create(struct if_clone *ifc, int unit, caddr_t param)
> -#else
> -int
> -pflog_clone_create(struct if_clone *ifc, int unit)
> -#endif
> =A0{
> =A0 =A0 =A0 =A0struct ifnet *ifp;
> =A0 =A0 =A0 =A0struct pflog_softc *pflogif;
> - =A0 =A0 =A0 int s;
>
> =A0 =A0 =A0 =A0if (unit >=3D PFLOGIFS_MAX)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (EINVAL);
> @@ -170,88 +137,50 @@ pflog_clone_create(struct if_clone *ifc,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (ENOMEM);
>
> =A0 =A0 =A0 =A0pflogif->sc_unit =3D unit;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0ifp =3D pflogif->sc_ifp =3D if_alloc(IFT_PFLOG);
> =A0 =A0 =A0 =A0if (ifp =3D=3D NULL) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0free(pflogif, M_DEVBUF);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (ENOSPC);
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0if_initname(ifp, ifc->ifc_name, unit);
> -#else
> - =A0 =A0 =A0 ifp =3D &pflogif->sc_if;
> - =A0 =A0 =A0 snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", un=
it);
> -#endif
> =A0 =A0 =A0 =A0ifp->if_softc =3D pflogif;
> =A0 =A0 =A0 =A0ifp->if_mtu =3D PFLOGMTU;
> =A0 =A0 =A0 =A0ifp->if_ioctl =3D pflogioctl;
> =A0 =A0 =A0 =A0ifp->if_output =3D pflogoutput;
> =A0 =A0 =A0 =A0ifp->if_start =3D pflogstart;
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 ifp->if_type =3D IFT_PFLOG;
> -#endif
> =A0 =A0 =A0 =A0ifp->if_snd.ifq_maxlen =3D ifqmaxlen;
> =A0 =A0 =A0 =A0ifp->if_hdrlen =3D PFLOG_HDRLEN;
> =A0 =A0 =A0 =A0if_attach(ifp);
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 if_alloc_sadl(ifp);
> -#endif
>
> =A0#if NBPFILTER > 0
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN);
> -#else
> - =A0 =A0 =A0 bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDR=
LEN);
> -#endif
> =A0#endif
>
> - =A0 =A0 =A0 s =3D splnet();
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0/* XXX: Why pf(4) lock?! Better add a pflog lock?! */
> =A0 =A0 =A0 =A0PF_LOCK();
> -#endif
> =A0 =A0 =A0 =A0LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list);
> =A0 =A0 =A0 =A0pflogifs[unit] =3D ifp;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0PF_UNLOCK();
> -#endif
> - =A0 =A0 =A0 splx(s);
>
> =A0 =A0 =A0 =A0return (0);
> =A0}
>
> -#ifdef __FreeBSD__
> =A0static void
> =A0pflog_clone_destroy(struct ifnet *ifp)
> -#else
> -int
> -pflog_clone_destroy(struct ifnet *ifp)
> -#endif
> =A0{
> =A0 =A0 =A0 =A0struct pflog_softc =A0 =A0 =A0*pflogif =3D ifp->if_softc;
> - =A0 =A0 =A0 int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0s;
>
> - =A0 =A0 =A0 s =3D splnet();
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0PF_LOCK();
> -#endif
> =A0 =A0 =A0 =A0pflogifs[pflogif->sc_unit] =3D NULL;
> =A0 =A0 =A0 =A0LIST_REMOVE(pflogif, sc_list);
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0PF_UNLOCK();
> -#endif
> - =A0 =A0 =A0 splx(s);
>
> =A0#if NBPFILTER > 0
> =A0 =A0 =A0 =A0bpfdetach(ifp);
> =A0#endif
> =A0 =A0 =A0 =A0if_detach(ifp);
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0if_free(ifp);
> -#endif
> =A0 =A0 =A0 =A0free(pflogif, M_DEVBUF);
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 return (0);
> -#endif
> =A0}
>
> =A0/*
> @@ -261,22 +190,12 @@ void
> =A0pflogstart(struct ifnet *ifp)
> =A0{
> =A0 =A0 =A0 =A0struct mbuf *m;
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 int s;
> -#endif
>
> =A0 =A0 =A0 =A0for (;;) {
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IF_LOCK(&ifp->if_snd);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_IF_DROP(&ifp->if_snd);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0_IF_DEQUEUE(&ifp->if_snd, m);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0IF_UNLOCK(&ifp->if_snd);
> -#else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 s =3D splnet();
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 IF_DROP(&ifp->if_snd);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 IF_DEQUEUE(&ifp->if_snd, m);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 splx(s);
> -#endif
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (m =3D=3D NULL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return;
> @@ -287,11 +206,7 @@ pflogstart(struct ifnet *ifp)
>
> =A0int
> =A0pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct route *rt)
> -#else
> - =A0 =A0 =A0 struct rtentry *rt)
> -#endif
> =A0{
> =A0 =A0 =A0 =A0m_freem(m);
> =A0 =A0 =A0 =A0return (0);
> @@ -303,17 +218,10 @@ pflogioctl(struct ifnet *ifp, u_long cmd
> =A0{
> =A0 =A0 =A0 =A0switch (cmd) {
> =A0 =A0 =A0 =A0case SIOCSIFFLAGS:
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (ifp->if_flags & IFF_UP)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ifp->if_drv_flags |=3D IFF=
_DRV_RUNNING;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ifp->if_drv_flags &=3D ~IF=
F_DRV_RUNNING;
> -#else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (ifp->if_flags & IFF_UP)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ifp->if_flags |=3D IFF_RUNN=
ING;
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ifp->if_flags &=3D ~IFF_RUN=
NING;
> -#endif
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0break;
> =A0 =A0 =A0 =A0default:
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (ENOTTY);
> @@ -355,15 +263,11 @@ pflog_packet(struct pfi_kif *kif, struct
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sizeof(hdr.ruleset=
));
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done)
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/*
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * XXX: This should not happen as we force=
 an early lookup
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 * via debug.pfugidhack
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 */
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0; /* empty */
> -#else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pd->lookup.done =3D pf_socket_lookup(dir, p=
d);
> -#endif
> =A0 =A0 =A0 =A0if (pd->lookup.done > 0) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0hdr.uid =3D pd->lookup.uid;
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0hdr.pid =3D pd->lookup.pid;
> @@ -387,18 +291,12 @@ pflog_packet(struct pfi_kif *kif, struct
>
> =A0 =A0 =A0 =A0ifn->if_opackets++;
> =A0 =A0 =A0 =A0ifn->if_obytes +=3D m->m_pkthdr.len;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m);
> -#else
> - =A0 =A0 =A0 bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m,
> - =A0 =A0 =A0 =A0 =A0 BPF_DIRECTION_OUT);
> -#endif
> =A0#endif
>
> =A0 =A0 =A0 =A0return (0);
> =A0}
>
> -#ifdef __FreeBSD__
> =A0static int
> =A0pflog_modevent(module_t mod, int type, void *data)
> =A0{
> @@ -432,4 +330,3 @@ static moduledata_t pflog_mod =3D { "pflog
> =A0DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
> =A0MODULE_VERSION(pflog, PFLOG_MODVER);
> =A0MODULE_DEPEND(pflog, pf, PF_MODVER, PF_MODVER, PF_MODVER);
> -#endif /* __FreeBSD__ */
>
> Modified: projects/pf/head/sys/contrib/pf/net/if_pflog.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- projects/pf/head/sys/contrib/pf/net/if_pflog.h =A0 =A0 =A0Thu Feb 23 =
09:23:10 2012 =A0 =A0 =A0 =A0(r232042)
> +++ projects/pf/head/sys/contrib/pf/net/if_pflog.h =A0 =A0 =A0Thu Feb 23 =
10:18:28 2012 =A0 =A0 =A0 =A0(r232043)
> @@ -30,11 +30,7 @@
> =A0#define =A0 =A0 =A0 =A0PFLOGIFS_MAX =A0 =A016
>
> =A0struct pflog_softc {
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct ifnet =A0 =A0 =A0 =A0 =A0 =A0*sc_ifp; =A0 =A0 =A0 =
=A0/* the interface pointer */
> -#else
> - =A0 =A0 =A0 struct ifnet =A0 =A0 =A0 =A0 =A0 =A0sc_if; =A0 =A0 =A0 =A0 =
=A0/* the interface */
> -#endif
> =A0 =A0 =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sc_unit;
> =A0 =A0 =A0 =A0LIST_ENTRY(pflog_softc) sc_list;
> =A0};
> @@ -74,28 +70,14 @@ struct old_pfloghdr {
> =A0#define =A0 =A0 =A0 =A0OLD_PFLOG_HDRLEN =A0 =A0 =A0 =A0sizeof(struct o=
ld_pfloghdr)
>
> =A0#ifdef _KERNEL
> -#ifdef __FreeBSD__
> =A0struct pf_rule;
> =A0struct pf_ruleset;
> =A0struct pfi_kif;
> =A0struct pf_pdesc;
>
> -#if 0
> -typedef int pflog_packet_t(struct pfi_kif *, struct mbuf *, sa_family_t,
> - =A0 =A0u_int8_t, u_int8_t, struct pf_rule *, struct pf_rule *,
> - =A0 =A0struct pf_ruleset *, struct pf_pdesc *);
> -extern pflog_packet_t *pflog_packet_ptr;
> -#endif
> =A0#define =A0 =A0 =A0 =A0PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) do { =A0 =A0 =
=A0 =A0 =A0\
> =A0 =A0 =A0 =A0if (pflog_packet_ptr !=3D NULL) =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 \
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pflog_packet_ptr(i,a,b,c,d,e,f,g,h); =A0 =
=A0\
> =A0} while (0)
> -#else /* ! __FreeBSD__ */
> -#if NPFLOG > 0
> -#define =A0 =A0 =A0 =A0PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) pflog_packet(i,=
a,b,c,d,e,f,g,h)
> -#else
> -#define =A0 =A0 =A0 =A0PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) ((void)0)
> -#endif /* NPFLOG > 0 */
> -#endif
> =A0#endif /* _KERNEL */
> =A0#endif /* _NET_IF_PFLOG_H_ */
>
> Modified: projects/pf/head/sys/contrib/pf/net/if_pflow.h
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- projects/pf/head/sys/contrib/pf/net/if_pflow.h =A0 =A0 =A0Thu Feb 23 =
09:23:10 2012 =A0 =A0 =A0 =A0(r232042)
> +++ projects/pf/head/sys/contrib/pf/net/if_pflow.h =A0 =A0 =A0Thu Feb 23 =
10:18:28 2012 =A0 =A0 =A0 =A0(r232043)
> @@ -66,11 +66,7 @@ struct pflow_softc {
> =A0 =A0 =A0 =A0unsigned int =A0 =A0 =A0 =A0 =A0 =A0 sc_maxcount;
> =A0 =A0 =A0 =A0u_int64_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc_gcounter;
> =A0 =A0 =A0 =A0struct ip_moptions =A0 =A0 =A0 sc_imo;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct callout =A0 =A0 =A0 =A0 =A0 sc_tmo;
> -#else
> - =A0 =A0 =A0 struct timeout =A0 =A0 =A0 =A0 =A0 sc_tmo;
> -#endif
> =A0 =A0 =A0 =A0struct in_addr =A0 =A0 =A0 =A0 =A0 sc_sender_ip;
> =A0 =A0 =A0 =A0u_int16_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc_sender_port;
> =A0 =A0 =A0 =A0struct in_addr =A0 =A0 =A0 =A0 =A0 sc_receiver_ip;
>
> Modified: projects/pf/head/sys/contrib/pf/net/if_pfsync.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- projects/pf/head/sys/contrib/pf/net/if_pfsync.c =A0 =A0 Thu Feb 23 09=
:23:10 2012 =A0 =A0 =A0 =A0(r232042)
> +++ projects/pf/head/sys/contrib/pf/net/if_pfsync.c =A0 =A0 Thu Feb 23 10=
:18:28 2012 =A0 =A0 =A0 =A0(r232043)
> @@ -51,7 +51,6 @@
> =A0* 1.170 - SIOCSIFMTU checks
> =A0*/
>
> -#ifdef __FreeBSD__
> =A0#include "opt_inet.h"
> =A0#include "opt_inet6.h"
> =A0#include "opt_pf.h"
> @@ -60,21 +59,17 @@
> =A0__FBSDID("$FreeBSD$");
>
> =A0#define =A0 =A0 =A0 =A0NBPFILTER =A0 =A0 =A0 1
> -#endif /* __FreeBSD__ */
>
> =A0#include <sys/param.h>
> =A0#include <sys/kernel.h>
> -#ifdef __FreeBSD__
> =A0#include <sys/bus.h>
> =A0#include <sys/interrupt.h>
> =A0#include <sys/priv.h>
> -#endif
> =A0#include <sys/proc.h>
> =A0#include <sys/systm.h>
> =A0#include <sys/time.h>
> =A0#include <sys/mbuf.h>
> =A0#include <sys/socket.h>
> -#ifdef __FreeBSD__
> =A0#include <sys/endian.h>
> =A0#include <sys/malloc.h>
> =A0#include <sys/module.h>
> @@ -83,26 +78,15 @@ __FBSDID("$FreeBSD$");
> =A0#include <sys/lock.h>
> =A0#include <sys/mutex.h>
> =A0#include <sys/protosw.h>
> -#else
> -#include <sys/ioctl.h>
> -#include <sys/timeout.h>
> -#endif
> =A0#include <sys/sysctl.h>
> -#ifndef __FreeBSD__
> -#include <sys/pool.h>
> -#endif
>
> =A0#include <net/if.h>
> -#ifdef __FreeBSD__
> =A0#include <net/if_clone.h>
> -#endif
> =A0#include <net/if_types.h>
> =A0#include <net/route.h>
> =A0#include <net/bpf.h>
> =A0#include <net/netisr.h>
> -#ifdef __FreeBSD__
> =A0#include <net/vnet.h>
> -#endif
>
> =A0#include <netinet/in.h>
> =A0#include <netinet/if_ether.h>
> @@ -120,22 +104,11 @@ __FBSDID("$FreeBSD$");
> =A0#include <netinet6/nd6.h>
> =A0#endif /* INET6 */
>
> -#ifdef __FreeBSD__
> =A0#include <netinet/ip_carp.h>
> -#else
> -#include "carp.h"
> -#if NCARP > 0
> -#include <netinet/ip_carp.h>
> -#endif
> -#endif
>
> =A0#include <net/pfvar.h>
> =A0#include <net/if_pfsync.h>
>
> -#ifndef __FreeBSD__
> -#include "bpfilter.h"
> -#include "pfsync.h"
> -#endif
>
> =A0#define PFSYNC_MINPKT ( \
> =A0 =A0 =A0 =A0sizeof(struct ip) + \
> @@ -217,11 +190,7 @@ struct pfsync_deferral {
> =A0 =A0 =A0 =A0TAILQ_ENTRY(pfsync_deferral) =A0 =A0 =A0 =A0 =A0 =A0 pd_en=
try;
> =A0 =A0 =A0 =A0struct pf_state =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 *pd_st;
> =A0 =A0 =A0 =A0struct mbuf =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 *pd_m;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct callout =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=
 =A0 =A0 pd_tmo;
> -#else
> - =A0 =A0 =A0 struct timeout =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 pd_tmo;
> -#endif
> =A0};
> =A0TAILQ_HEAD(pfsync_deferrals, pfsync_deferral);
>
> @@ -233,26 +202,16 @@ int =A0 =A0 =A0 pfsync_out_tdb(struct tdb *, struct
> =A0#endif
>
> =A0struct pfsync_softc {
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct ifnet =A0 =A0 =A0 =A0 =A0 =A0*sc_ifp;
> -#else
> - =A0 =A0 =A0 struct ifnet =A0 =A0 =A0 =A0 =A0 =A0 sc_if;
> -#endif
> =A0 =A0 =A0 =A0struct ifnet =A0 =A0 =A0 =A0 =A0 =A0*sc_sync_if;
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0uma_zone_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 sc_pool;
> -#else
> - =A0 =A0 =A0 struct pool =A0 =A0 =A0 =A0 =A0 =A0 =A0sc_pool;
> -#endif
>
> =A0 =A0 =A0 =A0struct ip_moptions =A0 =A0 =A0 sc_imo;
>
> =A0 =A0 =A0 =A0struct in_addr =A0 =A0 =A0 =A0 =A0 sc_sync_peer;
> =A0 =A0 =A0 =A0u_int8_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 sc_maxupdates;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pfsync_sync=
_ok;
> -#endif
>
> =A0 =A0 =A0 =A0struct ip =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc_template;
>
> @@ -269,31 +228,18 @@ struct pfsync_softc {
>
> =A0 =A0 =A0 =A0u_int32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc_ureq_sent;
> =A0 =A0 =A0 =A0int =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc_bulk_tri=
es;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct callout =A0 =A0 =A0 =A0 =A0 sc_bulkfail_tmo;
> -#else
> - =A0 =A0 =A0 struct timeout =A0 =A0 =A0 =A0 =A0 sc_bulkfail_tmo;
> -#endif
>
> =A0 =A0 =A0 =A0u_int32_t =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sc_ureq_received;
> =A0 =A0 =A0 =A0struct pf_state =A0 =A0 =A0 =A0 *sc_bulk_next;
> =A0 =A0 =A0 =A0struct pf_state =A0 =A0 =A0 =A0 *sc_bulk_last;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct callout =A0 =A0 =A0 =A0 =A0 sc_bulk_tmo;
> -#else
> - =A0 =A0 =A0 struct timeout =A0 =A0 =A0 =A0 =A0 sc_bulk_tmo;
> -#endif
>
> =A0 =A0 =A0 =A0TAILQ_HEAD(, tdb) =A0 =A0 =A0 =A0sc_tdb_q;
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct callout =A0 =A0 =A0 =A0 =A0 sc_tmo;
> -#else
> - =A0 =A0 =A0 struct timeout =A0 =A0 =A0 =A0 =A0 sc_tmo;
> -#endif
> =A0};
>
> -#ifdef __FreeBSD__
> =A0static MALLOC_DEFINE(M_PFSYNC, "pfsync", "pfsync data");
> =A0static VNET_DEFINE(struct pfsync_softc *, pfsyncif) =3D NULL;
> =A0#define =A0 =A0 =A0 =A0V_pfsyncif =A0 =A0 =A0 =A0 =A0 =A0 =A0VNET(pfsy=
ncif)
> @@ -319,29 +265,15 @@ SYSCTL_VNET_STRUCT(_net_pfsync, OID_AUTO
> =A0 =A0 "PFSYNC statistics (struct pfsyncstats, net/if_pfsync.h)");
> =A0SYSCTL_INT(_net_pfsync, OID_AUTO, carp_demotion_factor, CTLFLAG_RW,
> =A0 =A0 &VNET_NAME(pfsync_carp_adj), 0, "pfsync's CARP demotion factor ad=
justment");
> -#else
> -struct pfsync_softc =A0 =A0*pfsyncif =3D NULL;
> -struct pfsyncstats =A0 =A0 =A0pfsyncstats;
> -#define =A0 =A0 =A0 =A0V_pfsyncstats =A0 =A0pfsyncstats
> -#endif
>
> =A0void =A0 pfsyncattach(int);
> -#ifdef __FreeBSD__
> =A0int =A0 =A0pfsync_clone_create(struct if_clone *, int, caddr_t);
> =A0void =A0 pfsync_clone_destroy(struct ifnet *);
> -#else
> -int =A0 =A0pfsync_clone_create(struct if_clone *, int);
> -int =A0 =A0pfsync_clone_destroy(struct ifnet *);
> -#endif
> =A0int =A0 =A0pfsync_alloc_scrub_memory(struct pfsync_state_peer *,
> =A0 =A0 =A0 =A0 =A0 =A0struct pf_state_peer *);
> =A0void =A0 pfsync_update_net_tdb(struct pfsync_tdb *);
> =A0int =A0 =A0pfsyncoutput(struct ifnet *, struct mbuf *, struct sockaddr=
 *,
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0 =A0 =A0struct route *);
> -#else
> - =A0 =A0 =A0 =A0 =A0 struct rtentry *);
> -#endif
> =A0int =A0 =A0pfsyncioctl(struct ifnet *, u_long, caddr_t);
> =A0void =A0 pfsyncstart(struct ifnet *);
>
> @@ -365,27 +297,13 @@ void =A0 =A0 =A0pfsync_bulk_status(u_int8_t);
> =A0void =A0 pfsync_bulk_update(void *);
> =A0void =A0 pfsync_bulk_fail(void *);
>
> -#ifdef __FreeBSD__
> -/* XXX: ugly */
> -#define =A0 =A0 =A0 =A0betoh64 =A0 =A0 =A0 =A0 (unsigned long long)be64t=
oh
> -#define =A0 =A0 =A0 =A0timeout_del =A0 =A0 callout_stop
> -#endif
> -
> =A0#define PFSYNC_MAX_BULKTRIES =A0 12
> -#ifndef __FreeBSD__
> -int =A0 =A0pfsync_sync_ok;
> -#endif
>
> -#ifdef __FreeBSD__
> =A0VNET_DEFINE(struct ifc_simple_data, pfsync_cloner_data);
> =A0VNET_DEFINE(struct if_clone, pfsync_cloner);
> =A0#define =A0 =A0 =A0 =A0V_pfsync_cloner_data =A0 =A0VNET(pfsync_cloner_=
data)
> =A0#define =A0 =A0 =A0 =A0V_pfsync_cloner =A0 =A0 =A0 =A0 VNET(pfsync_clo=
ner)
> =A0IFC_SIMPLE_DECLARE(pfsync, 1);
> -#else
> -struct if_clone =A0 =A0 =A0 =A0pfsync_cloner =3D
> - =A0 =A0IF_CLONE_INITIALIZER("pfsync", pfsync_clone_create, pfsync_clone=
_destroy);
> -#endif
>
> =A0void
> =A0pfsyncattach(int npfsync)
> @@ -393,11 +311,7 @@ pfsyncattach(int npfsync)
> =A0 =A0 =A0 =A0if_clone_attach(&pfsync_cloner);
> =A0}
> =A0int
> -#ifdef __FreeBSD__
> =A0pfsync_clone_create(struct if_clone *ifc, int unit, caddr_t param)
> -#else
> -pfsync_clone_create(struct if_clone *ifc, int unit)
> -#endif
> =A0{
> =A0 =A0 =A0 =A0struct pfsync_softc *sc;
> =A0 =A0 =A0 =A0struct ifnet *ifp;
> @@ -406,23 +320,14 @@ pfsync_clone_create(struct if_clone *ifc
> =A0 =A0 =A0 =A0if (unit !=3D 0)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (EINVAL);
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0sc =3D malloc(sizeof(struct pfsync_softc), M_PFSYNC, M_WAI=
TOK | M_ZERO);
> =A0 =A0 =A0 =A0sc->pfsync_sync_ok =3D 1;
> -#else
> - =A0 =A0 =A0 pfsync_sync_ok =3D 1;
> - =A0 =A0 =A0 sc =3D malloc(sizeof(*pfsyncif), M_DEVBUF, M_NOWAIT | M_ZER=
O);
> -#endif
>
> =A0 =A0 =A0 =A0for (q =3D 0; q < PFSYNC_S_COUNT; q++)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0TAILQ_INIT(&sc->sc_qs[q]);
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0sc->sc_pool =3D uma_zcreate("pfsync", PFSYNC_PLSIZE, NULL,=
 NULL, NULL,
> =A0 =A0 =A0 =A0 =A0 =A0NULL, UMA_ALIGN_PTR, 0);
> -#else
> - =A0 =A0 =A0 pool_init(&sc->sc_pool, PFSYNC_PLSIZE, 0, 0, 0, "pfsync", N=
ULL);
> -#endif
> =A0 =A0 =A0 =A0TAILQ_INIT(&sc->sc_upd_req_list);
> =A0 =A0 =A0 =A0TAILQ_INIT(&sc->sc_deferrals);
> =A0 =A0 =A0 =A0sc->sc_deferred =3D 0;
> @@ -432,14 +337,7 @@ pfsync_clone_create(struct if_clone *ifc
> =A0 =A0 =A0 =A0sc->sc_len =3D PFSYNC_MINPKT;
> =A0 =A0 =A0 =A0sc->sc_maxupdates =3D 128;
>
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 sc->sc_imo.imo_membership =3D (struct in_multi **)malloc(
> - =A0 =A0 =A0 =A0 =A0 (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M=
_IPMOPTS,
> - =A0 =A0 =A0 =A0 =A0 M_WAITOK | M_ZERO);
> - =A0 =A0 =A0 sc->sc_imo.imo_max_memberships =3D IP_MIN_MEMBERSHIPS;
> -#endif
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0ifp =3D sc->sc_ifp =3D if_alloc(IFT_PFSYNC);
> =A0 =A0 =A0 =A0if (ifp =3D=3D NULL) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0uma_zdestroy(sc->sc_pool);
> @@ -447,10 +345,6 @@ pfsync_clone_create(struct if_clone *ifc
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (ENOSPC);
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0if_initname(ifp, ifc->ifc_name, unit);
> -#else
> - =A0 =A0 =A0 ifp =3D &sc->sc_if;
> - =A0 =A0 =A0 snprintf(ifp->if_xname, sizeof ifp->if_xname, "pfsync%d", u=
nit);
> -#endif
> =A0 =A0 =A0 =A0ifp->if_softc =3D sc;
> =A0 =A0 =A0 =A0ifp->if_ioctl =3D pfsyncioctl;
> =A0 =A0 =A0 =A0ifp->if_output =3D pfsyncoutput;
> @@ -459,67 +353,33 @@ pfsync_clone_create(struct if_clone *ifc
> =A0 =A0 =A0 =A0ifp->if_snd.ifq_maxlen =3D ifqmaxlen;
> =A0 =A0 =A0 =A0ifp->if_hdrlen =3D sizeof(struct pfsync_header);
> =A0 =A0 =A0 =A0ifp->if_mtu =3D ETHERMTU;
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0callout_init(&sc->sc_tmo, CALLOUT_MPSAFE);
> =A0 =A0 =A0 =A0callout_init_mtx(&sc->sc_bulk_tmo, &pf_task_mtx, 0);
> =A0 =A0 =A0 =A0callout_init(&sc->sc_bulkfail_tmo, CALLOUT_MPSAFE);
> -#else
> - =A0 =A0 =A0 timeout_set(&sc->sc_tmo, pfsync_timeout, sc);
> - =A0 =A0 =A0 timeout_set(&sc->sc_bulk_tmo, pfsync_bulk_update, sc);
> - =A0 =A0 =A0 timeout_set(&sc->sc_bulkfail_tmo, pfsync_bulk_fail, sc);
> -#endif
>
> =A0 =A0 =A0 =A0if_attach(ifp);
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 if_alloc_sadl(ifp);
> -
> -#if NCARP > 0
> - =A0 =A0 =A0 if_addgroup(ifp, "carp");
> -#endif
> -#endif
>
> =A0#if NBPFILTER > 0
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0bpfattach(ifp, DLT_PFSYNC, PFSYNC_HDRLEN);
> -#else
> - =A0 =A0 =A0 bpfattach(&sc->sc_if.if_bpf, ifp, DLT_PFSYNC, PFSYNC_HDRLEN=
);
> -#endif
> =A0#endif
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0V_pfsyncif =3D sc;
> -#else
> - =A0 =A0 =A0 pfsyncif =3D sc;
> -#endif
>
> =A0 =A0 =A0 =A0return (0);
> =A0}
>
> -#ifdef __FreeBSD__
> =A0void
> -#else
> -int
> -#endif
> =A0pfsync_clone_destroy(struct ifnet *ifp)
> =A0{
> =A0 =A0 =A0 =A0struct pfsync_softc *sc =3D ifp->if_softc;
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0PF_LOCK();
> -#endif
> - =A0 =A0 =A0 timeout_del(&sc->sc_bulkfail_tmo);
> - =A0 =A0 =A0 timeout_del(&sc->sc_bulk_tmo);
> - =A0 =A0 =A0 timeout_del(&sc->sc_tmo);
> -#ifdef __FreeBSD__
> + =A0 =A0 =A0 callout_stop(&sc->sc_bulkfail_tmo);
> + =A0 =A0 =A0 callout_stop(&sc->sc_bulk_tmo);
> + =A0 =A0 =A0 callout_stop(&sc->sc_tmo);
> =A0 =A0 =A0 =A0PF_UNLOCK();
> =A0 =A0 =A0 =A0if (!sc->pfsync_sync_ok && carp_demote_adj_p)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(*carp_demote_adj_p)(-V_pfsync_carp_adj, "=
pfsync destroy");
> -#else
> -#if NCARP > 0
> - =A0 =A0 =A0 if (!pfsync_sync_ok)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 carp_group_demote_adj(&sc->sc_if, -1);
> -#endif
> -#endif
> =A0#if NBPFILTER > 0
> =A0 =A0 =A0 =A0bpfdetach(ifp);
> =A0#endif
> @@ -530,50 +390,25 @@ pfsync_clone_destroy(struct ifnet *ifp)
> =A0 =A0 =A0 =A0while (sc->sc_deferred > 0)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pfsync_undefer(TAILQ_FIRST(&sc->sc_deferra=
ls), 0);
>
> -#ifdef __FreeBSD__
> - =A0 =A0 =A0 UMA_DESTROY(sc->sc_pool);
> -#else
> - =A0 =A0 =A0 pool_destroy(&sc->sc_pool);
> -#endif
> -#ifdef __FreeBSD__
> + =A0 =A0 =A0 uma_zdestroy(sc->sc_pool);
> =A0 =A0 =A0 =A0if_free(ifp);
> =A0 =A0 =A0 =A0if (sc->sc_imo.imo_membership)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pfsync_multicast_cleanup(sc);
> =A0 =A0 =A0 =A0free(sc, M_PFSYNC);
> -#else
> - =A0 =A0 =A0 free(sc->sc_imo.imo_membership, M_IPMOPTS);
> - =A0 =A0 =A0 free(sc, M_DEVBUF);
> -#endif
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0V_pfsyncif =3D NULL;
> -#else
> - =A0 =A0 =A0 pfsyncif =3D NULL;
> -#endif
>
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 return (0);
> -#endif
> =A0}
>
> =A0struct mbuf *
> =A0pfsync_if_dequeue(struct ifnet *ifp)
> =A0{
> =A0 =A0 =A0 =A0struct mbuf *m;
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 int s;
> -#endif
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0IF_LOCK(&ifp->if_snd);
> =A0 =A0 =A0 =A0_IF_DROP(&ifp->if_snd);
> =A0 =A0 =A0 =A0_IF_DEQUEUE(&ifp->if_snd, m);
> =A0 =A0 =A0 =A0IF_UNLOCK(&ifp->if_snd);
> -#else
> - =A0 =A0 =A0 s =3D splnet();
> - =A0 =A0 =A0 IF_DEQUEUE(&ifp->if_snd, m);
> - =A0 =A0 =A0 splx(s);
> -#endif
>
> =A0 =A0 =A0 =A0return (m);
> =A0}
> @@ -587,9 +422,6 @@ pfsyncstart(struct ifnet *ifp)
> =A0 =A0 =A0 =A0struct mbuf *m;
>
> =A0 =A0 =A0 =A0while ((m =3D pfsync_if_dequeue(ifp)) !=3D NULL) {
> -#ifndef __FreeBSD__
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 IF_DROP(&ifp->if_snd);
> -#endif
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0m_freem(m);
> =A0 =A0 =A0 =A0}
> =A0}
> @@ -599,11 +431,7 @@ pfsync_alloc_scrub_memory(struct pfsync_
> =A0 =A0 struct pf_state_peer *d)
> =A0{
> =A0 =A0 =A0 =A0if (s->scrub.scrub_flag && d->scrub =3D=3D NULL) {
> -#ifdef __FreeBSD__
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 d->scrub =3D pool_get(&V_pf_state_scrub_pl,=
 PR_NOWAIT | PR_ZERO);
> -#else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 d->scrub =3D pool_get(&pf_state_scrub_pl, P=
R_NOWAIT | PR_ZERO);
> -#endif
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 d->scrub =3D uma_zalloc(V_pf_state_scrub_pl=
, M_NOWAIT | M_ZERO);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (d->scrub =3D=3D NULL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (ENOMEM);
> =A0 =A0 =A0 =A0}
> @@ -611,68 +439,6 @@ pfsync_alloc_scrub_memory(struct pfsync_
> =A0 =A0 =A0 =A0return (0);
> =A0}
>
> -#ifndef __FreeBSD__
> -void
> -pfsync_state_export(struct pfsync_state *sp, struct pf_state *st)
> -{
> - =A0 =A0 =A0 bzero(sp, sizeof(struct pfsync_state));
> -
> - =A0 =A0 =A0 /* copy from state key */
> - =A0 =A0 =A0 sp->key[PF_SK_WIRE].addr[0] =3D st->key[PF_SK_WIRE]->addr[0=
];
> - =A0 =A0 =A0 sp->key[PF_SK_WIRE].addr[1] =3D st->key[PF_SK_WIRE]->addr[1=
];
> - =A0 =A0 =A0 sp->key[PF_SK_WIRE].port[0] =3D st->key[PF_SK_WIRE]->port[0=
];
> - =A0 =A0 =A0 sp->key[PF_SK_WIRE].port[1] =3D st->key[PF_SK_WIRE]->port[1=
];
> - =A0 =A0 =A0 sp->key[PF_SK_STACK].addr[0] =3D st->key[PF_SK_STACK]->addr=
[0];
> - =A0 =A0 =A0 sp->key[PF_SK_STACK].addr[1] =3D st->key[PF_SK_STACK]->addr=
[1];
> - =A0 =A0 =A0 sp->key[PF_SK_STACK].port[0] =3D st->key[PF_SK_STACK]->port=
[0];
> - =A0 =A0 =A0 sp->key[PF_SK_STACK].port[1] =3D st->key[PF_SK_STACK]->port=
[1];
> - =A0 =A0 =A0 sp->proto =3D st->key[PF_SK_WIRE]->proto;
> - =A0 =A0 =A0 sp->af =3D st->key[PF_SK_WIRE]->af;
> -
> - =A0 =A0 =A0 /* copy from state */
> - =A0 =A0 =A0 strlcpy(sp->ifname, st->kif->pfik_name, sizeof(sp->ifname))=
;
> - =A0 =A0 =A0 bcopy(&st->rt_addr, &sp->rt_addr, sizeof(sp->rt_addr));
> - =A0 =A0 =A0 sp->creation =3D htonl(time_uptime - st->creation);
> - =A0 =A0 =A0 sp->expire =3D pf_state_expires(st);
> - =A0 =A0 =A0 if (sp->expire <=3D time_second)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->expire =3D htonl(0);
> - =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->expire =3D htonl(sp->expire - time_seco=
nd);
> -
> - =A0 =A0 =A0 sp->direction =3D st->direction;
> - =A0 =A0 =A0 sp->log =3D st->log;
> - =A0 =A0 =A0 sp->timeout =3D st->timeout;
> - =A0 =A0 =A0 sp->state_flags =3D st->state_flags;
> - =A0 =A0 =A0 if (st->src_node)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->sync_flags |=3D PFSYNC_FLAG_SRCNODE;
> - =A0 =A0 =A0 if (st->nat_src_node)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->sync_flags |=3D PFSYNC_FLAG_NATSRCNODE;
> -
> - =A0 =A0 =A0 bcopy(&st->id, &sp->id, sizeof(sp->id));
> - =A0 =A0 =A0 sp->creatorid =3D st->creatorid;
> - =A0 =A0 =A0 pf_state_peer_hton(&st->src, &sp->src);
> - =A0 =A0 =A0 pf_state_peer_hton(&st->dst, &sp->dst);
> -
> - =A0 =A0 =A0 if (st->rule.ptr =3D=3D NULL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->rule =3D htonl(-1);
> - =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->rule =3D htonl(st->rule.ptr->nr);
> - =A0 =A0 =A0 if (st->anchor.ptr =3D=3D NULL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->anchor =3D htonl(-1);
> - =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->anchor =3D htonl(st->anchor.ptr->nr);
> - =A0 =A0 =A0 if (st->nat_rule.ptr =3D=3D NULL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->nat_rule =3D htonl(-1);
> - =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 sp->nat_rule =3D htonl(st->nat_rule.ptr->nr=
);
> -
> - =A0 =A0 =A0 pf_state_counter_hton(st->packets[0], sp->packets[0]);
> - =A0 =A0 =A0 pf_state_counter_hton(st->packets[1], sp->packets[1]);
> - =A0 =A0 =A0 pf_state_counter_hton(st->bytes[0], sp->bytes[0]);
> - =A0 =A0 =A0 pf_state_counter_hton(st->bytes[1], sp->bytes[1]);
> -
> -}
> -#endif
>
> =A0int
> =A0pfsync_state_import(struct pfsync_state *sp, u_int8_t flags)
> @@ -684,24 +450,16 @@ pfsync_state_import(struct pfsync_state
> =A0 =A0 =A0 =A0int pool_flags;
> =A0 =A0 =A0 =A0int error;
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0PF_LOCK_ASSERT();
>
> =A0 =A0 =A0 =A0if (sp->creatorid =3D=3D 0 && V_pf_status.debug >=3D PF_DE=
BUG_MISC) {
> -#else
> - =A0 =A0 =A0 if (sp->creatorid =3D=3D 0 && pf_status.debug >=3D PF_DEBUG=
_MISC) {
> -#endif
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("pfsync_state_import: invalid creat=
or id:"
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0" %08x\n", ntohl(sp->creatorid));
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return (EINVAL);
> =A0 =A0 =A0 =A0}
>
> =A0 =A0 =A0 =A0if ((kif =3D pfi_kif_get(sp->ifname)) =3D=3D NULL) {
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (V_pf_status.debug >=3D PF_DEBUG_MISC)
> -#else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (pf_status.debug >=3D PF_DEBUG_MISC)
> -#endif
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0printf("pfsync_state_impor=
t: "
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"unknown interface=
: %s\n", sp->ifname);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (flags & PFSYNC_SI_IOCTL)
> @@ -719,32 +477,18 @@ pfsync_state_import(struct pfsync_state
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r =3D pf_main_ruleset.rules[
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0PF_RULESET_FILTER].active.ptr_arra=
y[ntohl(sp->rule)];
> =A0 =A0 =A0 =A0else
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0r =3D &V_pf_default_rule;
> -#else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 r =3D &pf_default_rule;
> -#endif
>
> =A0 =A0 =A0 =A0if ((r->max_states && r->states_cur >=3D r->max_states))
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto cleanup;
>
> -#ifdef __FreeBSD__
> - =A0 =A0 =A0 if (flags & PFSYNC_SI_IOCTL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_flags =3D PR_WAITOK | PR_ZERO;
> - =A0 =A0 =A0 else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_flags =3D PR_NOWAIT | PR_ZERO;
> -
> - =A0 =A0 =A0 if ((st =3D pool_get(&V_pf_state_pl, pool_flags)) =3D=3D NU=
LL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto cleanup;
> -#else
> =A0 =A0 =A0 =A0if (flags & PFSYNC_SI_IOCTL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_flags =3D PR_WAITOK | PR_LIMITFAIL | P=
R_ZERO;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_flags =3D M_WAITOK | M_ZERO;
> =A0 =A0 =A0 =A0else
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_flags =3D PR_LIMITFAIL | PR_ZERO;
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_flags =3D M_NOWAIT | M_ZERO;
>
> - =A0 =A0 =A0 if ((st =3D pool_get(&pf_state_pl, pool_flags)) =3D=3D NULL=
)
> + =A0 =A0 =A0 if ((st =3D uma_zalloc(V_pf_state_pl, pool_flags)) =3D=3D N=
ULL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto cleanup;
> -#endif
>
> =A0 =A0 =A0 =A0if ((skw =3D pf_alloc_state_key(pool_flags)) =3D=3D NULL)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto cleanup;
> @@ -837,49 +581,26 @@ cleanup:
> =A0 =A0 =A0 =A0error =3D ENOMEM;
> =A0 =A0 =A0 =A0if (skw =3D=3D sks)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0sks =3D NULL;
> -#ifdef __FreeBSD__
> - =A0 =A0 =A0 if (skw !=3D NULL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&V_pf_state_key_pl, skw);
> - =A0 =A0 =A0 if (sks !=3D NULL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&V_pf_state_key_pl, sks);
> -#else
> =A0 =A0 =A0 =A0if (skw !=3D NULL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&pf_state_key_pl, skw);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 uma_zfree(V_pf_state_key_pl, skw);
> =A0 =A0 =A0 =A0if (sks !=3D NULL)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&pf_state_key_pl, sks);
> -#endif
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 uma_zfree(V_pf_state_key_pl, sks);
>
> =A0cleanup_state: /* pf_state_insert frees the state keys */
> =A0 =A0 =A0 =A0if (st) {
> -#ifdef __FreeBSD__
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (st->dst.scrub)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&V_pf_state_scrub_=
pl, st->dst.scrub);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (st->src.scrub)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&V_pf_state_scrub_=
pl, st->src.scrub);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&V_pf_state_pl, st);
> -#else
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (st->dst.scrub)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&pf_state_scrub_pl=
, st->dst.scrub);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 uma_zfree(V_pf_state_scrub_=
pl, st->dst.scrub);
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (st->src.scrub)
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&pf_state_scrub_pl=
, st->src.scrub);
> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 pool_put(&pf_state_pl, st);
> -#endif
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 uma_zfree(V_pf_state_scrub_=
pl, st->src.scrub);
> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 uma_zfree(V_pf_state_pl, st);
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0return (error);
> =A0}
>
> =A0void
> -#ifdef __FreeBSD__
> =A0pfsync_input(struct mbuf *m, __unused int off)
> -#else
> -pfsync_input(struct mbuf *m, ...)
> -#endif
> =A0{
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0struct pfsync_softc *sc =3D V_pfsyncif;
> -#else
> - =A0 =A0 =A0 struct pfsync_softc *sc =3D pfsyncif;
> -#endif
> =A0 =A0 =A0 =A0struct pfsync_pkt pkt;
> =A0 =A0 =A0 =A0struct ip *ip =3D mtod(m, struct ip *);
> =A0 =A0 =A0 =A0struct pfsync_header *ph;
> @@ -891,11 +612,7 @@ pfsync_input(struct mbuf *m, ...)
> =A0 =A0 =A0 =A0V_pfsyncstats.pfsyncs_ipackets++;
>
> =A0 =A0 =A0 =A0/* verify that we have a sync interface configured */
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0if (!sc || !sc->sc_sync_if || !V_pf_status.running)
> -#else
> - =A0 =A0 =A0 if (!sc || !sc->sc_sync_if || !pf_status.running)
> -#endif
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto done;
>
> =A0 =A0 =A0 =A0/* verify that the packet came in on the right interface *=
/
> @@ -904,13 +621,8 @@ pfsync_input(struct mbuf *m, ...)
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0goto done;
> =A0 =A0 =A0 =A0}
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0sc->sc_ifp->if_ipackets++;
> =A0 =A0 =A0 =A0sc->sc_ifp->if_ibytes +=3D m->m_pkthdr.len;
> -#else
> - =A0 =A0 =A0 sc->sc_if.if_ipackets++;
> - =A0 =A0 =A0 sc->sc_if.if_ibytes +=3D m->m_pkthdr.len;
> -#endif
> =A0 =A0 =A0 =A0/* verify that the IP TTL is 255. */
> =A0 =A0 =A0 =A0if (ip->ip_ttl !=3D PFSYNC_DFLTTL) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0V_pfsyncstats.pfsyncs_badttl++;
> @@ -950,11 +662,7 @@ pfsync_input(struct mbuf *m, ...)
> =A0 =A0 =A0 =A0pkt.src =3D ip->ip_src;
> =A0 =A0 =A0 =A0pkt.flags =3D 0;
>
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0if (!bcmp(&ph->pfcksum, &V_pf_status.pf_chksum, PF_MD5_DIG=
EST_LENGTH))
> -#else
> - =A0 =A0 =A0 if (!bcmp(&ph->pfcksum, &pf_status.pf_chksum, PF_MD5_DIGEST=
_LENGTH))
> -#endif
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pkt.flags |=3D PFSYNC_SI_CKSUM;
>
> =A0 =A0 =A0 =A0offset +=3D sizeof(*ph);
> @@ -991,7 +699,6 @@ pfsync_in_clr(struct pfsync_pkt *pkt, st
> =A0 =A0 =A0 =A0struct pf_state_key *sk, *nextsk;
> =A0 =A0 =A0 =A0struct pf_state_item *si;
> =A0 =A0 =A0 =A0u_int32_t creatorid;
> - =A0 =A0 =A0 int s;
>
> =A0 =A0 =A0 =A0mp =3D m_pulldown(m, offset, len, &offp);
> =A0 =A0 =A0 =A0if (mp =3D=3D NULL) {
> @@ -1000,23 +707,14 @@ pfsync_in_clr(struct pfsync_pkt *pkt, st
> =A0 =A0 =A0 =A0}
> =A0 =A0 =A0 =A0clr =3D (struct pfsync_clr *)(mp->m_data + offp);
>
> - =A0 =A0 =A0 s =3D splsoftnet();
> -#ifdef __FreeBSD__
> =A0 =A0 =A0 =A0PF_LOCK();
> -#endif
> =A0 =A0 =A0 =A0for (i =3D 0; i < count; i++) {
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0creatorid =3D clr[i].creatorid;
>
>
> *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



--=20
Ermal



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPBZQG0w%2BkWMC5y3r6gVGs21QjMWj89QRgy829TEjHmTPCAZmw>