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>
index | next in thread | previous in thread | raw e-mail
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: > - Cleanup #ifdef. > - Remove spl(9) calls. > - Remove #defines that mask FreeBSD API: use uma(9) implicitly, > use correct malloc(9) flags, etc.. > - Minor cleanups. > > Only compile tested. > > Modified: > projects/pf/head/sys/contrib/pf/net/if_pflog.c > projects/pf/head/sys/contrib/pf/net/if_pflog.h > projects/pf/head/sys/contrib/pf/net/if_pflow.h > projects/pf/head/sys/contrib/pf/net/if_pfsync.c > projects/pf/head/sys/contrib/pf/net/if_pfsync.h > projects/pf/head/sys/contrib/pf/net/pf.c > projects/pf/head/sys/contrib/pf/net/pf_if.c > projects/pf/head/sys/contrib/pf/net/pf_ioctl.c > projects/pf/head/sys/contrib/pf/net/pf_lb.c > projects/pf/head/sys/contrib/pf/net/pf_norm.c > projects/pf/head/sys/contrib/pf/net/pf_osfp.c > projects/pf/head/sys/contrib/pf/net/pf_ruleset.c > projects/pf/head/sys/contrib/pf/net/pf_table.c > projects/pf/head/sys/contrib/pf/net/pfvar.h > > Modified: projects/pf/head/sys/contrib/pf/net/if_pflog.c > ============================================================================== > --- projects/pf/head/sys/contrib/pf/net/if_pflog.c Thu Feb 23 09:23:10 2012 (r232042) > +++ projects/pf/head/sys/contrib/pf/net/if_pflog.c Thu Feb 23 10:18:28 2012 (r232043) > @@ -33,7 +33,6 @@ > * PURPOSE. > */ > > -#ifdef __FreeBSD__ > #include "opt_inet.h" > #include "opt_inet6.h" > #include "opt_bpf.h" > @@ -54,30 +53,20 @@ __FBSDID("$FreeBSD$"); > #define NPFLOG 0 > #endif > > -#else /* ! __FreeBSD__ */ > -#include "bpfilter.h" > -#include "pflog.h" > -#endif /* __FreeBSD__ */ > > #include <sys/param.h> > #include <sys/systm.h> > #include <sys/mbuf.h> > #include <sys/proc.h> > #include <sys/socket.h> > -#ifdef __FreeBSD__ > #include <sys/kernel.h> > #include <sys/limits.h> > #include <sys/malloc.h> > #include <sys/module.h> > #include <sys/sockio.h> > -#else > -#include <sys/ioctl.h> > -#endif > > #include <net/if.h> > -#ifdef __FreeBSD__ > #include <net/if_clone.h> > -#endif > #include <net/if_types.h> > #include <net/route.h> > #include <net/bpf.h> > @@ -99,11 +88,9 @@ __FBSDID("$FreeBSD$"); > #include <net/pfvar.h> > #include <net/if_pflog.h> > > -#ifdef __FreeBSD__ > #ifdef INET > #include <machine/in_cksum.h> > #endif /* INET */ > -#endif /* __FreeBSD__ */ > > #define PFLOGMTU (32768 + MHLEN + MLEN) > > @@ -115,28 +102,14 @@ __FBSDID("$FreeBSD$"); > > void pflogattach(int); > int pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *, > -#ifdef __FreeBSD__ > struct route *); > -#else > - struct rtentry *); > -#endif > int pflogioctl(struct ifnet *, u_long, caddr_t); > void pflogstart(struct ifnet *); > -#ifdef __FreeBSD__ > static int pflog_clone_create(struct if_clone *, int, caddr_t); > static void pflog_clone_destroy(struct ifnet *); > -#else > -int pflog_clone_create(struct if_clone *, int); > -int pflog_clone_destroy(struct ifnet *); > -#endif > > LIST_HEAD(, pflog_softc) pflogif_list; > -#ifdef __FreeBSD__ > IFC_SIMPLE_DECLARE(pflog, 1); > -#else > -struct if_clone pflog_cloner = > - IF_CLONE_INITIALIZER("pflog", pflog_clone_create, pflog_clone_destroy); > -#endif > > struct ifnet *pflogifs[PFLOGIFS_MAX]; /* for fast access */ > > @@ -150,17 +123,11 @@ pflogattach(int npflog) > if_clone_attach(&pflog_cloner); > } > > -#ifdef __FreeBSD__ > static int > pflog_clone_create(struct if_clone *ifc, int unit, caddr_t param) > -#else > -int > -pflog_clone_create(struct if_clone *ifc, int unit) > -#endif > { > struct ifnet *ifp; > struct pflog_softc *pflogif; > - int s; > > if (unit >= PFLOGIFS_MAX) > return (EINVAL); > @@ -170,88 +137,50 @@ pflog_clone_create(struct if_clone *ifc, > return (ENOMEM); > > pflogif->sc_unit = unit; > -#ifdef __FreeBSD__ > ifp = pflogif->sc_ifp = if_alloc(IFT_PFLOG); > if (ifp == NULL) { > free(pflogif, M_DEVBUF); > return (ENOSPC); > } > if_initname(ifp, ifc->ifc_name, unit); > -#else > - ifp = &pflogif->sc_if; > - snprintf(ifp->if_xname, sizeof ifp->if_xname, "pflog%d", unit); > -#endif > ifp->if_softc = pflogif; > ifp->if_mtu = PFLOGMTU; > ifp->if_ioctl = pflogioctl; > ifp->if_output = pflogoutput; > ifp->if_start = pflogstart; > -#ifndef __FreeBSD__ > - ifp->if_type = IFT_PFLOG; > -#endif > ifp->if_snd.ifq_maxlen = ifqmaxlen; > ifp->if_hdrlen = PFLOG_HDRLEN; > if_attach(ifp); > -#ifndef __FreeBSD__ > - if_alloc_sadl(ifp); > -#endif > > #if NBPFILTER > 0 > -#ifdef __FreeBSD__ > bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN); > -#else > - bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN); > -#endif > #endif > > - s = splnet(); > -#ifdef __FreeBSD__ > /* XXX: Why pf(4) lock?! Better add a pflog lock?! */ > PF_LOCK(); > -#endif > LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list); > pflogifs[unit] = ifp; > -#ifdef __FreeBSD__ > PF_UNLOCK(); > -#endif > - splx(s); > > return (0); > } > > -#ifdef __FreeBSD__ > static void > pflog_clone_destroy(struct ifnet *ifp) > -#else > -int > -pflog_clone_destroy(struct ifnet *ifp) > -#endif > { > struct pflog_softc *pflogif = ifp->if_softc; > - int s; > > - s = splnet(); > -#ifdef __FreeBSD__ > PF_LOCK(); > -#endif > pflogifs[pflogif->sc_unit] = NULL; > LIST_REMOVE(pflogif, sc_list); > -#ifdef __FreeBSD__ > PF_UNLOCK(); > -#endif > - splx(s); > > #if NBPFILTER > 0 > bpfdetach(ifp); > #endif > if_detach(ifp); > -#ifdef __FreeBSD__ > if_free(ifp); > -#endif > free(pflogif, M_DEVBUF); > -#ifndef __FreeBSD__ > - return (0); > -#endif > } > > /* > @@ -261,22 +190,12 @@ void > pflogstart(struct ifnet *ifp) > { > struct mbuf *m; > -#ifndef __FreeBSD__ > - int s; > -#endif > > for (;;) { > -#ifdef __FreeBSD__ > IF_LOCK(&ifp->if_snd); > _IF_DROP(&ifp->if_snd); > _IF_DEQUEUE(&ifp->if_snd, m); > IF_UNLOCK(&ifp->if_snd); > -#else > - s = splnet(); > - IF_DROP(&ifp->if_snd); > - IF_DEQUEUE(&ifp->if_snd, m); > - splx(s); > -#endif > > if (m == NULL) > return; > @@ -287,11 +206,7 @@ pflogstart(struct ifnet *ifp) > > int > pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, > -#ifdef __FreeBSD__ > struct route *rt) > -#else > - struct rtentry *rt) > -#endif > { > m_freem(m); > return (0); > @@ -303,17 +218,10 @@ pflogioctl(struct ifnet *ifp, u_long cmd > { > switch (cmd) { > case SIOCSIFFLAGS: > -#ifdef __FreeBSD__ > if (ifp->if_flags & IFF_UP) > ifp->if_drv_flags |= IFF_DRV_RUNNING; > else > ifp->if_drv_flags &= ~IFF_DRV_RUNNING; > -#else > - if (ifp->if_flags & IFF_UP) > - ifp->if_flags |= IFF_RUNNING; > - else > - ifp->if_flags &= ~IFF_RUNNING; > -#endif > break; > default: > return (ENOTTY); > @@ -355,15 +263,11 @@ pflog_packet(struct pfi_kif *kif, struct > sizeof(hdr.ruleset)); > } > if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done) > -#ifdef __FreeBSD__ > /* > * XXX: This should not happen as we force an early lookup > * via debug.pfugidhack > */ > ; /* empty */ > -#else > - pd->lookup.done = pf_socket_lookup(dir, pd); > -#endif > if (pd->lookup.done > 0) { > hdr.uid = pd->lookup.uid; > hdr.pid = pd->lookup.pid; > @@ -387,18 +291,12 @@ pflog_packet(struct pfi_kif *kif, struct > > ifn->if_opackets++; > ifn->if_obytes += m->m_pkthdr.len; > -#ifdef __FreeBSD__ > BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m); > -#else > - bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m, > - BPF_DIRECTION_OUT); > -#endif > #endif > > return (0); > } > > -#ifdef __FreeBSD__ > static int > pflog_modevent(module_t mod, int type, void *data) > { > @@ -432,4 +330,3 @@ static moduledata_t pflog_mod = { "pflog > DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PSEUDO, SI_ORDER_ANY); > MODULE_VERSION(pflog, PFLOG_MODVER); > MODULE_DEPEND(pflog, pf, PF_MODVER, PF_MODVER, PF_MODVER); > -#endif /* __FreeBSD__ */ > > Modified: projects/pf/head/sys/contrib/pf/net/if_pflog.h > ============================================================================== > --- projects/pf/head/sys/contrib/pf/net/if_pflog.h Thu Feb 23 09:23:10 2012 (r232042) > +++ projects/pf/head/sys/contrib/pf/net/if_pflog.h Thu Feb 23 10:18:28 2012 (r232043) > @@ -30,11 +30,7 @@ > #define PFLOGIFS_MAX 16 > > struct pflog_softc { > -#ifdef __FreeBSD__ > struct ifnet *sc_ifp; /* the interface pointer */ > -#else > - struct ifnet sc_if; /* the interface */ > -#endif > int sc_unit; > LIST_ENTRY(pflog_softc) sc_list; > }; > @@ -74,28 +70,14 @@ struct old_pfloghdr { > #define OLD_PFLOG_HDRLEN sizeof(struct old_pfloghdr) > > #ifdef _KERNEL > -#ifdef __FreeBSD__ > struct pf_rule; > struct pf_ruleset; > struct pfi_kif; > struct pf_pdesc; > > -#if 0 > -typedef int pflog_packet_t(struct pfi_kif *, struct mbuf *, sa_family_t, > - u_int8_t, u_int8_t, struct pf_rule *, struct pf_rule *, > - struct pf_ruleset *, struct pf_pdesc *); > -extern pflog_packet_t *pflog_packet_ptr; > -#endif > #define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) do { \ > if (pflog_packet_ptr != NULL) \ > pflog_packet_ptr(i,a,b,c,d,e,f,g,h); \ > } while (0) > -#else /* ! __FreeBSD__ */ > -#if NPFLOG > 0 > -#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) pflog_packet(i,a,b,c,d,e,f,g,h) > -#else > -#define PFLOG_PACKET(i,x,a,b,c,d,e,f,g,h) ((void)0) > -#endif /* NPFLOG > 0 */ > -#endif > #endif /* _KERNEL */ > #endif /* _NET_IF_PFLOG_H_ */ > > Modified: projects/pf/head/sys/contrib/pf/net/if_pflow.h > ============================================================================== > --- projects/pf/head/sys/contrib/pf/net/if_pflow.h Thu Feb 23 09:23:10 2012 (r232042) > +++ projects/pf/head/sys/contrib/pf/net/if_pflow.h Thu Feb 23 10:18:28 2012 (r232043) > @@ -66,11 +66,7 @@ struct pflow_softc { > unsigned int sc_maxcount; > u_int64_t sc_gcounter; > struct ip_moptions sc_imo; > -#ifdef __FreeBSD__ > struct callout sc_tmo; > -#else > - struct timeout sc_tmo; > -#endif > struct in_addr sc_sender_ip; > u_int16_t sc_sender_port; > struct in_addr sc_receiver_ip; > > Modified: projects/pf/head/sys/contrib/pf/net/if_pfsync.c > ============================================================================== > --- projects/pf/head/sys/contrib/pf/net/if_pfsync.c Thu Feb 23 09:23:10 2012 (r232042) > +++ projects/pf/head/sys/contrib/pf/net/if_pfsync.c Thu Feb 23 10:18:28 2012 (r232043) > @@ -51,7 +51,6 @@ > * 1.170 - SIOCSIFMTU checks > */ > > -#ifdef __FreeBSD__ > #include "opt_inet.h" > #include "opt_inet6.h" > #include "opt_pf.h" > @@ -60,21 +59,17 @@ > __FBSDID("$FreeBSD$"); > > #define NBPFILTER 1 > -#endif /* __FreeBSD__ */ > > #include <sys/param.h> > #include <sys/kernel.h> > -#ifdef __FreeBSD__ > #include <sys/bus.h> > #include <sys/interrupt.h> > #include <sys/priv.h> > -#endif > #include <sys/proc.h> > #include <sys/systm.h> > #include <sys/time.h> > #include <sys/mbuf.h> > #include <sys/socket.h> > -#ifdef __FreeBSD__ > #include <sys/endian.h> > #include <sys/malloc.h> > #include <sys/module.h> > @@ -83,26 +78,15 @@ __FBSDID("$FreeBSD$"); > #include <sys/lock.h> > #include <sys/mutex.h> > #include <sys/protosw.h> > -#else > -#include <sys/ioctl.h> > -#include <sys/timeout.h> > -#endif > #include <sys/sysctl.h> > -#ifndef __FreeBSD__ > -#include <sys/pool.h> > -#endif > > #include <net/if.h> > -#ifdef __FreeBSD__ > #include <net/if_clone.h> > -#endif > #include <net/if_types.h> > #include <net/route.h> > #include <net/bpf.h> > #include <net/netisr.h> > -#ifdef __FreeBSD__ > #include <net/vnet.h> > -#endif > > #include <netinet/in.h> > #include <netinet/if_ether.h> > @@ -120,22 +104,11 @@ __FBSDID("$FreeBSD$"); > #include <netinet6/nd6.h> > #endif /* INET6 */ > > -#ifdef __FreeBSD__ > #include <netinet/ip_carp.h> > -#else > -#include "carp.h" > -#if NCARP > 0 > -#include <netinet/ip_carp.h> > -#endif > -#endif > > #include <net/pfvar.h> > #include <net/if_pfsync.h> > > -#ifndef __FreeBSD__ > -#include "bpfilter.h" > -#include "pfsync.h" > -#endif > > #define PFSYNC_MINPKT ( \ > sizeof(struct ip) + \ > @@ -217,11 +190,7 @@ struct pfsync_deferral { > TAILQ_ENTRY(pfsync_deferral) pd_entry; > struct pf_state *pd_st; > struct mbuf *pd_m; > -#ifdef __FreeBSD__ > struct callout pd_tmo; > -#else > - struct timeout pd_tmo; > -#endif > }; > TAILQ_HEAD(pfsync_deferrals, pfsync_deferral); > > @@ -233,26 +202,16 @@ int pfsync_out_tdb(struct tdb *, struct > #endif > > struct pfsync_softc { > -#ifdef __FreeBSD__ > struct ifnet *sc_ifp; > -#else > - struct ifnet sc_if; > -#endif > struct ifnet *sc_sync_if; > > -#ifdef __FreeBSD__ > uma_zone_t sc_pool; > -#else > - struct pool sc_pool; > -#endif > > struct ip_moptions sc_imo; > > struct in_addr sc_sync_peer; > u_int8_t sc_maxupdates; > -#ifdef __FreeBSD__ > int pfsync_sync_ok; > -#endif > > struct ip sc_template; > > @@ -269,31 +228,18 @@ struct pfsync_softc { > > u_int32_t sc_ureq_sent; > int sc_bulk_tries; > -#ifdef __FreeBSD__ > struct callout sc_bulkfail_tmo; > -#else > - struct timeout sc_bulkfail_tmo; > -#endif > > u_int32_t sc_ureq_received; > struct pf_state *sc_bulk_next; > struct pf_state *sc_bulk_last; > -#ifdef __FreeBSD__ > struct callout sc_bulk_tmo; > -#else > - struct timeout sc_bulk_tmo; > -#endif > > TAILQ_HEAD(, tdb) sc_tdb_q; > > -#ifdef __FreeBSD__ > struct callout sc_tmo; > -#else > - struct timeout sc_tmo; > -#endif > }; > > -#ifdef __FreeBSD__ > static MALLOC_DEFINE(M_PFSYNC, "pfsync", "pfsync data"); > static VNET_DEFINE(struct pfsync_softc *, pfsyncif) = NULL; > #define V_pfsyncif VNET(pfsyncif) > @@ -319,29 +265,15 @@ SYSCTL_VNET_STRUCT(_net_pfsync, OID_AUTO > "PFSYNC statistics (struct pfsyncstats, net/if_pfsync.h)"); > SYSCTL_INT(_net_pfsync, OID_AUTO, carp_demotion_factor, CTLFLAG_RW, > &VNET_NAME(pfsync_carp_adj), 0, "pfsync's CARP demotion factor adjustment"); > -#else > -struct pfsync_softc *pfsyncif = NULL; > -struct pfsyncstats pfsyncstats; > -#define V_pfsyncstats pfsyncstats > -#endif > > void pfsyncattach(int); > -#ifdef __FreeBSD__ > int pfsync_clone_create(struct if_clone *, int, caddr_t); > void pfsync_clone_destroy(struct ifnet *); > -#else > -int pfsync_clone_create(struct if_clone *, int); > -int pfsync_clone_destroy(struct ifnet *); > -#endif > int pfsync_alloc_scrub_memory(struct pfsync_state_peer *, > struct pf_state_peer *); > void pfsync_update_net_tdb(struct pfsync_tdb *); > int pfsyncoutput(struct ifnet *, struct mbuf *, struct sockaddr *, > -#ifdef __FreeBSD__ > struct route *); > -#else > - struct rtentry *); > -#endif > int pfsyncioctl(struct ifnet *, u_long, caddr_t); > void pfsyncstart(struct ifnet *); > > @@ -365,27 +297,13 @@ void pfsync_bulk_status(u_int8_t); > void pfsync_bulk_update(void *); > void pfsync_bulk_fail(void *); > > -#ifdef __FreeBSD__ > -/* XXX: ugly */ > -#define betoh64 (unsigned long long)be64toh > -#define timeout_del callout_stop > -#endif > - > #define PFSYNC_MAX_BULKTRIES 12 > -#ifndef __FreeBSD__ > -int pfsync_sync_ok; > -#endif > > -#ifdef __FreeBSD__ > VNET_DEFINE(struct ifc_simple_data, pfsync_cloner_data); > VNET_DEFINE(struct if_clone, pfsync_cloner); > #define V_pfsync_cloner_data VNET(pfsync_cloner_data) > #define V_pfsync_cloner VNET(pfsync_cloner) > IFC_SIMPLE_DECLARE(pfsync, 1); > -#else > -struct if_clone pfsync_cloner = > - IF_CLONE_INITIALIZER("pfsync", pfsync_clone_create, pfsync_clone_destroy); > -#endif > > void > pfsyncattach(int npfsync) > @@ -393,11 +311,7 @@ pfsyncattach(int npfsync) > if_clone_attach(&pfsync_cloner); > } > int > -#ifdef __FreeBSD__ > pfsync_clone_create(struct if_clone *ifc, int unit, caddr_t param) > -#else > -pfsync_clone_create(struct if_clone *ifc, int unit) > -#endif > { > struct pfsync_softc *sc; > struct ifnet *ifp; > @@ -406,23 +320,14 @@ pfsync_clone_create(struct if_clone *ifc > if (unit != 0) > return (EINVAL); > > -#ifdef __FreeBSD__ > sc = malloc(sizeof(struct pfsync_softc), M_PFSYNC, M_WAITOK | M_ZERO); > sc->pfsync_sync_ok = 1; > -#else > - pfsync_sync_ok = 1; > - sc = malloc(sizeof(*pfsyncif), M_DEVBUF, M_NOWAIT | M_ZERO); > -#endif > > for (q = 0; q < PFSYNC_S_COUNT; q++) > TAILQ_INIT(&sc->sc_qs[q]); > > -#ifdef __FreeBSD__ > sc->sc_pool = uma_zcreate("pfsync", PFSYNC_PLSIZE, NULL, NULL, NULL, > NULL, UMA_ALIGN_PTR, 0); > -#else > - pool_init(&sc->sc_pool, PFSYNC_PLSIZE, 0, 0, 0, "pfsync", NULL); > -#endif > TAILQ_INIT(&sc->sc_upd_req_list); > TAILQ_INIT(&sc->sc_deferrals); > sc->sc_deferred = 0; > @@ -432,14 +337,7 @@ pfsync_clone_create(struct if_clone *ifc > sc->sc_len = PFSYNC_MINPKT; > sc->sc_maxupdates = 128; > > -#ifndef __FreeBSD__ > - sc->sc_imo.imo_membership = (struct in_multi **)malloc( > - (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS, > - M_WAITOK | M_ZERO); > - sc->sc_imo.imo_max_memberships = IP_MIN_MEMBERSHIPS; > -#endif > > -#ifdef __FreeBSD__ > ifp = sc->sc_ifp = if_alloc(IFT_PFSYNC); > if (ifp == NULL) { > uma_zdestroy(sc->sc_pool); > @@ -447,10 +345,6 @@ pfsync_clone_create(struct if_clone *ifc > return (ENOSPC); > } > if_initname(ifp, ifc->ifc_name, unit); > -#else > - ifp = &sc->sc_if; > - snprintf(ifp->if_xname, sizeof ifp->if_xname, "pfsync%d", unit); > -#endif > ifp->if_softc = sc; > ifp->if_ioctl = pfsyncioctl; > ifp->if_output = pfsyncoutput; > @@ -459,67 +353,33 @@ pfsync_clone_create(struct if_clone *ifc > ifp->if_snd.ifq_maxlen = ifqmaxlen; > ifp->if_hdrlen = sizeof(struct pfsync_header); > ifp->if_mtu = ETHERMTU; > -#ifdef __FreeBSD__ > callout_init(&sc->sc_tmo, CALLOUT_MPSAFE); > callout_init_mtx(&sc->sc_bulk_tmo, &pf_task_mtx, 0); > callout_init(&sc->sc_bulkfail_tmo, CALLOUT_MPSAFE); > -#else > - timeout_set(&sc->sc_tmo, pfsync_timeout, sc); > - timeout_set(&sc->sc_bulk_tmo, pfsync_bulk_update, sc); > - timeout_set(&sc->sc_bulkfail_tmo, pfsync_bulk_fail, sc); > -#endif > > if_attach(ifp); > -#ifndef __FreeBSD__ > - if_alloc_sadl(ifp); > - > -#if NCARP > 0 > - if_addgroup(ifp, "carp"); > -#endif > -#endif > > #if NBPFILTER > 0 > -#ifdef __FreeBSD__ > bpfattach(ifp, DLT_PFSYNC, PFSYNC_HDRLEN); > -#else > - bpfattach(&sc->sc_if.if_bpf, ifp, DLT_PFSYNC, PFSYNC_HDRLEN); > -#endif > #endif > > -#ifdef __FreeBSD__ > V_pfsyncif = sc; > -#else > - pfsyncif = sc; > -#endif > > return (0); > } > > -#ifdef __FreeBSD__ > void > -#else > -int > -#endif > pfsync_clone_destroy(struct ifnet *ifp) > { > struct pfsync_softc *sc = ifp->if_softc; > > -#ifdef __FreeBSD__ > PF_LOCK(); > -#endif > - timeout_del(&sc->sc_bulkfail_tmo); > - timeout_del(&sc->sc_bulk_tmo); > - timeout_del(&sc->sc_tmo); > -#ifdef __FreeBSD__ > + callout_stop(&sc->sc_bulkfail_tmo); > + callout_stop(&sc->sc_bulk_tmo); > + callout_stop(&sc->sc_tmo); > PF_UNLOCK(); > if (!sc->pfsync_sync_ok && carp_demote_adj_p) > (*carp_demote_adj_p)(-V_pfsync_carp_adj, "pfsync destroy"); > -#else > -#if NCARP > 0 > - if (!pfsync_sync_ok) > - carp_group_demote_adj(&sc->sc_if, -1); > -#endif > -#endif > #if NBPFILTER > 0 > bpfdetach(ifp); > #endif > @@ -530,50 +390,25 @@ pfsync_clone_destroy(struct ifnet *ifp) > while (sc->sc_deferred > 0) > pfsync_undefer(TAILQ_FIRST(&sc->sc_deferrals), 0); > > -#ifdef __FreeBSD__ > - UMA_DESTROY(sc->sc_pool); > -#else > - pool_destroy(&sc->sc_pool); > -#endif > -#ifdef __FreeBSD__ > + uma_zdestroy(sc->sc_pool); > if_free(ifp); > if (sc->sc_imo.imo_membership) > pfsync_multicast_cleanup(sc); > free(sc, M_PFSYNC); > -#else > - free(sc->sc_imo.imo_membership, M_IPMOPTS); > - free(sc, M_DEVBUF); > -#endif > > -#ifdef __FreeBSD__ > V_pfsyncif = NULL; > -#else > - pfsyncif = NULL; > -#endif > > -#ifndef __FreeBSD__ > - return (0); > -#endif > } > > struct mbuf * > pfsync_if_dequeue(struct ifnet *ifp) > { > struct mbuf *m; > -#ifndef __FreeBSD__ > - int s; > -#endif > > -#ifdef __FreeBSD__ > IF_LOCK(&ifp->if_snd); > _IF_DROP(&ifp->if_snd); > _IF_DEQUEUE(&ifp->if_snd, m); > IF_UNLOCK(&ifp->if_snd); > -#else > - s = splnet(); > - IF_DEQUEUE(&ifp->if_snd, m); > - splx(s); > -#endif > > return (m); > } > @@ -587,9 +422,6 @@ pfsyncstart(struct ifnet *ifp) > struct mbuf *m; > > while ((m = pfsync_if_dequeue(ifp)) != NULL) { > -#ifndef __FreeBSD__ > - IF_DROP(&ifp->if_snd); > -#endif > m_freem(m); > } > } > @@ -599,11 +431,7 @@ pfsync_alloc_scrub_memory(struct pfsync_ > struct pf_state_peer *d) > { > if (s->scrub.scrub_flag && d->scrub == NULL) { > -#ifdef __FreeBSD__ > - d->scrub = pool_get(&V_pf_state_scrub_pl, PR_NOWAIT | PR_ZERO); > -#else > - d->scrub = pool_get(&pf_state_scrub_pl, PR_NOWAIT | PR_ZERO); > -#endif > + d->scrub = uma_zalloc(V_pf_state_scrub_pl, M_NOWAIT | M_ZERO); > if (d->scrub == NULL) > return (ENOMEM); > } > @@ -611,68 +439,6 @@ pfsync_alloc_scrub_memory(struct pfsync_ > return (0); > } > > -#ifndef __FreeBSD__ > -void > -pfsync_state_export(struct pfsync_state *sp, struct pf_state *st) > -{ > - bzero(sp, sizeof(struct pfsync_state)); > - > - /* copy from state key */ > - sp->key[PF_SK_WIRE].addr[0] = st->key[PF_SK_WIRE]->addr[0]; > - sp->key[PF_SK_WIRE].addr[1] = st->key[PF_SK_WIRE]->addr[1]; > - sp->key[PF_SK_WIRE].port[0] = st->key[PF_SK_WIRE]->port[0]; > - sp->key[PF_SK_WIRE].port[1] = st->key[PF_SK_WIRE]->port[1]; > - sp->key[PF_SK_STACK].addr[0] = st->key[PF_SK_STACK]->addr[0]; > - sp->key[PF_SK_STACK].addr[1] = st->key[PF_SK_STACK]->addr[1]; > - sp->key[PF_SK_STACK].port[0] = st->key[PF_SK_STACK]->port[0]; > - sp->key[PF_SK_STACK].port[1] = st->key[PF_SK_STACK]->port[1]; > - sp->proto = st->key[PF_SK_WIRE]->proto; > - sp->af = st->key[PF_SK_WIRE]->af; > - > - /* copy from state */ > - strlcpy(sp->ifname, st->kif->pfik_name, sizeof(sp->ifname)); > - bcopy(&st->rt_addr, &sp->rt_addr, sizeof(sp->rt_addr)); > - sp->creation = htonl(time_uptime - st->creation); > - sp->expire = pf_state_expires(st); > - if (sp->expire <= time_second) > - sp->expire = htonl(0); > - else > - sp->expire = htonl(sp->expire - time_second); > - > - sp->direction = st->direction; > - sp->log = st->log; > - sp->timeout = st->timeout; > - sp->state_flags = st->state_flags; > - if (st->src_node) > - sp->sync_flags |= PFSYNC_FLAG_SRCNODE; > - if (st->nat_src_node) > - sp->sync_flags |= PFSYNC_FLAG_NATSRCNODE; > - > - bcopy(&st->id, &sp->id, sizeof(sp->id)); > - sp->creatorid = st->creatorid; > - pf_state_peer_hton(&st->src, &sp->src); > - pf_state_peer_hton(&st->dst, &sp->dst); > - > - if (st->rule.ptr == NULL) > - sp->rule = htonl(-1); > - else > - sp->rule = htonl(st->rule.ptr->nr); > - if (st->anchor.ptr == NULL) > - sp->anchor = htonl(-1); > - else > - sp->anchor = htonl(st->anchor.ptr->nr); > - if (st->nat_rule.ptr == NULL) > - sp->nat_rule = htonl(-1); > - else > - sp->nat_rule = htonl(st->nat_rule.ptr->nr); > - > - pf_state_counter_hton(st->packets[0], sp->packets[0]); > - pf_state_counter_hton(st->packets[1], sp->packets[1]); > - pf_state_counter_hton(st->bytes[0], sp->bytes[0]); > - pf_state_counter_hton(st->bytes[1], sp->bytes[1]); > - > -} > -#endif > > int > pfsync_state_import(struct pfsync_state *sp, u_int8_t flags) > @@ -684,24 +450,16 @@ pfsync_state_import(struct pfsync_state > int pool_flags; > int error; > > -#ifdef __FreeBSD__ > PF_LOCK_ASSERT(); > > if (sp->creatorid == 0 && V_pf_status.debug >= PF_DEBUG_MISC) { > -#else > - if (sp->creatorid == 0 && pf_status.debug >= PF_DEBUG_MISC) { > -#endif > printf("pfsync_state_import: invalid creator id:" > " %08x\n", ntohl(sp->creatorid)); > return (EINVAL); > } > > if ((kif = pfi_kif_get(sp->ifname)) == NULL) { > -#ifdef __FreeBSD__ > if (V_pf_status.debug >= PF_DEBUG_MISC) > -#else > - if (pf_status.debug >= PF_DEBUG_MISC) > -#endif > printf("pfsync_state_import: " > "unknown interface: %s\n", sp->ifname); > if (flags & PFSYNC_SI_IOCTL) > @@ -719,32 +477,18 @@ pfsync_state_import(struct pfsync_state > r = pf_main_ruleset.rules[ > PF_RULESET_FILTER].active.ptr_array[ntohl(sp->rule)]; > else > -#ifdef __FreeBSD__ > r = &V_pf_default_rule; > -#else > - r = &pf_default_rule; > -#endif > > if ((r->max_states && r->states_cur >= r->max_states)) > goto cleanup; > > -#ifdef __FreeBSD__ > - if (flags & PFSYNC_SI_IOCTL) > - pool_flags = PR_WAITOK | PR_ZERO; > - else > - pool_flags = PR_NOWAIT | PR_ZERO; > - > - if ((st = pool_get(&V_pf_state_pl, pool_flags)) == NULL) > - goto cleanup; > -#else > if (flags & PFSYNC_SI_IOCTL) > - pool_flags = PR_WAITOK | PR_LIMITFAIL | PR_ZERO; > + pool_flags = M_WAITOK | M_ZERO; > else > - pool_flags = PR_LIMITFAIL | PR_ZERO; > + pool_flags = M_NOWAIT | M_ZERO; > > - if ((st = pool_get(&pf_state_pl, pool_flags)) == NULL) > + if ((st = uma_zalloc(V_pf_state_pl, pool_flags)) == NULL) > goto cleanup; > -#endif > > if ((skw = pf_alloc_state_key(pool_flags)) == NULL) > goto cleanup; > @@ -837,49 +581,26 @@ cleanup: > error = ENOMEM; > if (skw == sks) > sks = NULL; > -#ifdef __FreeBSD__ > - if (skw != NULL) > - pool_put(&V_pf_state_key_pl, skw); > - if (sks != NULL) > - pool_put(&V_pf_state_key_pl, sks); > -#else > if (skw != NULL) > - pool_put(&pf_state_key_pl, skw); > + uma_zfree(V_pf_state_key_pl, skw); > if (sks != NULL) > - pool_put(&pf_state_key_pl, sks); > -#endif > + uma_zfree(V_pf_state_key_pl, sks); > > cleanup_state: /* pf_state_insert frees the state keys */ > if (st) { > -#ifdef __FreeBSD__ > - if (st->dst.scrub) > - pool_put(&V_pf_state_scrub_pl, st->dst.scrub); > - if (st->src.scrub) > - pool_put(&V_pf_state_scrub_pl, st->src.scrub); > - pool_put(&V_pf_state_pl, st); > -#else > if (st->dst.scrub) > - pool_put(&pf_state_scrub_pl, st->dst.scrub); > + uma_zfree(V_pf_state_scrub_pl, st->dst.scrub); > if (st->src.scrub) > - pool_put(&pf_state_scrub_pl, st->src.scrub); > - pool_put(&pf_state_pl, st); > -#endif > + uma_zfree(V_pf_state_scrub_pl, st->src.scrub); > + uma_zfree(V_pf_state_pl, st); > } > return (error); > } > > void > -#ifdef __FreeBSD__ > pfsync_input(struct mbuf *m, __unused int off) > -#else > -pfsync_input(struct mbuf *m, ...) > -#endif > { > -#ifdef __FreeBSD__ > struct pfsync_softc *sc = V_pfsyncif; > -#else > - struct pfsync_softc *sc = pfsyncif; > -#endif > struct pfsync_pkt pkt; > struct ip *ip = mtod(m, struct ip *); > struct pfsync_header *ph; > @@ -891,11 +612,7 @@ pfsync_input(struct mbuf *m, ...) > V_pfsyncstats.pfsyncs_ipackets++; > > /* verify that we have a sync interface configured */ > -#ifdef __FreeBSD__ > if (!sc || !sc->sc_sync_if || !V_pf_status.running) > -#else > - if (!sc || !sc->sc_sync_if || !pf_status.running) > -#endif > goto done; > > /* verify that the packet came in on the right interface */ > @@ -904,13 +621,8 @@ pfsync_input(struct mbuf *m, ...) > goto done; > } > > -#ifdef __FreeBSD__ > sc->sc_ifp->if_ipackets++; > sc->sc_ifp->if_ibytes += m->m_pkthdr.len; > -#else > - sc->sc_if.if_ipackets++; > - sc->sc_if.if_ibytes += m->m_pkthdr.len; > -#endif > /* verify that the IP TTL is 255. */ > if (ip->ip_ttl != PFSYNC_DFLTTL) { > V_pfsyncstats.pfsyncs_badttl++; > @@ -950,11 +662,7 @@ pfsync_input(struct mbuf *m, ...) > pkt.src = ip->ip_src; > pkt.flags = 0; > > -#ifdef __FreeBSD__ > if (!bcmp(&ph->pfcksum, &V_pf_status.pf_chksum, PF_MD5_DIGEST_LENGTH)) > -#else > - if (!bcmp(&ph->pfcksum, &pf_status.pf_chksum, PF_MD5_DIGEST_LENGTH)) > -#endif > pkt.flags |= PFSYNC_SI_CKSUM; > > offset += sizeof(*ph); > @@ -991,7 +699,6 @@ pfsync_in_clr(struct pfsync_pkt *pkt, st > struct pf_state_key *sk, *nextsk; > struct pf_state_item *si; > u_int32_t creatorid; > - int s; > > mp = m_pulldown(m, offset, len, &offp); > if (mp == NULL) { > @@ -1000,23 +707,14 @@ pfsync_in_clr(struct pfsync_pkt *pkt, st > } > clr = (struct pfsync_clr *)(mp->m_data + offp); > > - s = splsoftnet(); > -#ifdef __FreeBSD__ > PF_LOCK(); > -#endif > for (i = 0; i < count; i++) { > creatorid = clr[i].creatorid; > > > *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** -- Ermalhelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPBZQG0w%2BkWMC5y3r6gVGs21QjMWj89QRgy829TEjHmTPCAZmw>
