Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jan 2012 19:24:59 +0100
From:      Robert Millan <rmh@freebsd.org>
To:        freebsd-pf@freebsd.org, mlaier@freebsd.org, bz@freebsd.org, glebius@freebsd.org, eri@freebsd.org
Cc:        Kostik Belousov <kostikbel@gmail.com>, Adrian Chadd <adrian@freebsd.org>
Subject:   [PATCH] GNU/kFreeBSD detection in PF
Message-ID:  <20120130182459.GA1096@thorin>

next in thread | raw e-mail | index | archive | help

--i0/AhcQY5QxfSsSZ
Content-Type: multipart/mixed; boundary="NzB8fVQJ5HfG6fxh"
Content-Disposition: inline


--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable


Hi,

Please consider attached patch (since it's so large you may find it
easier to read with grep "^[+-]") to fix detection of GNU/kFreeBSD in PF.

Note: since this code is part of FreeBSD, the __FreeBSD_kernel__ macro
may be relied on when <sys/param.h> has been included.  For simplicity,
this patch switches __FreeBSD__ to __FreeBSD_kernel__ for C files while
adding the #include <sys/param.h> if missing.

For header files, instead of adding a new #include I opted for checking
both macros, to avoid header pollution.

This patch fixes most (but not all) __FreeBSD__ checks and adds missing
#includes where appropiate, but doesn't change anything else.  Since the
patch is so big, I wanted to keep it as simple as possible.

--=20
Robert Millan

--NzB8fVQJ5HfG6fxh
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="pf.diff"
Content-Transfer-Encoding: quoted-printable

Index: contrib/pf/authpf/authpf.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
--- contrib/pf/authpf/authpf.c	(revision 230747)
+++ contrib/pf/authpf/authpf.c	(working copy)
@@ -19,6 +19,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/file.h>
 #include <sys/ioctl.h>
@@ -33,7 +34,7 @@
=20
 #include <err.h>
 #include <errno.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <inttypes.h>
 #endif
 #include <login_cap.h>
@@ -74,7 +75,7 @@
=20
 volatile sig_atomic_t	want_death;
 static void		need_death(int signo);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static __dead2 void	do_death(int);
 #else
 static __dead void	do_death(int);
@@ -932,7 +933,7 @@
 /*
  * function that removes our stuff when we go away.
  */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static __dead2 void
 #else
 static __dead void
Index: contrib/pf/libevent/kqueue.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
--- contrib/pf/libevent/kqueue.c	(revision 230747)
+++ contrib/pf/libevent/kqueue.c	(working copy)
@@ -30,6 +30,7 @@
 #include "config.h"
 #endif
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
@@ -48,7 +49,7 @@
 #include <inttypes.h>
 #endif
=20
-#if defined(HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBS=
D__)
+#if defined(HAVE_INTTYPES_H) && !defined(__OpenBSD__) && !defined(__FreeBS=
D_kernel__)
 #define INTPTR(x)	(intptr_t)x
 #else
 #define INTPTR(x)	x
Index: contrib/pf/pfctl/parse.y
=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
--- contrib/pf/pfctl/parse.y	(revision 230747)
+++ contrib/pf/pfctl/parse.y	(working copy)
@@ -30,6 +30,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
@@ -2223,7 +2224,7 @@
 				}
 				free($9.queues.pqname);
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			r.divert.port =3D $9.divert.port;
 #else
 			if ((r.divert.port =3D $9.divert.port)) {
@@ -2368,7 +2369,7 @@
 			filter_opts.rtableid =3D $2;
 		}
 		| DIVERTTO portplain {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			filter_opts.divert.port =3D $2.a;
 			if (!filter_opts.divert.port) {
 				yyerror("invalid divert port: %u", ntohs($2.a));
@@ -2377,7 +2378,7 @@
 #endif
 		}
 		| DIVERTTO STRING PORT portplain {
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 			if ((filter_opts.divert.addr =3D host($2)) =3D=3D NULL) {
 				yyerror("could not parse divert address: %s",
 				    $2);
@@ -2395,7 +2396,7 @@
 			}
 		}
 		| DIVERTREPLY {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			yyerror("divert-reply has no meaning in FreeBSD pf(4)");
 			YYERROR;
 #else
@@ -2861,7 +2862,7 @@
 			char	*buf;
=20
 			/* ie. for 10/8 parsing */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (asprintf(&buf, "%lld/%lld", (long long)$1, (long long)$3) =3D=3D -1)
 #else
 			if (asprintf(&buf, "%lld/%lld", $1, $3) =3D=3D -1)
Index: contrib/pf/pfctl/pf_print_state.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
--- contrib/pf/pfctl/pf_print_state.c	(revision 230747)
+++ contrib/pf/pfctl/pf_print_state.c	(working copy)
@@ -33,9 +33,10 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/endian.h>
 #define	betoh64	be64toh
 #endif
@@ -322,7 +323,7 @@
 		bcopy(s->bytes[0], &bytes[0], sizeof(u_int64_t));
 		bcopy(s->bytes[1], &bytes[1], sizeof(u_int64_t));
 		printf(", %llu:%llu pkts, %llu:%llu bytes",
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    (unsigned long long)betoh64(packets[0]),
 		    (unsigned long long)betoh64(packets[1]),
 		    (unsigned long long)betoh64(bytes[0]),
@@ -352,7 +353,7 @@
=20
 		bcopy(&s->id, &id, sizeof(u_int64_t));
 		printf("   id: %016llx creatorid: %08x",
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    (unsigned long long)betoh64(id), ntohl(s->creatorid));
 #else
 		    betoh64(id), ntohl(s->creatorid));
Index: contrib/pf/pfctl/pfctl_parser.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
--- contrib/pf/pfctl/pfctl_parser.c	(revision 230747)
+++ contrib/pf/pfctl/pfctl_parser.c	(working copy)
@@ -580,7 +580,7 @@
 		    s->src_nodes, "");
 		for (i =3D 0; i < SCNT_MAX; i++) {
 			printf("  %-25s %14lld ", pf_scounters[i],
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    (long long)s->scounters[i]);
 #else
 				    s->scounters[i]);
@@ -606,7 +606,7 @@
 		printf("Limit Counters\n");
 		for (i =3D 0; i < LCNT_MAX; i++) {
 			printf("  %-25s %14lld ", pf_lcounters[i],
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    (unsigned long long)s->lcounters[i]);
 #else
 				    s->lcounters[i]);
@@ -655,7 +655,7 @@
 			    sn->expire, min, sec);
 		}
 		printf(", %llu pkts, %llu bytes",
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    (unsigned long long)(sn->packets[0] + sn->packets[1]),
 		    (unsigned long long)(sn->bytes[0] + sn->bytes[1]));
 #else
@@ -1019,7 +1019,7 @@
 	if (r->rtableid !=3D -1)
 		printf(" rtable %u", r->rtableid);
 	if (r->divert.port) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		printf(" divert-to %u", ntohs(r->divert.port));
 #else
 		if (PF_AZERO(&r->divert.addr, r->af)) {
Index: contrib/pf/pfctl/pfctl_qstats.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
--- contrib/pf/pfctl/pfctl_qstats.c	(revision 230747)
+++ contrib/pf/pfctl/pfctl_qstats.c	(working copy)
@@ -19,6 +19,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -89,7 +90,7 @@
 	struct pf_altq_node	*root =3D NULL, *node;
 	int			 nodes, dotitle =3D (opts & PF_OPT_SHOWALL);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (!altqsupport)
 		return (-1);
 #endif
@@ -118,7 +119,7 @@
 		for (node =3D root; node !=3D NULL; node =3D node->next) {
 			if (iface !=3D NULL && strcmp(node->altq.ifname, iface))
 				continue;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (node->altq.local_flags & PFALTQ_FLAG_IF_REMOVED)
 				continue;
 #endif
@@ -161,7 +162,7 @@
 			warn("DIOCGETALTQ");
 			return (-1);
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pa.altq.qid > 0 &&
 		    !(pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED)) {
 #else
@@ -184,7 +185,7 @@
 				pfctl_insert_altq_node(root, pa.altq, qstats);
 			}
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		else if (pa.altq.local_flags & PFALTQ_FLAG_IF_REMOVED) {
 			memset(&qstats.data, 0, sizeof(qstats.data));
 			if ((node =3D pfctl_find_altq_node(*root, pa.altq.qname,
@@ -303,7 +304,7 @@
 	if (a->altq.qid =3D=3D 0)
 		return;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (a->altq.local_flags & PFALTQ_FLAG_IF_REMOVED)
 		return;
 #endif
Index: contrib/pf/pfctl/pfctl.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
--- contrib/pf/pfctl/pfctl.c	(revision 230747)
+++ contrib/pf/pfctl/pfctl.c	(working copy)
@@ -34,12 +34,13 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/stat.h>
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/endian.h>
 #endif
=20
@@ -251,7 +252,7 @@
 	if (ioctl(dev, DIOCSTART)) {
 		if (errno =3D=3D EEXIST)
 			errx(1, "pf already enabled");
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		else if (errno =3D=3D ESRCH)
 			errx(1, "pfil registeration failed");
 #endif
@@ -1585,7 +1586,7 @@
 	pf->limit[PF_LIMIT_TABLE_ENTRIES] =3D PFR_KENTRY_HIWAT;
=20
 	mib[0] =3D CTL_HW;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	mib[1] =3D HW_PHYSMEM;
 #else
 	mib[1] =3D HW_PHYSMEM64;
@@ -2202,7 +2203,7 @@
 		/* turn off options */
 		opts &=3D ~ (PF_OPT_DISABLE | PF_OPT_ENABLE);
 		clearopt =3D showopt =3D debugopt =3D NULL;
-#if defined(__FreeBSD__) && !defined(ENABLE_ALTQ)
+#if defined(__FreeBSD_kernel__) && !defined(ENABLE_ALTQ)
 		altqsupport =3D 0;
 #else
 		altqsupport =3D 1;
Index: contrib/pf/pfctl/pfctl_optimize.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
--- contrib/pf/pfctl/pfctl_optimize.c	(revision 230747)
+++ contrib/pf/pfctl/pfctl_optimize.c	(working copy)
@@ -19,6 +19,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -862,7 +863,7 @@
 				break;
 			}
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (por2 =3D=3D NULL)
 #else
 		if (por2 =3D=3D TAILQ_END(&block->sb_rules))
Index: contrib/pf/pfctl/pfctl_altq.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
--- contrib/pf/pfctl/pfctl_altq.c	(revision 230747)
+++ contrib/pf/pfctl/pfctl_altq.c	(working copy)
@@ -21,6 +21,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
@@ -77,7 +78,7 @@
 			     double);
 static double		 sc_x2y(struct service_curve *, double);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 u_int32_t	getifspeed(int, char *);
 #else
 u_int32_t	 getifspeed(char *);
@@ -153,7 +154,7 @@
 		return;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (a->local_flags & PFALTQ_FLAG_IF_REMOVED)
 		printf("INACTIVE ");
 #endif
@@ -193,7 +194,7 @@
 {
 	unsigned int	i;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (a->local_flags & PFALTQ_FLAG_IF_REMOVED)
 		printf("INACTIVE ");
 #endif
@@ -239,7 +240,7 @@
 	if (bw->bw_absolute > 0)
 		pa->ifbandwidth =3D bw->bw_absolute;
 	else
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((rate =3D getifspeed(pf->dev, pa->ifname)) =3D=3D 0) {
 #else
 		if ((rate =3D getifspeed(pa->ifname)) =3D=3D 0) {
@@ -1095,7 +1096,7 @@
 	return (buf);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 /*
  * XXX
  * FreeBSD does not have SIOCGIFDATA.
@@ -1150,7 +1151,7 @@
 	    sizeof(ifr.ifr_name))
 		errx(1, "getifmtu: strlcpy");
 	if (ioctl(s, SIOCGIFMTU, (caddr_t)&ifr) =3D=3D -1)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		ifr.ifr_mtu =3D 1500;
 #else
 		err(1, "SIOCGIFMTU");
Index: contrib/pf/pfctl/pfctl_parser.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
--- contrib/pf/pfctl/pfctl_parser.h	(revision 230747)
+++ contrib/pf/pfctl/pfctl_parser.h	(working copy)
@@ -159,7 +159,7 @@
 	}			 data;
 };
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 /*
  * XXX
  * Absolutely this is not correct location to define this.
Index: contrib/pf/pfctl/pfctl.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
--- contrib/pf/pfctl/pfctl.h	(revision 230747)
+++ contrib/pf/pfctl/pfctl.h	(working copy)
@@ -86,7 +86,7 @@
 int	 pfctl_show_ifaces(const char *, int);
 FILE	*pfctl_fopen(const char *, const char *);
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 extern int altqsupport;
 extern int dummynetsupport;
 #define	HTONL(x)		(x) =3D htonl((__uint32_t)(x))
Index: contrib/pf/pflogd/privsep.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
--- contrib/pf/pflogd/privsep.c	(revision 230747)
+++ contrib/pf/pflogd/privsep.c	(working copy)
@@ -20,6 +20,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/socket.h>
@@ -73,7 +74,7 @@
 	int snaplen, ret, olderrno;
 	struct passwd *pw;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	for (i =3D 1; i < NSIG; i++)
 #else
 	for (i =3D 1; i < _NSIG; i++)
Index: contrib/pf/pflogd/pflogd.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
--- contrib/pf/pflogd/pflogd.c	(revision 230747)
+++ contrib/pf/pflogd/pflogd.c	(working copy)
@@ -33,6 +33,7 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
 #include <sys/file.h>
@@ -51,7 +52,7 @@
 #include <errno.h>
 #include <stdarg.h>
 #include <fcntl.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <ifaddrs.h>
 #include "pidfile.h"
 #else
@@ -161,7 +162,7 @@
 	va_end(ap);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 __dead2 void
 #else
 __dead void
@@ -215,7 +216,7 @@
 int
 if_exists(char *ifname)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct ifaddrs *ifdata, *mb;
 	int exists =3D 0;
=20
@@ -406,7 +407,7 @@
 scan_dump(FILE *fp, off_t size)
 {
 	struct pcap_file_header hdr;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pcap_sf_pkthdr ph;
 #else
 	struct pcap_pkthdr ph;
@@ -479,7 +480,7 @@
 dump_packet_nobuf(u_char *user, const struct pcap_pkthdr *h, const u_char =
*sp)
 {
 	FILE *f =3D (FILE *)user;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pcap_sf_pkthdr sh;
 #endif
=20
@@ -488,7 +489,7 @@
 		return;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	sh.ts.tv_sec =3D (bpf_int32)h->ts.tv_sec;
 	sh.ts.tv_usec =3D (bpf_int32)h->ts.tv_usec;
 	sh.caplen =3D h->caplen;
@@ -501,7 +502,7 @@
 		off_t pos =3D ftello(f);
=20
 		/* try to undo header to prevent corruption */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pos < sizeof(sh) ||
 		    ftruncate(fileno(f), pos - sizeof(sh))) {
 #else
@@ -576,7 +577,7 @@
 dump_packet(u_char *user, const struct pcap_pkthdr *h, const u_char *sp)
 {
 	FILE *f =3D (FILE *)user;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pcap_sf_pkthdr sh;
 	size_t len =3D sizeof(sh) + h->caplen;
 #else
@@ -609,7 +610,7 @@
 	}
=20
  append:      =20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	sh.ts.tv_sec =3D (bpf_int32)h->ts.tv_sec;
 	sh.ts.tv_usec =3D (bpf_int32)h->ts.tv_usec;
 	sh.caplen =3D h->caplen;
Index: contrib/pf/pflogd/pidfile.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
--- contrib/pf/pflogd/pidfile.c	(revision 230747)
+++ contrib/pf/pflogd/pidfile.c	(working copy)
@@ -48,7 +48,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include "pidfile.h"
 #else
 #include <util.h>
Index: contrib/pf/tftp-proxy/filter.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
--- contrib/pf/tftp-proxy/filter.c	(revision 230747)
+++ contrib/pf/tftp-proxy/filter.c	(working copy)
@@ -20,6 +20,7 @@
 #include <syslog.h>
=20
 #include <sys/ioctl.h>
+#include <sys/param.h>
 #include <sys/types.h>
 #include <sys/socket.h>
=20
@@ -298,7 +299,7 @@
 		pfr.rule.quick =3D 1;
 		pfr.rule.log =3D rule_log;
 		pfr.rule.keep_state =3D 1;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pfr.rule.flags =3D (proto =3D=3D IPPROTO_TCP ? TH_SYN : 0);
 		pfr.rule.flagset =3D (proto =3D=3D IPPROTO_TCP ?
 		    (TH_SYN|TH_ACK|TH_FIN|TH_RST) : 0);
Index: sys/contrib/pf/net/pf_ioctl.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
--- sys/contrib/pf/net/pf_ioctl.c	(revision 230747)
+++ sys/contrib/pf/net/pf_ioctl.c	(working copy)
@@ -35,7 +35,9 @@
  *
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
=20
@@ -57,7 +59,6 @@
 #include "pflog.h"
 #endif /* __FreeBSD__ */
=20
-#include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
 #include <sys/filio.h>
@@ -66,7 +67,7 @@
 #include <sys/socketvar.h>
 #include <sys/kernel.h>
 #include <sys/time.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/ucred.h>
 #include <sys/jail.h>
 #include <sys/module.h>
@@ -80,14 +81,14 @@
 #include <sys/proc.h>
 #include <sys/malloc.h>
 #include <sys/kthread.h>
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <sys/rwlock.h>
 #include <uvm/uvm_extern.h>
 #endif
=20
 #include <net/if.h>
 #include <net/if_types.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <net/vnet.h>
 #endif
 #include <net/route.h>
@@ -99,7 +100,7 @@
 #include <netinet/ip_var.h>
 #include <netinet/ip_icmp.h>
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/md5.h>
 #else
 #include <dev/rndvar.h>
@@ -122,14 +123,14 @@
 #include <altq/altq.h>
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/limits.h>
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <net/pfil.h>
 #endif /* __FreeBSD__ */
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void			 init_zone_var(void);
 void			 cleanup_pf_zone(void);
 int			 pfattach(void);
@@ -144,7 +145,7 @@
=20
 void			 pf_mv_pool(struct pf_palist *, struct pf_palist *);
 void			 pf_empty_pool(struct pf_palist *);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 int			 pfioctl(struct cdev *, u_long, caddr_t, int, struct thread *);
 #else
 int			 pfioctl(dev_t, u_long, caddr_t, int, struct proc *);
@@ -168,7 +169,7 @@
=20
 #define	TAGID_MAX	 50000
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 VNET_DEFINE(struct pf_rule,	 pf_default_rule);
 VNET_DEFINE(struct sx,		 pf_consistency_lock);
=20
@@ -206,13 +207,13 @@
 void			 pf_rtlabel_remove(struct pf_addr_wrap *);
 void			 pf_rtlabel_copyout(struct pf_addr_wrap *);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define DPFPRINTF(n, x) if (V_pf_status.debug >=3D (n)) printf x
 #else
 #define DPFPRINTF(n, x) if (pf_status.debug >=3D (n)) printf x
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 struct cdev *pf_dev;
 =20
 /*
@@ -597,7 +598,7 @@
 		pf_tbladdr_remove(&empty_pool_pa->addr);
 		pfi_kif_unref(empty_pool_pa->kif, PFI_KIF_REF_RULE);
 		TAILQ_REMOVE(poola, empty_pool_pa, entries);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_pooladdr_pl, empty_pool_pa);
 #else
 		pool_put(&pf_pooladdr_pl, empty_pool_pa);
@@ -648,7 +649,7 @@
 	pfi_kif_unref(rule->kif, PFI_KIF_REF_RULE);
 	pf_anchor_remove(rule);
 	pf_empty_pool(&rule->rpool.list);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pool_put(&V_pf_rule_pl, rule);
 #else
 	pool_put(&pf_rule_pl, rule);
@@ -733,7 +734,7 @@
 u_int16_t
 pf_tagname2tag(char *tagname)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	return (tagname2tag(&V_pf_tags, tagname));
 #else
 	return (tagname2tag(&pf_tags, tagname));
@@ -743,7 +744,7 @@
 void
 pf_tag2tagname(u_int16_t tagid, char *p)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	tag2tagname(&V_pf_tags, tagid, p);
 #else
 	tag2tagname(&pf_tags, tagid, p);
@@ -755,7 +756,7 @@
 {
 	struct pf_tagname *t;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	TAILQ_FOREACH(t, &V_pf_tags, entries)
 #else
 	TAILQ_FOREACH(t, &pf_tags, entries)
@@ -769,7 +770,7 @@
 void
 pf_tag_unref(u_int16_t tag)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	tag_unref(&V_pf_tags, tag);
 #else
 	tag_unref(&pf_tags, tag);
@@ -779,7 +780,7 @@
 int
 pf_rtlabel_add(struct pf_addr_wrap *a)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX_IMPORT: later */
 	return (0);
 #else
@@ -793,7 +794,7 @@
 void
 pf_rtlabel_remove(struct pf_addr_wrap *a)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX_IMPORT: later */
 #else
 	if (a->type =3D=3D PF_ADDR_RTLABEL)
@@ -804,7 +805,7 @@
 void
 pf_rtlabel_copyout(struct pf_addr_wrap *a)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX_IMPORT: later */
 	if (a->type =3D=3D PF_ADDR_RTLABEL && a->v.rtlabel)
 		strlcpy(a->v.rtlabelname, "?", sizeof(a->v.rtlabelname));
@@ -826,7 +827,7 @@
 u_int32_t
 pf_qname2qid(char *qname)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	return ((u_int32_t)tagname2tag(&V_pf_qids, qname));
 #else
 	return ((u_int32_t)tagname2tag(&pf_qids, qname));
@@ -836,7 +837,7 @@
 void
 pf_qid2qname(u_int32_t qid, char *p)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	tag2tagname(&V_pf_qids, (u_int16_t)qid, p);
 #else
 	tag2tagname(&pf_qids, (u_int16_t)qid, p);
@@ -846,7 +847,7 @@
 void
 pf_qid_unref(u_int32_t qid)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	tag_unref(&V_pf_qids, (u_int16_t)qid);
 #else
 	tag_unref(&pf_qids, (u_int16_t)qid);
@@ -860,7 +861,7 @@
 	int		 error =3D 0;
=20
 	/* Purge the old altq list */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	while ((altq =3D TAILQ_FIRST(V_pf_altqs_inactive)) !=3D NULL) {
 		TAILQ_REMOVE(V_pf_altqs_inactive, altq, entries);
 		if (altq->qname[0] =3D=3D 0 &&
@@ -874,7 +875,7 @@
 			error =3D altq_remove(altq);
 		} else
 			pf_qid_unref(altq->qid);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_altq_pl, altq);
 #else
 		pool_put(&pf_altq_pl, altq);
@@ -882,7 +883,7 @@
 	}
 	if (error)
 		return (error);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	*ticket =3D ++V_ticket_altqs_inactive;
 	V_altqs_inactive_open =3D 1;
 #else
@@ -898,7 +899,7 @@
 	struct pf_altq	*altq;
 	int		 error =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (!V_altqs_inactive_open || ticket !=3D V_ticket_altqs_inactive)
 		return (0);
 	/* Purge the old altq list */
@@ -918,13 +919,13 @@
 			error =3D altq_remove(altq);
 		} else
 			pf_qid_unref(altq->qid);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_altq_pl, altq);
 #else
 		pool_put(&pf_altq_pl, altq);
 #endif
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_altqs_inactive_open =3D 0;
 #else
 	altqs_inactive_open =3D 0;
@@ -939,7 +940,7 @@
 	struct pf_altq		*altq;
 	int			 s, err, error =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (!V_altqs_inactive_open || ticket !=3D V_ticket_altqs_inactive)
 #else
 	if (!altqs_inactive_open || ticket !=3D ticket_altqs_inactive)
@@ -948,7 +949,7 @@
=20
 	/* swap altqs, keep the old. */
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	old_altqs =3D V_pf_altqs_active;
 	V_pf_altqs_active =3D V_pf_altqs_inactive;
 	V_pf_altqs_inactive =3D old_altqs;
@@ -961,7 +962,7 @@
 #endif
=20
 	/* Attach new disciplines */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	TAILQ_FOREACH(altq, V_pf_altqs_active, entries) {
 	if (altq->qname[0] =3D=3D 0 &&
 	   (altq->local_flags & PFALTQ_FLAG_IF_REMOVED) =3D=3D 0) {
@@ -971,7 +972,7 @@
 #endif
 			/* attach the discipline */
 			error =3D altq_pfattach(altq);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (error =3D=3D 0 && V_pf_altq_running)
 #else
 			if (error =3D=3D 0 && pf_altq_running)
@@ -985,7 +986,7 @@
 	}
=20
 	/* Purge the old altq list */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	while ((altq =3D TAILQ_FIRST(V_pf_altqs_inactive)) !=3D NULL) {
 		TAILQ_REMOVE(V_pf_altqs_inactive, altq, entries);
 		if (altq->qname[0] =3D=3D 0 &&
@@ -996,7 +997,7 @@
 		if (altq->qname[0] =3D=3D 0) {
 #endif
 			/* detach and destroy the discipline */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_altq_running)
 #else
 			if (pf_altq_running)
@@ -1010,7 +1011,7 @@
 				error =3D err;
 		} else
 			pf_qid_unref(altq->qid);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_altq_pl, altq);
 #else
 		pool_put(&pf_altq_pl, altq);
@@ -1018,7 +1019,7 @@
 	}
 	splx(s);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_altqs_inactive_open =3D 0;
 #else
 	altqs_inactive_open =3D 0;
@@ -1044,11 +1045,11 @@
 		tb.rate =3D altq->ifbandwidth;
 		tb.depth =3D altq->tbrsize;
 		s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		error =3D tbr_set(&ifp->if_snd, &tb);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		splx(s);
@@ -1080,11 +1081,11 @@
 		/* clear tokenbucket regulator */
 		tb.rate =3D 0;
 		s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		error =3D tbr_set(&ifp->if_snd, &tb);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		splx(s);
@@ -1093,7 +1094,7 @@
 	return (error);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void
 pf_altq_ifnet_event(struct ifnet *ifp, int remove)
 {
@@ -1103,7 +1104,7 @@
 	int		 error =3D 0;
=20
 	/* Interrupt userland queue modifications */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (V_altqs_inactive_open)
 		pf_rollback_altq(V_ticket_altqs_inactive);
 #else
@@ -1116,7 +1117,7 @@
 		return;
=20
 	/* Copy the current active set */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	TAILQ_FOREACH(a1, V_pf_altqs_active, entries) {
 		a2 =3D pool_get(&V_pf_altq_pl, PR_NOWAIT);
 #else
@@ -1132,7 +1133,7 @@
 		if (a2->qname[0] !=3D 0) {
 			if ((a2->qid =3D pf_qname2qid(a2->qname)) =3D=3D 0) {
 				error =3D EBUSY;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_altq_pl, a2);
 #else
 				pool_put(&pf_altq_pl, a2);
@@ -1140,7 +1141,7 @@
 				break;
 			}
 			a2->altq_disc =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			TAILQ_FOREACH(a3, V_pf_altqs_inactive, entries) {
 #else
 			TAILQ_FOREACH(a3, pf_altqs_inactive, entries) {
@@ -1162,7 +1163,7 @@
 			error =3D altq_add(a2);
 			PF_LOCK();
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (ticket !=3D V_ticket_altqs_inactive)
 #else
 			if (ticket !=3D ticket_altqs_inactive)
@@ -1170,7 +1171,7 @@
 				error =3D EBUSY;
=20
 			if (error) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_altq_pl, a2);
 #else
 				pool_put(&pf_altq_pl, a2);
@@ -1179,7 +1180,7 @@
 			}
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		TAILQ_INSERT_TAIL(V_pf_altqs_inactive, a2, entries);
 #else
 		TAILQ_INSERT_TAIL(pf_altqs_inactive, a2, entries);
@@ -1410,7 +1411,7 @@
 	}
=20
 	MD5Final(digest, &ctx);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	memcpy(V_pf_status.pf_chksum, digest, sizeof(V_pf_status.pf_chksum));
 #else
 	memcpy(pf_status.pf_chksum, digest, sizeof(pf_status.pf_chksum));
@@ -1438,7 +1439,7 @@
 }
=20
 int
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pfioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flags, struct thre=
ad *td)
 #else
 pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
@@ -1446,7 +1447,7 @@
 {
 	struct pf_pooladdr	*pa =3D NULL;
 	struct pf_pool		*pool =3D NULL;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	int			 s;
 #endif
 	int			 error =3D 0;
@@ -1454,7 +1455,7 @@
 	CURVNET_SET(TD_TO_VNET(td));
=20
 	/* XXX keep in sync with switch() below */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (securelevel_gt(td->td_ucred, 2))
 #else
 	if (securelevel > 1)
@@ -1494,7 +1495,7 @@
 		case DIOCGETSRCNODES:
 		case DIOCCLRSRCNODES:
 		case DIOCIGETIFACES:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		case DIOCGIFSPEED:
 #endif
 		case DIOCSETIFFLAG:
@@ -1536,7 +1537,7 @@
 		case DIOCOSFPGET:
 		case DIOCGETSRCNODES:
 		case DIOCIGETIFACES:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		case DIOCGIFSPEED:
 #endif
 			break;
@@ -1565,7 +1566,7 @@
 		}
=20
 	if (flags & FWRITE)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		sx_xlock(&V_pf_consistency_lock);
 	else
 		sx_slock(&V_pf_consistency_lock);
@@ -1575,7 +1576,7 @@
 		rw_enter_read(&pf_consistency_lock);
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #else
 	s =3D splsoftnet();
@@ -1583,14 +1584,14 @@
 	switch (cmd) {
=20
 	case DIOCSTART:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.running)
 #else
 		if (pf_status.running)
 #endif
 			error =3D EEXIST;
 		else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_UNLOCK();
 			error =3D hook_pf();
 			PF_LOCK();
@@ -1620,7 +1621,7 @@
 		break;
=20
 	case DIOCSTOP:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (!V_pf_status.running)
 			error =3D ENOENT;
 		else {
@@ -1668,7 +1669,7 @@
 			break;
 		}
 		if (pr->ticket !=3D ruleset->rules[rs_num].inactive.ticket) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			DPFPRINTF(PF_DEBUG_MISC,
 			    ("ticket: %d !=3D [%d]%d\n", pr->ticket, rs_num,
 			    ruleset->rules[rs_num].inactive.ticket));
@@ -1676,7 +1677,7 @@
 			error =3D EBUSY;
 			break;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pr->pool_ticket !=3D V_ticket_pabuf) {
 			DPFPRINTF(PF_DEBUG_MISC,
 			    ("pool_ticket: %d !=3D %d\n", pr->pool_ticket,
@@ -1687,7 +1688,7 @@
 			error =3D EBUSY;
 			break;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rule =3D pool_get(&V_pf_rule_pl, PR_NOWAIT);
 #else
 		rule =3D pool_get(&pf_rule_pl, PR_WAITOK|PR_LIMITFAIL);
@@ -1697,7 +1698,7 @@
 			break;
 		}
 		bcopy(&pr->rule, rule, sizeof(struct pf_rule));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rule->cuid =3D td->td_ucred->cr_ruid;
 		rule->cpid =3D td->td_proc ? td->td_proc->p_pid : 0;
 #else
@@ -1713,7 +1714,7 @@
 		rule->entries.tqe_prev =3D NULL;
 #ifndef INET
 		if (rule->af =3D=3D AF_INET) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_rule_pl, rule);
 #else
 			pool_put(&pf_rule_pl, rule);
@@ -1724,7 +1725,7 @@
 #endif /* INET */
 #ifndef INET6
 		if (rule->af =3D=3D AF_INET6) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_rule_pl, rule);
 #else
 			pool_put(&pf_rule_pl, rule);
@@ -1742,7 +1743,7 @@
 		if (rule->ifname[0]) {
 			rule->kif =3D pfi_kif_get(rule->ifname);
 			if (rule->kif =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_rule_pl, rule);
 #else
 				pool_put(&pf_rule_pl, rule);
@@ -1753,7 +1754,7 @@
 			pfi_kif_ref(rule->kif, PFI_KIF_REF_RULE);
 		}
=20
-#ifdef __FreeBSD__ /* ROUTING */
+#ifdef __FreeBSD_kernel__ /* ROUTING */
 		if (rule->rtableid > 0 && rule->rtableid > rt_numfibs)
 #else
 		if (rule->rtableid > 0 && !rtable_exists(rule->rtableid))
@@ -1797,7 +1798,7 @@
 			error =3D EINVAL;
 		if (pf_anchor_setup(rule, ruleset, pr->anchor_call))
 			error =3D EINVAL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		TAILQ_FOREACH(pa, &V_pf_pabuf, entries)
 #else
 		TAILQ_FOREACH(pa, &pf_pabuf, entries)
@@ -1814,7 +1815,7 @@
 				    PFR_TFLAG_ACTIVE;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_mv_pool(&V_pf_pabuf, &rule->rpool.list);
 #else
 		pf_mv_pool(&pf_pabuf, &rule->rpool.list);
@@ -1830,7 +1831,7 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (!V_debug_pfugidhack && (rule->uid.op || rule->gid.op ||
 		    rule->log & PF_LOG_SOCKET_LOOKUP)) {
 			DPFPRINTF(PF_DEBUG_MISC,
@@ -1934,7 +1935,7 @@
=20
 		if (!(pcr->action =3D=3D PF_CHANGE_REMOVE ||
 		    pcr->action =3D=3D PF_CHANGE_GET_TICKET) &&
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    pcr->pool_ticket !=3D V_ticket_pabuf) {
 #else
 		    pcr->pool_ticket !=3D ticket_pabuf) {
@@ -1975,7 +1976,7 @@
 		}
=20
 		if (pcr->action !=3D PF_CHANGE_REMOVE) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			newrule =3D pool_get(&V_pf_rule_pl, PR_NOWAIT);
 #else
 			newrule =3D pool_get(&pf_rule_pl, PR_WAITOK|PR_LIMITFAIL);
@@ -1985,7 +1986,7 @@
 				break;
 			}
 			bcopy(&pcr->rule, newrule, sizeof(struct pf_rule));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			newrule->cuid =3D td->td_ucred->cr_ruid;
 			newrule->cpid =3D td->td_proc ? td->td_proc->p_pid : 0;
 #else
@@ -1998,7 +1999,7 @@
 			newrule->entries.tqe_prev =3D NULL;
 #ifndef INET
 			if (newrule->af =3D=3D AF_INET) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_rule_pl, newrule);
 #else
 				pool_put(&pf_rule_pl, newrule);
@@ -2009,7 +2010,7 @@
 #endif /* INET */
 #ifndef INET6
 			if (newrule->af =3D=3D AF_INET6) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_rule_pl, newrule);
 #else
 				pool_put(&pf_rule_pl, newrule);
@@ -2021,7 +2022,7 @@
 			if (newrule->ifname[0]) {
 				newrule->kif =3D pfi_kif_get(newrule->ifname);
 				if (newrule->kif =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					pool_put(&V_pf_rule_pl, newrule);
 #else
 					pool_put(&pf_rule_pl, newrule);
@@ -2034,7 +2035,7 @@
 				newrule->kif =3D NULL;
=20
 			if (newrule->rtableid > 0 &&
-#ifdef __FreeBSD__ /* ROUTING */
+#ifdef __FreeBSD_kernel__ /* ROUTING */
 			    newrule->rtableid > rt_numfibs)
 #else
 			    !rtable_exists(newrule->rtableid))
@@ -2080,7 +2081,7 @@
 				error =3D EINVAL;
 			if (pf_anchor_setup(newrule, ruleset, pcr->anchor_call))
 				error =3D EINVAL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			TAILQ_FOREACH(pa, &V_pf_pabuf, entries)
 #else
 			TAILQ_FOREACH(pa, &pf_pabuf, entries)
@@ -2098,7 +2099,7 @@
 					    PFR_TFLAG_ACTIVE;
 			}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pf_mv_pool(&V_pf_pabuf, &newrule->rpool.list);
 #else
 			pf_mv_pool(&pf_pabuf, &newrule->rpool.list);
@@ -2116,7 +2117,7 @@
 				break;
 			}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (!V_debug_pfugidhack && (newrule->uid.op ||
 			    newrule->gid.op ||
 			    newrule->log & PF_LOG_SOCKET_LOOKUP)) {
@@ -2131,7 +2132,7 @@
 			newrule->packets[0] =3D newrule->packets[1] =3D 0;
 			newrule->bytes[0] =3D newrule->bytes[1] =3D 0;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_empty_pool(&V_pf_pabuf);
 #else
 		pf_empty_pool(&pf_pabuf);
@@ -2192,7 +2193,7 @@
 		struct pfioc_state_kill *psk =3D (struct pfioc_state_kill *)addr;
 		u_int			 killed =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		for (s =3D RB_MIN(pf_state_tree_id, &V_tree_id); s; s =3D nexts) {
 			nexts =3D RB_NEXT(pf_state_tree_id, &V_tree_id, s);
 #else
@@ -2212,7 +2213,7 @@
 		}
 		psk->psk_killed =3D killed;
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pfsync_clear_states_ptr !=3D NULL)
 			pfsync_clear_states_ptr(V_pf_status.hostid, psk->psk_ifname);
 #else
@@ -2232,7 +2233,7 @@
=20
 		if (psk->psk_pfcmp.id) {
 			if (psk->psk_pfcmp.creatorid =3D=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				psk->psk_pfcmp.creatorid =3D V_pf_status.hostid;
 #else
 				psk->psk_pfcmp.creatorid =3D pf_status.hostid;
@@ -2244,7 +2245,7 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		for (s =3D RB_MIN(pf_state_tree_id, &V_tree_id); s;
 		    s =3D nexts) {
 			nexts =3D RB_NEXT(pf_state_tree_id, &V_tree_id, s);
@@ -2306,7 +2307,7 @@
 			error =3D EINVAL;
 			break;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pfsync_state_import_ptr !=3D NULL)
 			error =3D pfsync_state_import_ptr(sp, PFSYNC_SI_IOCTL);
 #else
@@ -2340,7 +2341,7 @@
 		u_int32_t		 nr =3D 0;
=20
 		if (ps->ps_len =3D=3D 0) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			nr =3D V_pf_status.states;
 #else
 			nr =3D pf_status.states;
@@ -2349,17 +2350,17 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		pstore =3D malloc(sizeof(*pstore), M_TEMP, M_WAITOK);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
=20
 		p =3D ps->ps_states;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		state =3D TAILQ_FIRST(&V_state_list);
 #else
 		state =3D TAILQ_FIRST(&state_list);
@@ -2369,7 +2370,7 @@
 				if ((nr+1) * sizeof(*p) > (unsigned)ps->ps_len)
 					break;
 				pfsync_state_export(pstore, state);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				PF_COPYOUT(pstore, p, sizeof(*p), error);
 #else
 				error =3D copyout(pstore, p, sizeof(*p));
@@ -2392,7 +2393,7 @@
=20
 	case DIOCGETSTATUS: {
 		struct pf_status *s =3D (struct pf_status *)addr;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		bcopy(&V_pf_status, s, sizeof(struct pf_status));
 #else
 		bcopy(&pf_status, s, sizeof(struct pf_status));
@@ -2405,14 +2406,14 @@
 		struct pfioc_if	*pi =3D (struct pfioc_if *)addr;
=20
 		if (pi->ifname[0] =3D=3D 0) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			bzero(V_pf_status.ifname, IFNAMSIZ);
 #else
 			bzero(pf_status.ifname, IFNAMSIZ);
 #endif
 			break;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		strlcpy(V_pf_status.ifname, pi->ifname, IFNAMSIZ);
 #else
 		strlcpy(pf_status.ifname, pi->ifname, IFNAMSIZ);
@@ -2421,7 +2422,7 @@
 	}
=20
 	case DIOCCLRSTATUS: {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		bzero(V_pf_status.counters, sizeof(V_pf_status.counters));
 		bzero(V_pf_status.fcounters, sizeof(V_pf_status.fcounters));
 		bzero(V_pf_status.scounters, sizeof(V_pf_status.scounters));
@@ -2491,14 +2492,14 @@
 			error =3D EINVAL;
 			goto fail;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		old =3D V_pf_default_rule.timeout[pt->timeout];
 #else
 		old =3D pf_default_rule.timeout[pt->timeout];
 #endif
 		if (pt->timeout =3D=3D PFTM_INTERVAL && pt->seconds =3D=3D 0)
 			pt->seconds =3D 1;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_default_rule.timeout[pt->timeout] =3D pt->seconds;
 #else
 		pf_default_rule.timeout[pt->timeout] =3D pt->seconds;
@@ -2516,7 +2517,7 @@
 			error =3D EINVAL;
 			goto fail;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pt->seconds =3D V_pf_default_rule.timeout[pt->timeout];
 #else
 		pt->seconds =3D pf_default_rule.timeout[pt->timeout];
@@ -2531,7 +2532,7 @@
 			error =3D EINVAL;
 			goto fail;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pl->limit =3D V_pf_pool_limits[pl->index].limit;
 #else
 		pl->limit =3D pf_pool_limits[pl->index].limit;
@@ -2544,7 +2545,7 @@
 		int			 old_limit;
=20
 		if (pl->index < 0 || pl->index >=3D PF_LIMIT_MAX ||
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    V_pf_pool_limits[pl->index].pp =3D=3D NULL) {
 #else
 		    pf_pool_limits[pl->index].pp =3D=3D NULL) {
@@ -2552,7 +2553,7 @@
 			error =3D EINVAL;
 			goto fail;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		uma_zone_set_max(V_pf_pool_limits[pl->index].pp, pl->limit);
 		old_limit =3D V_pf_pool_limits[pl->index].limit;
 		V_pf_pool_limits[pl->index].limit =3D pl->limit;
@@ -2573,7 +2574,7 @@
 	case DIOCSETDEBUG: {
 		u_int32_t	*level =3D (u_int32_t *)addr;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.debug =3D *level;
 #else
 		pf_status.debug =3D *level;
@@ -2595,7 +2596,7 @@
 		break;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	case DIOCGIFSPEED: {
 		struct pf_ifspeed	*psp =3D (struct pf_ifspeed *)addr;
 		struct pf_ifspeed	ps;
@@ -2620,7 +2621,7 @@
 		struct pf_altq		*altq;
=20
 		/* enable all altq interfaces on active list */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		TAILQ_FOREACH(altq, V_pf_altqs_active, entries) {
 			if (altq->qname[0] =3D=3D 0 && (altq->local_flags &
 			    PFALTQ_FLAG_IF_REMOVED) =3D=3D 0) {
@@ -2634,7 +2635,7 @@
 			}
 		}
 		if (error =3D=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			V_pf_altq_running =3D 1;
 #else
 			pf_altq_running =3D 1;
@@ -2647,7 +2648,7 @@
 		struct pf_altq		*altq;
=20
 		/* disable all altq interfaces on active list */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		TAILQ_FOREACH(altq, V_pf_altqs_active, entries) {
 			if (altq->qname[0] =3D=3D 0 && (altq->local_flags &
 			    PFALTQ_FLAG_IF_REMOVED) =3D=3D 0) {
@@ -2661,7 +2662,7 @@
 			}
 		}
 		if (error =3D=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			V_pf_altq_running =3D 0;
 #else
 			pf_altq_running =3D 0;
@@ -2674,7 +2675,7 @@
 		struct pfioc_altq	*pa =3D (struct pfioc_altq *)addr;
 		struct pf_altq		*altq, *a;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pa->ticket !=3D V_ticket_altqs_inactive) {
 #else
 		if (pa->ticket !=3D ticket_altqs_inactive) {
@@ -2682,7 +2683,7 @@
 			error =3D EBUSY;
 			break;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		altq =3D pool_get(&V_pf_altq_pl, PR_NOWAIT);
 #else
 		altq =3D pool_get(&pf_altq_pl, PR_WAITOK|PR_LIMITFAIL);
@@ -2692,7 +2693,7 @@
 			break;
 		}
 		bcopy(&pa->altq, altq, sizeof(struct pf_altq));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		altq->local_flags =3D 0;
 #endif
=20
@@ -2703,7 +2704,7 @@
 		if (altq->qname[0] !=3D 0) {
 			if ((altq->qid =3D pf_qname2qid(altq->qname)) =3D=3D 0) {
 				error =3D EBUSY;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_altq_pl, altq);
 #else
 				pool_put(&pf_altq_pl, altq);
@@ -2711,7 +2712,7 @@
 				break;
 			}
 			altq->altq_disc =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			TAILQ_FOREACH(a, V_pf_altqs_inactive, entries) {
 #else
 			TAILQ_FOREACH(a, pf_altqs_inactive, entries) {
@@ -2724,7 +2725,7 @@
 			}
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		struct ifnet *ifp;
=20
 		if ((ifp =3D ifunit(altq->ifname)) =3D=3D NULL) {
@@ -2733,12 +2734,12 @@
 			PF_UNLOCK();
 #endif
 		error =3D altq_add(altq);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_LOCK();
 		}
 #endif
 		if (error) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_altq_pl, altq);
 #else
 			pool_put(&pf_altq_pl, altq);
@@ -2746,7 +2747,7 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		TAILQ_INSERT_TAIL(V_pf_altqs_inactive, altq, entries);
 #else
 		TAILQ_INSERT_TAIL(pf_altqs_inactive, altq, entries);
@@ -2760,7 +2761,7 @@
 		struct pf_altq		*altq;
=20
 		pa->nr =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		TAILQ_FOREACH(altq, V_pf_altqs_active, entries)
 			pa->nr++;
 		pa->ticket =3D V_ticket_altqs_active;
@@ -2777,7 +2778,7 @@
 		struct pf_altq		*altq;
 		u_int32_t		 nr;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pa->ticket !=3D V_ticket_altqs_active) {
 #else
 		if (pa->ticket !=3D ticket_altqs_active) {
@@ -2786,7 +2787,7 @@
 			break;
 		}
 		nr =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		altq =3D TAILQ_FIRST(V_pf_altqs_active);
 #else
 		altq =3D TAILQ_FIRST(pf_altqs_active);
@@ -2814,7 +2815,7 @@
 		u_int32_t		 nr;
 		int			 nbytes;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pq->ticket !=3D V_ticket_altqs_active) {
 #else
 		if (pq->ticket !=3D ticket_altqs_active) {
@@ -2824,7 +2825,7 @@
 		}
 		nbytes =3D pq->nbytes;
 		nr =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		altq =3D TAILQ_FIRST(V_pf_altqs_active);
 #else
 		altq =3D TAILQ_FIRST(pf_altqs_active);
@@ -2838,7 +2839,7 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((altq->local_flags & PFALTQ_FLAG_IF_REMOVED) !=3D 0) {
 			error =3D ENXIO;
 			break;
@@ -2846,7 +2847,7 @@
 		PF_UNLOCK();
 #endif
 		error =3D altq_getqstats(altq, pq->buf, &nbytes);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		if (error =3D=3D 0) {
@@ -2860,7 +2861,7 @@
 	case DIOCBEGINADDRS: {
 		struct pfioc_pooladdr	*pp =3D (struct pfioc_pooladdr *)addr;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_empty_pool(&V_pf_pabuf);
 		pp->ticket =3D ++V_ticket_pabuf;
 #else
@@ -2873,7 +2874,7 @@
 	case DIOCADDADDR: {
 		struct pfioc_pooladdr	*pp =3D (struct pfioc_pooladdr *)addr;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pp->ticket !=3D V_ticket_pabuf) {
 #else
 		if (pp->ticket !=3D ticket_pabuf) {
@@ -2899,7 +2900,7 @@
 			error =3D EINVAL;
 			break;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pa =3D pool_get(&V_pf_pooladdr_pl, PR_NOWAIT);
 #else
 		pa =3D pool_get(&pf_pooladdr_pl, PR_WAITOK|PR_LIMITFAIL);
@@ -2912,7 +2913,7 @@
 		if (pa->ifname[0]) {
 			pa->kif =3D pfi_kif_get(pa->ifname);
 			if (pa->kif =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_pooladdr_pl, pa);
 #else
 				pool_put(&pf_pooladdr_pl, pa);
@@ -2925,7 +2926,7 @@
 		if (pfi_dynaddr_setup(&pa->addr, pp->af)) {
 			pfi_dynaddr_remove(&pa->addr);
 			pfi_kif_unref(pa->kif, PFI_KIF_REF_RULE);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_pooladdr_pl, pa);
 #else
 			pool_put(&pf_pooladdr_pl, pa);
@@ -2933,7 +2934,7 @@
 			error =3D EINVAL;
 			break;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		TAILQ_INSERT_TAIL(&V_pf_pabuf, pa, entries);
 #else
 		TAILQ_INSERT_TAIL(&pf_pabuf, pa, entries);
@@ -3009,7 +3010,7 @@
 			break;
 		}
 		if (pca->action !=3D PF_CHANGE_REMOVE) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			newpa =3D pool_get(&V_pf_pooladdr_pl,
 			    PR_NOWAIT);
 #else
@@ -3023,7 +3024,7 @@
 			bcopy(&pca->addr, newpa, sizeof(struct pf_pooladdr));
 #ifndef INET
 			if (pca->af =3D=3D AF_INET) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_pooladdr_pl, newpa);
 #else
 				pool_put(&pf_pooladdr_pl, newpa);
@@ -3034,7 +3035,7 @@
 #endif /* INET */
 #ifndef INET6
 			if (pca->af =3D=3D AF_INET6) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_pooladdr_pl, newpa);
 #else
 				pool_put(&pf_pooladdr_pl, newpa);
@@ -3046,7 +3047,7 @@
 			if (newpa->ifname[0]) {
 				newpa->kif =3D pfi_kif_get(newpa->ifname);
 				if (newpa->kif =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					pool_put(&V_pf_pooladdr_pl, newpa);
 #else
 					pool_put(&pf_pooladdr_pl, newpa);
@@ -3061,7 +3062,7 @@
 			    pf_tbladdr_setup(ruleset, &newpa->addr)) {
 				pfi_dynaddr_remove(&newpa->addr);
 				pfi_kif_unref(newpa->kif, PFI_KIF_REF_RULE);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_pooladdr_pl, newpa);
 #else
 				pool_put(&pf_pooladdr_pl, newpa);
@@ -3094,7 +3095,7 @@
 			pfi_dynaddr_remove(&oldpa->addr);
 			pf_tbladdr_remove(&oldpa->addr);
 			pfi_kif_unref(oldpa->kif, PFI_KIF_REF_RULE);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_pooladdr_pl, oldpa);
 #else
 			pool_put(&pf_pooladdr_pl, oldpa);
@@ -3129,7 +3130,7 @@
 		pr->nr =3D 0;
 		if (ruleset->anchor =3D=3D NULL) {
 			/* XXX kludge for pf_main_ruleset */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			RB_FOREACH(anchor, pf_anchor_global, &V_pf_anchors)
 #else
 			RB_FOREACH(anchor, pf_anchor_global, &pf_anchors)
@@ -3158,7 +3159,7 @@
 		pr->name[0] =3D 0;
 		if (ruleset->anchor =3D=3D NULL) {
 			/* XXX kludge for pf_main_ruleset */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			RB_FOREACH(anchor, pf_anchor_global, &V_pf_anchors)
 #else
 			RB_FOREACH(anchor, pf_anchor_global, &pf_anchors)
@@ -3404,16 +3405,16 @@
 			error =3D ENODEV;
 			goto fail;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		ioe =3D malloc(sizeof(*ioe), M_TEMP, M_WAITOK);
 		table =3D malloc(sizeof(*table), M_TEMP, M_WAITOK);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		for (i =3D 0; i < io->size; i++) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_COPYIN(io->array+i, ioe, sizeof(*ioe), error);
 		if (error) {
 #else
@@ -3460,7 +3461,7 @@
 				}
 				break;
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_COPYOUT(ioe, io->array+i, sizeof(io->array[i]),
 			    error);
 			if (error) {
@@ -3488,16 +3489,16 @@
 			error =3D ENODEV;
 			goto fail;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		ioe =3D malloc(sizeof(*ioe), M_TEMP, M_WAITOK);
 		table =3D malloc(sizeof(*table), M_TEMP, M_WAITOK);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		for (i =3D 0; i < io->size; i++) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_COPYIN(io->array+i, ioe, sizeof(*ioe), error);
 			if (error) {
 #else
@@ -3561,17 +3562,17 @@
 			error =3D ENODEV;
 			goto fail;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		ioe =3D malloc(sizeof(*ioe), M_TEMP, M_WAITOK);
 		table =3D malloc(sizeof(*table), M_TEMP, M_WAITOK);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		/* first makes sure everything will succeed */
 		for (i =3D 0; i < io->size; i++) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_COPYIN(io->array+i, ioe, sizeof(*ioe), error);
 			if (error) {
 #else
@@ -3591,7 +3592,7 @@
 					error =3D EINVAL;
 					goto fail;
 				}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				if (!V_altqs_inactive_open || ioe->ticket !=3D
 				    V_ticket_altqs_inactive) {
 #else
@@ -3638,7 +3639,7 @@
 		}
 		/* now do the commit - no errors should happen here */
 		for (i =3D 0; i < io->size; i++) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_COPYIN(io->array+i, ioe, sizeof(*ioe), error);
 			if (error) {
 #else
@@ -3692,7 +3693,7 @@
 		int			 space =3D psn->psn_len;
=20
 		if (space =3D=3D 0) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			RB_FOREACH(n, pf_src_tree, &V_tree_src_tracking)
 #else
 			RB_FOREACH(n, pf_src_tree, &tree_src_tracking)
@@ -3702,15 +3703,15 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		pstore =3D malloc(sizeof(*pstore), M_TEMP, M_WAITOK);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		p =3D psn->psn_src_nodes;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_FOREACH(n, pf_src_tree, &V_tree_src_tracking) {
 #else
 		RB_FOREACH(n, pf_src_tree, &tree_src_tracking) {
@@ -3738,7 +3739,7 @@
 				    n->conn_rate.count * diff /
 				    n->conn_rate.seconds;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_COPYOUT(pstore, p, sizeof(*p), error);
 #else
 			error =3D copyout(pstore, p, sizeof(*p));
@@ -3760,7 +3761,7 @@
 		struct pf_src_node	*n;
 		struct pf_state		*state;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_FOREACH(state, pf_state_tree_id, &V_tree_id) {
 #else
 		RB_FOREACH(state, pf_state_tree_id, &tree_id) {
@@ -3768,7 +3769,7 @@
 			state->src_node =3D NULL;
 			state->nat_src_node =3D NULL;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_FOREACH(n, pf_src_tree, &V_tree_src_tracking) {
 #else
 		RB_FOREACH(n, pf_src_tree, &tree_src_tracking) {
@@ -3777,7 +3778,7 @@
 			n->states =3D 0;
 		}
 		pf_purge_expired_src_nodes(1);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.src_nodes =3D 0;
 #else
 		pf_status.src_nodes =3D 0;
@@ -3792,7 +3793,7 @@
 		    (struct pfioc_src_node_kill *)addr;
 		u_int			killed =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_FOREACH(sn, pf_src_tree, &V_tree_src_tracking) {
 #else
 		RB_FOREACH(sn, pf_src_tree, &tree_src_tracking) {
@@ -3808,7 +3809,7 @@
 				/* Handle state to src_node linkage */
 				if (sn->states !=3D 0) {
 					RB_FOREACH(s, pf_state_tree_id,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    &V_tree_id) {
 #else
 					    &tree_id) {
@@ -3835,7 +3836,7 @@
 	case DIOCSETHOSTID: {
 		u_int32_t	*hostid =3D (u_int32_t *)addr;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (*hostid =3D=3D 0)
 			V_pf_status.hostid =3D arc4random();
 		else
@@ -3884,7 +3885,7 @@
 		break;
 	}
 fail:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
=20
 	if (flags & FWRITE)
@@ -3904,7 +3905,7 @@
 	return (error);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void
 pfsync_state_export(struct pfsync_state *sp, struct pf_state *st)
 {
@@ -3974,7 +3975,7 @@
 {
 	struct pf_state	*state;
 =20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_FOREACH(state, pf_state_tree_id, &V_tree_id) {
 #else
 	RB_FOREACH(state, pf_state_tree_id, &tree_id) {
@@ -4015,7 +4016,7 @@
 	struct pf_src_node	*n;
 	struct pf_state		*state;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_FOREACH(state, pf_state_tree_id, &V_tree_id) {
 #else
 	RB_FOREACH(state, pf_state_tree_id, &tree_id) {
@@ -4023,7 +4024,7 @@
 		state->src_node =3D NULL;
 		state->nat_src_node =3D NULL;
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_FOREACH(n, pf_src_tree, &V_tree_src_tracking) {
 #else
 	RB_FOREACH(n, pf_src_tree, &tree_src_tracking) {
Index: sys/contrib/pf/net/pf_norm.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
--- sys/contrib/pf/net/pf_norm.c	(revision 230747)
+++ sys/contrib/pf/net/pf_norm.c	(working copy)
@@ -25,7 +25,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_pf.h"
@@ -42,7 +44,6 @@
 #include "pflog.h"
 #endif
=20
-#include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
 #include <sys/filio.h>
@@ -50,7 +51,7 @@
 #include <sys/socket.h>
 #include <sys/kernel.h>
 #include <sys/time.h>
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <sys/pool.h>
=20
 #include <dev/rndvar.h>
@@ -77,7 +78,7 @@
=20
 #include <net/pfvar.h>
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 struct pf_frent {
 	LIST_ENTRY(pf_frent) fr_next;
 	struct ip *fr_ip;
@@ -96,7 +97,7 @@
 #define PFFRAG_DROP	0x0004		/* Drop all fragments */
 #define BUFFER_FRAGMENTS(fr)	(!((fr)->fr_flags & PFFRAG_NOBUFFER))
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 struct pf_fragment {
 	RB_ENTRY(pf_fragment) fr_entry;
 	TAILQ_ENTRY(pf_fragment) frag_next;
@@ -116,7 +117,7 @@
 };
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 TAILQ_HEAD(pf_fragqueue, pf_fragment);
 TAILQ_HEAD(pf_cachequeue, pf_fragment);
 VNET_DEFINE(struct pf_fragqueue,	pf_fragqueue);
@@ -128,7 +129,7 @@
 TAILQ_HEAD(pf_cachequeue, pf_fragment)	pf_cachequeue;
 #endif
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 static __inline int	 pf_frag_compare(struct pf_fragment *,
 			    struct pf_fragment *);
 #else
@@ -136,7 +137,7 @@
 			    struct pf_fragment *);
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 RB_HEAD(pf_frag_tree, pf_fragment);
 VNET_DEFINE(struct pf_frag_tree,	pf_frag_tree);
 #define	V_pf_frag_tree			VNET(pf_frag_tree)
@@ -165,7 +166,7 @@
 #ifdef INET6
 void			 pf_scrub_ip6(struct mbuf **, u_int8_t);
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define	DPFPRINTF(x) do {				\
 	if (V_pf_status.debug >=3D PF_DEBUG_MISC) {	\
 		printf("%s: ", __func__);		\
@@ -182,7 +183,7 @@
 #endif
=20
 /* Globals */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 VNET_DEFINE(uma_zone_t,		pf_frent_pl);
 VNET_DEFINE(uma_zone_t,		pf_frag_pl);
 VNET_DEFINE(uma_zone_t,		pf_cache_pl);
@@ -202,7 +203,7 @@
 void
 pf_normalize_init(void)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/*
 	 * XXX
 	 * No high water mark support(It's hint not hard limit).
@@ -229,7 +230,7 @@
 	pool_sethardlimit(&pf_cent_pl, PFFRAG_FRCENT_HIWAT, NULL, 0);
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	TAILQ_INIT(&V_pf_fragqueue);
 	TAILQ_INIT(&V_pf_cachequeue);
 #else
@@ -238,7 +239,7 @@
 #endif
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static int
 #else
 static __inline int
@@ -266,7 +267,7 @@
 pf_purge_expired_fragments(void)
 {
 	struct pf_fragment	*frag;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	u_int32_t		 expire =3D time_second -
 				    V_pf_default_rule.timeout[PFTM_FRAG];
 #else
@@ -274,7 +275,7 @@
 				    pf_default_rule.timeout[PFTM_FRAG];
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	while ((frag =3D TAILQ_LAST(&V_pf_fragqueue, pf_fragqueue)) !=3D NULL) {
 		KASSERT((BUFFER_FRAGMENTS(frag)),
 		    ("BUFFER_FRAGMENTS(frag) =3D=3D 0: %s", __FUNCTION__));
@@ -289,7 +290,7 @@
 		pf_free_fragment(frag);
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	while ((frag =3D TAILQ_LAST(&V_pf_cachequeue, pf_cachequeue)) !=3D NULL) {
 		KASSERT((!BUFFER_FRAGMENTS(frag)),
 		    ("BUFFER_FRAGMENTS(frag) !=3D 0: %s", __FUNCTION__));
@@ -302,7 +303,7 @@
=20
 		DPFPRINTF(("expiring %d(%p)\n", frag->fr_id, frag));
 		pf_free_fragment(frag);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		KASSERT((TAILQ_EMPTY(&V_pf_cachequeue) ||
 		    TAILQ_LAST(&V_pf_cachequeue, pf_cachequeue) !=3D frag),
 		    ("!(TAILQ_EMPTY() || TAILQ_LAST() =3D=3D farg): %s",
@@ -324,7 +325,7 @@
 	struct pf_fragment	*frag;
 	int			 goal;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	goal =3D V_pf_nfrents * 9 / 10;
 	DPFPRINTF(("trying to free > %d frents\n",
 	    V_pf_nfrents - goal));
@@ -335,7 +336,7 @@
 	    pf_nfrents - goal));
 	while (goal < pf_nfrents) {
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		frag =3D TAILQ_LAST(&V_pf_fragqueue, pf_fragqueue);
 #else
 		frag =3D TAILQ_LAST(&pf_fragqueue, pf_fragqueue);
@@ -346,7 +347,7 @@
 	}
=20
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	goal =3D V_pf_ncache * 9 / 10;
 	DPFPRINTF(("trying to free > %d cache entries\n",
 	    V_pf_ncache - goal));
@@ -357,7 +358,7 @@
 	    pf_ncache - goal));
 	while (goal < pf_ncache) {
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		frag =3D TAILQ_LAST(&V_pf_cachequeue, pf_cachequeue);
 #else
 		frag =3D TAILQ_LAST(&pf_cachequeue, pf_cachequeue);
@@ -383,7 +384,7 @@
 			LIST_REMOVE(frent, fr_next);
=20
 			m_freem(frent->fr_m);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_frent_pl, frent);
 			V_pf_nfrents--;
 #else
@@ -396,7 +397,7 @@
 		    frcache =3D LIST_FIRST(&frag->fr_cache)) {
 			LIST_REMOVE(frcache, fr_next);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			KASSERT((LIST_EMPTY(&frag->fr_cache) ||
 			    LIST_FIRST(&frag->fr_cache)->fr_off >
 			    frcache->fr_end),
@@ -441,7 +442,7 @@
 		/* XXX Are we sure we want to update the timeout? */
 		frag->fr_timeout =3D time_second;
 		if (BUFFER_FRAGMENTS(frag)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			TAILQ_REMOVE(&V_pf_fragqueue, frag, frag_next);
 			TAILQ_INSERT_HEAD(&V_pf_fragqueue, frag, frag_next);
 #else
@@ -449,7 +450,7 @@
 			TAILQ_INSERT_HEAD(&pf_fragqueue, frag, frag_next);
 #endif
 		} else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			TAILQ_REMOVE(&V_pf_cachequeue, frag, frag_next);
 			TAILQ_INSERT_HEAD(&V_pf_cachequeue, frag, frag_next);
 #else
@@ -468,7 +469,7 @@
 pf_remove_fragment(struct pf_fragment *frag)
 {
 	if (BUFFER_FRAGMENTS(frag)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_REMOVE(pf_frag_tree, &V_pf_frag_tree, frag);
 		TAILQ_REMOVE(&V_pf_fragqueue, frag, frag_next);
 		pool_put(&V_pf_frag_pl, frag);
@@ -478,7 +479,7 @@
 		pool_put(&pf_frag_pl, frag);
 #endif
 	} else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_REMOVE(pf_frag_tree, &V_pf_cache_tree, frag);
 		TAILQ_REMOVE(&V_pf_cachequeue, frag, frag_next);
 		pool_put(&V_pf_cache_pl, frag);
@@ -504,7 +505,7 @@
 	u_int16_t	 ip_len =3D ntohs(ip->ip_len) - ip->ip_hl * 4;
 	u_int16_t	 max =3D ip_len + off;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((*frag =3D=3D NULL || BUFFER_FRAGMENTS(*frag)),
 	    ("! (*frag =3D=3D NULL || BUFFER_FRAGMENTS(*frag)): %s", __FUNCTION__=
));
 #else
@@ -517,14 +518,14 @@
=20
 	/* Create a new reassembly queue for this packet */
 	if (*frag =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		*frag =3D pool_get(&V_pf_frag_pl, PR_NOWAIT);
 #else
 		*frag =3D pool_get(&pf_frag_pl, PR_NOWAIT);
 #endif
 		if (*frag =3D=3D NULL) {
 			pf_flush_fragments();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			*frag =3D pool_get(&V_pf_frag_pl, PR_NOWAIT);
 #else
 			*frag =3D pool_get(&pf_frag_pl, PR_NOWAIT);
@@ -542,7 +543,7 @@
 		(*frag)->fr_timeout =3D time_second;
 		LIST_INIT(&(*frag)->fr_queue);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_INSERT(pf_frag_tree, &V_pf_frag_tree, *frag);
 		TAILQ_INSERT_HEAD(&V_pf_fragqueue, *frag, frag_next);
 #else
@@ -565,7 +566,7 @@
 		frep =3D frea;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((frep !=3D NULL || frea !=3D NULL),
 	    ("!(frep !=3D NULL || frea !=3D NULL): %s", __FUNCTION__));;
 #else
@@ -613,7 +614,7 @@
 		next =3D LIST_NEXT(frea, fr_next);
 		m_freem(frea->fr_m);
 		LIST_REMOVE(frea, fr_next);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_frent_pl, frea);
 		V_pf_nfrents--;
 #else
@@ -660,7 +661,7 @@
=20
 	/* We have all the data */
 	frent =3D LIST_FIRST(&(*frag)->fr_queue);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((frent !=3D NULL), ("frent =3D=3D NULL: %s", __FUNCTION__));
 #else
 	KASSERT(frent !=3D NULL);
@@ -679,7 +680,7 @@
 	m2 =3D m->m_next;
 	m->m_next =3D NULL;
 	m_cat(m, m2);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pool_put(&V_pf_frent_pl, frent);
 	V_pf_nfrents--;
 #else
@@ -690,21 +691,21 @@
 		next =3D LIST_NEXT(frent, fr_next);
=20
 		m2 =3D frent->fr_m;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_frent_pl, frent);
 		V_pf_nfrents--;
 #else
 		pool_put(&pf_frent_pl, frent);
 		pf_nfrents--;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m->m_pkthdr.csum_flags &=3D m2->m_pkthdr.csum_flags;
 		m->m_pkthdr.csum_data +=3D m2->m_pkthdr.csum_data;
 #endif
 		m_cat(m, m2);
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	while (m->m_pkthdr.csum_data & 0xffff0000)
 		m->m_pkthdr.csum_data =3D (m->m_pkthdr.csum_data & 0xffff) +
 		    (m->m_pkthdr.csum_data >> 16);
@@ -735,7 +736,7 @@
=20
  drop_fragment:
 	/* Oops - fail safe - drop packet */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pool_put(&V_pf_frent_pl, frent);
 	V_pf_nfrents--;
 #else
@@ -757,7 +758,7 @@
 	u_int16_t		 max =3D ip_len + off;
 	int			 hosed =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((*frag =3D=3D NULL || !BUFFER_FRAGMENTS(*frag)),
 	    ("!(*frag =3D=3D NULL || !BUFFER_FRAGMENTS(*frag)): %s", __FUNCTION__=
));
 #else
@@ -766,14 +767,14 @@
=20
 	/* Create a new range queue for this packet */
 	if (*frag =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		*frag =3D pool_get(&V_pf_cache_pl, PR_NOWAIT);
 #else
 		*frag =3D pool_get(&pf_cache_pl, PR_NOWAIT);
 #endif
 		if (*frag =3D=3D NULL) {
 			pf_flush_fragments();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			*frag =3D pool_get(&V_pf_cache_pl, PR_NOWAIT);
 #else
 			*frag =3D pool_get(&pf_cache_pl, PR_NOWAIT);
@@ -783,7 +784,7 @@
 		}
=20
 		/* Get an entry for the queue */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		cur =3D pool_get(&V_pf_cent_pl, PR_NOWAIT);
 		if (cur =3D=3D NULL) {
 			pool_put(&V_pf_cache_pl, *frag);
@@ -795,7 +796,7 @@
 			*frag =3D NULL;
 			goto no_mem;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_ncache++;
 #else
 		pf_ncache++;
@@ -814,7 +815,7 @@
 		LIST_INIT(&(*frag)->fr_cache);
 		LIST_INSERT_HEAD(&(*frag)->fr_cache, cur, fr_next);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_INSERT(pf_frag_tree, &V_pf_cache_tree, *frag);
 		TAILQ_INSERT_HEAD(&V_pf_cachequeue, *frag, frag_next);
 #else
@@ -838,7 +839,7 @@
 		frp =3D fra;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((frp !=3D NULL || fra !=3D NULL),
 	    ("!(frp !=3D NULL || fra !=3D NULL): %s", __FUNCTION__));
 #else
@@ -885,14 +886,14 @@
 				 * than this mbuf magic.  For my next trick,
 				 * I'll pull a rabbit out of my laptop.
 				 */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				*m0 =3D m_dup(m, M_DONTWAIT);
 #else
 				*m0 =3D m_copym2(m, 0, h->ip_hl << 2, M_NOWAIT);
 #endif
 				if (*m0 =3D=3D NULL)
 					goto no_mem;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				/* From KAME Project : We have missed this! */
 				m_adj(*m0, (h->ip_hl << 2) -
 				    (*m0)->m_pkthdr.len);
@@ -917,7 +918,7 @@
=20
 				h =3D mtod(m, struct ip *);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				KASSERT(((int)m->m_len =3D=3D
 				    ntohs(h->ip_len) - precut),
 				    ("m->m_len !=3D ntohs(h->ip_len) - precut: %s",
@@ -939,14 +940,14 @@
 			    h->ip_id, -precut, frp->fr_off, frp->fr_end, off,
 			    max));
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			cur =3D pool_get(&V_pf_cent_pl, PR_NOWAIT);
 #else
 			cur =3D pool_get(&pf_cent_pl, PR_NOWAIT);
 #endif
 			if (cur =3D=3D NULL)
 				goto no_mem;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			V_pf_ncache++;
 #else
 			pf_ncache++;
@@ -989,7 +990,7 @@
 					m->m_pkthdr.len =3D plen;
 				}
 				h =3D mtod(m, struct ip *);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				KASSERT(((int)m->m_len =3D=3D ntohs(h->ip_len) - aftercut),
 				    ("m->m_len !=3D ntohs(h->ip_len) - aftercut: %s",
 				    __FUNCTION__));
@@ -1007,14 +1008,14 @@
 			    h->ip_id, -aftercut, off, max, fra->fr_off,
 			    fra->fr_end));
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			cur =3D pool_get(&V_pf_cent_pl, PR_NOWAIT);
 #else
 			cur =3D pool_get(&pf_cent_pl, PR_NOWAIT);
 #endif
 			if (cur =3D=3D NULL)
 				goto no_mem;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			V_pf_ncache++;
 #else
 			pf_ncache++;
@@ -1036,7 +1037,7 @@
 				    max, fra->fr_off, fra->fr_end));
 				fra->fr_off =3D cur->fr_off;
 				LIST_REMOVE(cur, fr_next);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_cent_pl, cur);
 				V_pf_ncache--;
 #else
@@ -1047,7 +1048,7 @@
=20
 			} else if (frp && fra->fr_off <=3D frp->fr_end) {
 				/* Need to merge in a modified 'frp' */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				KASSERT((cur =3D=3D NULL), ("cur !=3D NULL: %s",
 				    __FUNCTION__));
 #else
@@ -1059,7 +1060,7 @@
 				    max, fra->fr_off, fra->fr_end));
 				fra->fr_off =3D frp->fr_off;
 				LIST_REMOVE(frp, fr_next);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pool_put(&V_pf_cent_pl, frp);
 				V_pf_ncache--;
 #else
@@ -1169,7 +1170,7 @@
 		    (struct pf_addr *)&h->ip_dst.s_addr, AF_INET,
 		    r->dst.neg, NULL))
 			r =3D r->skip[PF_SKIP_DST_ADDR].ptr;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		else if (r->match_tag && !pf_match_tag(m, r, &tag, pd->pf_mtag))
 #else
 		else if (r->match_tag && !pf_match_tag(m, r, &tag))
@@ -1233,7 +1234,7 @@
 	if ((r->rule_flag & (PFRULE_FRAGCROP|PFRULE_FRAGDROP)) =3D=3D 0) {
 		/* Fully buffer all of the fragments */
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		frag =3D pf_find_fragment(h, &V_pf_frag_tree);
 #else
 		frag =3D pf_find_fragment(h, &pf_frag_tree);
@@ -1245,7 +1246,7 @@
 			goto bad;
=20
 		/* Get an entry for the fragment queue */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		frent =3D pool_get(&V_pf_frent_pl, PR_NOWAIT);
 #else
 		frent =3D pool_get(&pf_frent_pl, PR_NOWAIT);
@@ -1254,7 +1255,7 @@
 			REASON_SET(reason, PFRES_MEMORY);
 			return (PF_DROP);
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_nfrents++;
 #else
 		pf_nfrents++;
@@ -1289,7 +1290,7 @@
 		/* non-buffering fragment cache (drops or masks overlaps) */
 		int	nomem =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (dir =3D=3D PF_OUT && pd->pf_mtag->flags & PF_TAG_FRAGCACHE) {
 #else
 		if (dir =3D=3D PF_OUT && m->m_pkthdr.pf.flags & PF_TAG_FRAGCACHE) {
@@ -1302,7 +1303,7 @@
 			goto fragment_pass;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		frag =3D pf_find_fragment(h, &V_pf_cache_tree);
 #else
 		frag =3D pf_find_fragment(h, &pf_cache_tree);
@@ -1337,7 +1338,7 @@
 		}
 #endif
 		if (dir =3D=3D PF_IN)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pd->pf_mtag->flags |=3D PF_TAG_FRAGCACHE;
 #else
 			m->m_pkthdr.pf.flags |=3D PF_TAG_FRAGCACHE;
@@ -1674,7 +1675,7 @@
=20
 	/* copy back packet headers if we sanitized */
 	if (rewrite)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m_copyback(m, off, sizeof(*th), (caddr_t)th);
 #else
 		m_copyback(m, off, sizeof(*th), th);
@@ -1697,7 +1698,7 @@
 	u_int8_t hdr[60];
 	u_int8_t *opt;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((src->scrub =3D=3D NULL),=20
 	    ("pf_normalize_tcp_init: src->scrub !=3D NULL"));
=20
@@ -1782,7 +1783,7 @@
 void
 pf_normalize_tcp_cleanup(struct pf_state *state)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (state->src.scrub)
 		pool_put(&V_pf_state_scrub_pl, state->src.scrub);
 	if (state->dst.scrub)
@@ -1810,7 +1811,7 @@
 	int copyback =3D 0;
 	int got_ts =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((src->scrub || dst->scrub),=20
 	    ("pf_normalize_tcp_statefull: src->scrub && dst->scrub!"));
 #else
@@ -1870,7 +1871,7 @@
=20
 				if (got_ts) {
 					/* Huh?  Multiple timestamps!? */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 					if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -1943,7 +1944,7 @@
 	if (src->scrub && (src->scrub->pfss_flags & PFSS_PAWS) &&
 	    (uptime.tv_sec - src->scrub->pfss_last.tv_sec > TS_MAX_IDLE ||
 	    time_second - state->creation > TS_MAX_CONN))  {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -1957,7 +1958,7 @@
 	}
 	if (dst->scrub && (dst->scrub->pfss_flags & PFSS_PAWS) &&
 	    uptime.tv_sec - dst->scrub->pfss_last.tv_sec > TS_MAX_IDLE) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -2045,7 +2046,7 @@
 		 * this packet.
 		 */
 		if ((ts_fudge =3D state->rule.ptr->timeout[PFTM_TS_DIFF]) =3D=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			ts_fudge =3D V_pf_default_rule.timeout[PFTM_TS_DIFF];
 #else
 			ts_fudge =3D pf_default_rule.timeout[PFTM_TS_DIFF];
@@ -2055,7 +2056,7 @@
 		/* Calculate max ticks since the last timestamp */
 #define TS_MAXFREQ	1100		/* RFC max TS freq of 1Khz + 10% skew */
 #define TS_MICROSECS	1000000		/* microseconds per second */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifndef timersub
 #define	timersub(tvp, uvp, vvp)						\
 	do {								\
@@ -2092,7 +2093,7 @@
 			    tsval_from_last) ? '1' : ' ',
 			    SEQ_GT(tsecr, dst->scrub->pfss_tsval) ? '2' : ' ',
 			    SEQ_LT(tsecr, dst->scrub->pfss_tsval0)? '3' : ' '));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			DPFPRINTF((" tsval: %u  tsecr: %u  +ticks: %u  "
 			    "idle: %jus %lums\n",
 			    tsval, tsecr, tsval_from_last,
@@ -2114,7 +2115,7 @@
 			    "\n", dst->scrub->pfss_tsval,
 			    dst->scrub->pfss_tsecr, dst->scrub->pfss_tsval0));
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -2166,7 +2167,7 @@
 			 * Hey!  Someone tried to sneak a packet in.  Or the
 			 * stack changed its RFC1323 behavior?!?!
 			 */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -2197,7 +2198,7 @@
 			src->scrub->pfss_flags |=3D PFSS_DATA_TS;
 		else {
 			src->scrub->pfss_flags |=3D PFSS_DATA_NOTS;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC && dst->scrub &&
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC && dst->scrub &&
@@ -2255,7 +2256,7 @@
 	int		 thoff;
 	int		 opt, cnt, optlen =3D 0;
 	int		 rewrite =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	u_char		 opts[TCP_MAXOLEN];
 #else
 	u_char		 opts[MAX_TCPOPTLEN];
Index: sys/contrib/pf/net/pf.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
--- sys/contrib/pf/net/pf.c	(revision 230747)
+++ sys/contrib/pf/net/pf.c	(working copy)
@@ -35,7 +35,9 @@
  *
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include "opt_inet.h"
 #include "opt_inet6.h"
=20
@@ -43,7 +45,7 @@
 __FBSDID("$FreeBSD$");
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include "opt_bpf.h"
 #include "opt_pf.h"
=20
@@ -62,7 +64,6 @@
 #include "pflow.h"
 #endif
=20
-#include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
 #include <sys/filio.h>
@@ -70,7 +71,7 @@
 #include <sys/socketvar.h>
 #include <sys/kernel.h>
 #include <sys/time.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/random.h>
 #include <sys/sysctl.h>
 #include <sys/endian.h>
@@ -79,7 +80,7 @@
 #include <sys/pool.h>
 #endif
 #include <sys/proc.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/kthread.h>
 #include <sys/lock.h>
 #include <sys/sx.h>
@@ -87,7 +88,7 @@
 #include <sys/rwlock.h>
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/md5.h>
 #else
 #include <crypto/md5.h>
@@ -97,7 +98,7 @@
 #include <net/if_types.h>
 #include <net/bpf.h>
 #include <net/route.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef RADIX_MPATH
 #include <net/radix_mpath.h>
 #endif
@@ -120,12 +121,12 @@
 #include <netinet/udp_var.h>
 #include <netinet/icmp_var.h>
 #include <netinet/if_ether.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <netinet/ip_fw.h>
 #include <netinet/ipfw/ip_fw_private.h> /* XXX: only for DIR_IN/DIR_OUT */
 #endif
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <dev/rndvar.h>
 #endif
 #include <net/pfvar.h>
@@ -138,13 +139,13 @@
 #include <netinet/in_pcb.h>
 #include <netinet/icmp6.h>
 #include <netinet6/nd6.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <netinet6/ip6_var.h>
 #include <netinet6/in6_pcb.h>
 #endif
 #endif /* INET6 */
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <machine/in_cksum.h>
 #include <sys/limits.h>
 #include <sys/ucred.h>
@@ -153,7 +154,7 @@
 extern int ip_optcopy(struct ip *, struct ip *);
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define	DPFPRINTF(n, x)	if (V_pf_status.debug >=3D (n)) printf x
 #else
 #define	DPFPRINTF(n, x)	if (pf_status.debug >=3D (n)) printf x
@@ -164,7 +165,7 @@
  */
=20
 /* state tables */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 VNET_DEFINE(struct pf_state_tree,	 pf_statetbl);
=20
 VNET_DEFINE(struct pf_altqqueue,	 pf_altqs[2]);
@@ -252,7 +253,7 @@
 			    struct pf_addr *, struct pf_addr *, u_int16_t,
 			    u_int16_t *, u_int16_t *, u_int16_t *,
 			    u_int16_t *, u_int8_t, sa_family_t);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void			 pf_send_tcp(struct mbuf *,
 			    const struct pf_rule *, sa_family_t,
 #else
@@ -270,7 +271,7 @@
 int			 pf_test_rule(struct pf_rule **, struct pf_state **,
 			    int, struct pfi_kif *, struct mbuf *, int,
 			    void *, struct pf_pdesc *, struct pf_rule **,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    struct pf_ruleset **, struct ifqueue *,
 			    struct inpcb *);
 #else
@@ -312,7 +313,7 @@
 void			 pf_route6(struct mbuf **, struct pf_rule *, int,
 			    struct ifnet *, struct pf_state *,
 			    struct pf_pdesc *);
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 int			 pf_socket_lookup(int, struct pf_pdesc *);
 #endif
 u_int8_t		 pf_get_wscale(struct mbuf *, int, u_int16_t,
@@ -325,7 +326,7 @@
 			    struct pf_addr *);
 int			 pf_check_proto_cksum(struct mbuf *, int, int,
 			    u_int8_t, sa_family_t);
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 struct pf_divert	*pf_get_divert(struct mbuf *);
 #endif
 void			 pf_print_state_parts(struct pf_state *,
@@ -334,7 +335,7 @@
 			    struct pf_addr_wrap *);
 int			 pf_compare_state_keys(struct pf_state_key *,
 			    struct pf_state_key *, struct pfi_kif *, u_int);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 struct pf_state		*pf_find_state(struct pfi_kif *,
 			    struct pf_state_key_cmp *, u_int, struct mbuf *,
 			    struct pf_mtag *);
@@ -345,7 +346,7 @@
 int			 pf_src_connlimit(struct pf_state **);
 int			 pf_check_congestion(struct ifqueue *);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 int in4_cksum(struct mbuf *m, u_int8_t nxt, int off, int len);
=20
 VNET_DECLARE(int, pf_end_threads);
@@ -364,7 +365,7 @@
 };
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define	PPACKET_LOOPED()						\
 	(pd->pf_mtag->flags & PF_PACKET_LOOPED)
=20
@@ -404,7 +405,7 @@
 	} while (0)
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define	BOUND_IFACE(r, k) \
 	((r)->rule_flag & PFRULE_IFBOUND) ? (k) : V_pfi_all
 #else
@@ -441,7 +442,7 @@
 static __inline int pf_state_compare_id(struct pf_state *,
 	struct pf_state *);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 VNET_DEFINE(struct pf_src_tree,	 	 tree_src_tracking);
=20
 VNET_DEFINE(struct pf_state_tree_id,	 tree_id);
@@ -564,7 +565,7 @@
 	if ((*state)->rule.ptr->max_src_conn &&
 	    (*state)->rule.ptr->max_src_conn <
 	    (*state)->src_node->conn) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.lcounters[LCNT_SRCCONN]++;
 #else
 		pf_status.lcounters[LCNT_SRCCONN]++;
@@ -574,7 +575,7 @@
=20
 	if ((*state)->rule.ptr->max_src_conn_rate.limit &&
 	    pf_check_threshold(&(*state)->src_node->conn_rate)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.lcounters[LCNT_SRCCONNRATE]++;
 #else
 		pf_status.lcounters[LCNT_SRCCONNRATE]++;
@@ -589,7 +590,7 @@
 		struct pfr_addr p;
 		u_int32_t	killed =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.lcounters[LCNT_OVERLOAD_TABLE]++;
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
@@ -626,7 +627,7 @@
 			struct pf_state_key *sk;
 			struct pf_state *st;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			V_pf_status.lcounters[LCNT_OVERLOAD_FLUSH]++;
 			RB_FOREACH(st, pf_state_tree_id, &V_tree_id) {
 #else
@@ -656,14 +657,14 @@
 					killed++;
 				}
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC)
 #endif
 				printf(", %u states killed", killed);
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC)
@@ -691,7 +692,7 @@
 			k.rule.ptr =3D rule;
 		else
 			k.rule.ptr =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.scounters[SCNT_SRC_NODE_SEARCH]++;
 		*sn =3D RB_FIND(pf_src_tree, &V_tree_src_tracking, &k);
 #else
@@ -702,13 +703,13 @@
 	if (*sn =3D=3D NULL) {
 		if (!rule->max_src_nodes ||
 		    rule->src_nodes < rule->max_src_nodes)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			(*sn) =3D pool_get(&V_pf_src_tree_pl, PR_NOWAIT | PR_ZERO);
 #else
 			(*sn) =3D pool_get(&pf_src_tree_pl, PR_NOWAIT | PR_ZERO);
 #endif
 		else
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			V_pf_status.lcounters[LCNT_SRCNODES]++;
 #else
 			pf_status.lcounters[LCNT_SRCNODES]++;
@@ -728,7 +729,7 @@
 			(*sn)->rule.ptr =3D NULL;
 		PF_ACPY(&(*sn)->addr, src, af);
 		if (RB_INSERT(pf_src_tree,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    &V_tree_src_tracking, *sn) !=3D NULL) {
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
@@ -739,7 +740,7 @@
 				pf_print_host(&(*sn)->addr, 0, af);
 				printf("\n");
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_src_tree_pl, *sn);
 #else
 			pool_put(&pf_src_tree_pl, *sn);
@@ -750,7 +751,7 @@
 		(*sn)->ruletype =3D rule->action;
 		if ((*sn)->rule.ptr !=3D NULL)
 			(*sn)->rule.ptr->src_nodes++;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.scounters[SCNT_SRC_NODE_INSERT]++;
 		V_pf_status.src_nodes++;
 #else
@@ -760,7 +761,7 @@
 	} else {
 		if (rule->max_src_states &&
 		    (*sn)->states >=3D rule->max_src_states) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			V_pf_status.lcounters[LCNT_SRCSTATES]++;
 #else
 			pf_status.lcounters[LCNT_SRCSTATES]++;
@@ -863,13 +864,13 @@
 	struct pf_state_key	*cur;
 	struct pf_state		*olds =3D NULL;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT(s->key[idx] =3D=3D NULL, ("%s: key is null!", __FUNCTION__));
 #else
 	KASSERT(s->key[idx] =3D=3D NULL);	/* XXX handle this? */
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((cur =3D RB_INSERT(pf_state_tree, &V_pf_statetbl, sk)) !=3D NULL) {
 #else
 	if ((cur =3D RB_INSERT(pf_state_tree, &pf_statetbl, sk)) !=3D NULL) {
@@ -886,7 +887,7 @@
 					/* unlink late or sks can go away */
 					olds =3D si->s;
 				} else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 					if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -909,7 +910,7 @@
 						    sk : NULL);
 						printf("\n");
 					}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					pool_put(&V_pf_state_key_pl, sk);
 #else
 					pool_put(&pf_state_key_pl, sk);
@@ -917,7 +918,7 @@
 					return (-1);	/* collision! */
 				}
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_state_key_pl, sk);
 #else
 		pool_put(&pf_state_key_pl, sk);
@@ -926,7 +927,7 @@
 	} else
 		s->key[idx] =3D sk;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((si =3D pool_get(&V_pf_state_item_pl, PR_NOWAIT)) =3D=3D NULL) {
 #else
 	if ((si =3D pool_get(&pf_state_item_pl, PR_NOWAIT)) =3D=3D NULL) {
@@ -937,7 +938,7 @@
 	si->s =3D s;
=20
 	/* list is sorted, if-bound states before floating */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (s->kif =3D=3D V_pfi_all)
 #else
 	if (s->kif =3D=3D pfi_all)
@@ -976,7 +977,7 @@
=20
 	if (si) {
 		TAILQ_REMOVE(&s->key[idx]->states, si, entry);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_state_item_pl, si);
 #else
 		pool_put(&pf_state_item_pl, si);
@@ -984,20 +985,20 @@
 	}
=20
 	if (TAILQ_EMPTY(&s->key[idx]->states)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_REMOVE(pf_state_tree, &V_pf_statetbl, s->key[idx]);
 #else
 		RB_REMOVE(pf_state_tree, &pf_statetbl, s->key[idx]);
 #endif
 		if (s->key[idx]->reverse)
 			s->key[idx]->reverse->reverse =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX: implement this */
 #else
 		if (s->key[idx]->inp)
 			s->key[idx]->inp->inp_pf_sk =3D NULL;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_state_key_pl, s->key[idx]);
 #else
 		pool_put(&pf_state_key_pl, s->key[idx]);
@@ -1011,7 +1012,7 @@
 {
 	struct pf_state_key	*sk;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((sk =3D pool_get(&V_pf_state_key_pl, pool_flags)) =3D=3D NULL)
 #else
 	if ((sk =3D pool_get(&pf_state_key_pl, pool_flags)) =3D=3D NULL)
@@ -1029,7 +1030,7 @@
 	struct pf_addr *saddr, struct pf_addr *daddr,
 	u_int16_t sport, u_int16_t dport)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT((*skp =3D=3D NULL && *nkp =3D=3D NULL),
 		("%s: skp =3D=3D NULL && nkp =3D=3D NULL", __FUNCTION__));
 #else
@@ -1075,7 +1076,7 @@
 pf_state_insert(struct pfi_kif *kif, struct pf_state_key *skw,
     struct pf_state_key *sks, struct pf_state *s)
 {
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	splassert(IPL_SOFTNET);
 #endif
=20
@@ -1087,7 +1088,7 @@
 		s->key[PF_SK_STACK] =3D s->key[PF_SK_WIRE];
 	} else {
 		if (pf_state_key_attach(skw, s, PF_SK_WIRE)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_state_key_pl, sks);
 #else
 			pool_put(&pf_state_key_pl, sks);
@@ -1101,7 +1102,7 @@
 	}
=20
 	if (s->id =3D=3D 0 && s->creatorid =3D=3D 0) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		s->id =3D htobe64(V_pf_status.stateid++);
 		s->creatorid =3D V_pf_status.hostid;
 #else
@@ -1109,7 +1110,7 @@
 		s->creatorid =3D pf_status.hostid;
 #endif
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (RB_INSERT(pf_state_tree_id, &V_tree_id, s) !=3D NULL) {
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
@@ -1118,7 +1119,7 @@
 #endif
 			printf("pf: state insert failed: "
 			    "id: %016llx creatorid: %08x",
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    (unsigned long long)betoh64(s->id), ntohl(s->creatorid));
 #else
 			    betoh64(s->id), ntohl(s->creatorid));
@@ -1128,7 +1129,7 @@
 		pf_detach_state(s);
 		return (-1);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	TAILQ_INSERT_TAIL(&V_state_list, s, entry_list);
 	V_pf_status.fcounters[FCNT_STATE_INSERT]++;
 	V_pf_status.states++;
@@ -1139,7 +1140,7 @@
 #endif
 	pfi_kif_ref(kif, PFI_KIF_REF_STATE);
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pfsync_insert_state_ptr !=3D NULL)
 		pfsync_insert_state_ptr(s);
 #else
@@ -1152,7 +1153,7 @@
 struct pf_state *
 pf_find_state_byid(struct pf_state_cmp *key)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pf_status.fcounters[FCNT_STATE_SEARCH]++;
=20
 	return (RB_FIND(pf_state_tree_id, &V_tree_id, (struct pf_state *)key));
@@ -1195,7 +1196,7 @@
 }
=20
 struct pf_state *
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pf_find_state(struct pfi_kif *kif, struct pf_state_key_cmp *key, u_int dir,
     struct mbuf *m, struct pf_mtag *pftag)
 #else
@@ -1206,18 +1207,18 @@
 	struct pf_state_key	*sk;
 	struct pf_state_item	*si;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pf_status.fcounters[FCNT_STATE_SEARCH]++;
 #else
 	pf_status.fcounters[FCNT_STATE_SEARCH]++;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (dir =3D=3D PF_OUT && pftag->statekey &&
 	    ((struct pf_state_key *)pftag->statekey)->reverse)
 		sk =3D ((struct pf_state_key *)pftag->statekey)->reverse;
 	else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((sk =3D RB_FIND(pf_state_tree, &V_pf_statetbl,
 #else
 		if ((sk =3D RB_FIND(pf_state_tree, &pf_statetbl,
@@ -1237,7 +1238,7 @@
 	    ((struct pf_state_key *)m->m_pkthdr.pf.statekey)->reverse)
 		sk =3D ((struct pf_state_key *)m->m_pkthdr.pf.statekey)->reverse;
 	else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((sk =3D RB_FIND(pf_state_tree, &V_pf_statetbl,
 #else
 		if ((sk =3D RB_FIND(pf_state_tree, &pf_statetbl,
@@ -1255,7 +1256,7 @@
 #endif
=20
 	if (dir =3D=3D PF_OUT)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pftag->statekey =3D NULL;
 #else
 		m->m_pkthdr.pf.statekey =3D NULL;
@@ -1263,7 +1264,7 @@
=20
 	/* list is sorted, if-bound states before floating ones */
 	TAILQ_FOREACH(si, &sk->states, entry)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((si->s->kif =3D=3D V_pfi_all || si->s->kif =3D=3D kif) &&
 #else
 		if ((si->s->kif =3D=3D pfi_all || si->s->kif =3D=3D kif) &&
@@ -1281,13 +1282,13 @@
 	struct pf_state_key	*sk;
 	struct pf_state_item	*si, *ret =3D NULL;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pf_status.fcounters[FCNT_STATE_SEARCH]++;
 #else
 	pf_status.fcounters[FCNT_STATE_SEARCH]++;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	sk =3D RB_FIND(pf_state_tree, &V_pf_statetbl, (struct pf_state_key *)key);
 #else
 	sk =3D RB_FIND(pf_state_tree, &pf_statetbl, (struct pf_state_key *)key);
@@ -1316,7 +1317,7 @@
 pf_purge_thread(void *v)
 {
 	int nloops =3D 0, s;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	int locked;
 #endif
=20
@@ -1325,7 +1326,7 @@
 	for (;;) {
 		tsleep(pf_purge_thread, PWAIT, "pftm", 1 * hz);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		sx_slock(&V_pf_consistency_lock);
 		PF_LOCK();
 		locked =3D 0;
@@ -1350,7 +1351,7 @@
 		s =3D splsoftnet();
=20
 		/* process a fraction of the state table every second */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (!pf_purge_expired_states(1 + (V_pf_status.states /
 		    V_pf_default_rule.timeout[PFTM_INTERVAL]), 0)) {
 			PF_UNLOCK();
@@ -1368,7 +1369,7 @@
 #endif
=20
 		/* purge other expired types every PFTM_INTERVAL seconds */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (++nloops >=3D V_pf_default_rule.timeout[PFTM_INTERVAL]) {
 #else
 		if (++nloops >=3D pf_default_rule.timeout[PFTM_INTERVAL]) {
@@ -1379,7 +1380,7 @@
 		}
=20
 		splx(s);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 		if (locked)
 			sx_xunlock(&V_pf_consistency_lock);
@@ -1403,7 +1404,7 @@
 		return (time_second);
 	if (state->timeout =3D=3D PFTM_UNTIL_PACKET)
 		return (0);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT(state->timeout !=3D PFTM_UNLINKED,
 	    ("pf_state_expires: timeout =3D=3D PFTM_UNLINKED"));
 	KASSERT((state->timeout < PFTM_MAX),=20
@@ -1414,7 +1415,7 @@
 #endif
 	timeout =3D state->rule.ptr->timeout[state->timeout];
 	if (!timeout)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		timeout =3D V_pf_default_rule.timeout[state->timeout];
 #else
 		timeout =3D pf_default_rule.timeout[state->timeout];
@@ -1424,7 +1425,7 @@
 		end =3D state->rule.ptr->timeout[PFTM_ADAPTIVE_END];
 		states =3D state->rule.ptr->states_cur;
 	} else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		start =3D V_pf_default_rule.timeout[PFTM_ADAPTIVE_START];
 		end =3D V_pf_default_rule.timeout[PFTM_ADAPTIVE_END];
 		states =3D V_pf_status.states;
@@ -1444,7 +1445,7 @@
 	return (state->expire + timeout);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 int
 pf_purge_expired_src_nodes(int waslocked)
 #else
@@ -1455,7 +1456,7 @@
 	struct pf_src_node		*cur, *next;
 	int				 locked =3D waslocked;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	for (cur =3D RB_MIN(pf_src_tree, &V_tree_src_tracking); cur; cur =3D next=
) {
 	next =3D RB_NEXT(pf_src_tree, &V_tree_src_tracking, cur);
 #else
@@ -1465,14 +1466,14 @@
=20
 		if (cur->states <=3D 0 && cur->expire <=3D time_second) {
 			if (! locked) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				if (!sx_try_upgrade(&V_pf_consistency_lock))
 					return (0);
 #else
 				rw_enter_write(&pf_consistency_lock);
 #endif
 				next =3D RB_NEXT(pf_src_tree,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    &V_tree_src_tracking, cur);
 #else
 				    &tree_src_tracking, cur);
@@ -1485,7 +1486,7 @@
 				    cur->rule.ptr->max_src_nodes <=3D 0)
 					pf_rm_rule(NULL, cur->rule.ptr);
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			RB_REMOVE(pf_src_tree, &V_tree_src_tracking, cur);
 			V_pf_status.scounters[SCNT_SRC_NODE_REMOVALS]++;
 			V_pf_status.src_nodes--;
@@ -1500,7 +1501,7 @@
 	}
=20
 	if (locked && !waslocked)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	{
 		sx_downgrade(&V_pf_consistency_lock);
 	}
@@ -1522,7 +1523,7 @@
 			timeout =3D s->rule.ptr->timeout[PFTM_SRC_NODE];
 			if (!timeout)
 				timeout =3D
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    V_pf_default_rule.timeout[PFTM_SRC_NODE];
 #else
 				    pf_default_rule.timeout[PFTM_SRC_NODE];
@@ -1535,7 +1536,7 @@
 			timeout =3D s->rule.ptr->timeout[PFTM_SRC_NODE];
 			if (!timeout)
 				timeout =3D
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    V_pf_default_rule.timeout[PFTM_SRC_NODE];
 #else
 				    pf_default_rule.timeout[PFTM_SRC_NODE];
@@ -1550,7 +1551,7 @@
 void
 pf_unlink_state(struct pf_state *cur)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (cur->local_flags & PFSTATE_EXPIRING)
 		return;
 	cur->local_flags |=3D PFSTATE_EXPIRING;
@@ -1560,7 +1561,7 @@
=20
 	if (cur->src.state =3D=3D PF_TCPS_PROXY_DST) {
 		/* XXX wire key the right one? */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_send_tcp(NULL, cur->rule.ptr, cur->key[PF_SK_WIRE]->af,
 #else
 		pf_send_tcp(cur->rule.ptr, cur->key[PF_SK_WIRE]->af,
@@ -1572,14 +1573,14 @@
 		    cur->src.seqhi, cur->src.seqlo + 1,
 		    TH_RST|TH_ACK, 0, 0, 0, 1, cur->tag, NULL, NULL);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_REMOVE(pf_state_tree_id, &V_tree_id, cur);
 #else
 	RB_REMOVE(pf_state_tree_id, &tree_id, cur);
 #endif
 #if NPFLOW > 0
 	if (cur->state_flags & PFSTATE_PFLOW)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (export_pflow_ptr !=3D NULL)
 			export_pflow_ptr(cur);
 #else
@@ -1587,7 +1588,7 @@
 #endif
 #endif
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pfsync_delete_state_ptr !=3D NULL)
 		pfsync_delete_state_ptr(cur);
 #else
@@ -1604,12 +1605,12 @@
 void
 pf_free_state(struct pf_state *cur)
 {
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	splassert(IPL_SOFTNET);
 #endif
=20
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pfsync_state_in_use_ptr !=3D NULL &&
 		pfsync_state_in_use_ptr(cur))
 #else
@@ -1617,7 +1618,7 @@
 #endif
 		return;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT(cur->timeout =3D=3D PFTM_UNLINKED,
 	    ("pf_free_state: cur->timeout !=3D PFTM_UNLINKED"));
 #else
@@ -1635,14 +1636,14 @@
 			pf_rm_rule(NULL, cur->anchor.ptr);
 	pf_normalize_tcp_cleanup(cur);
 	pfi_kif_unref(cur->kif, PFI_KIF_REF_STATE);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	TAILQ_REMOVE(&V_state_list, cur, entry_list);
 #else
 	TAILQ_REMOVE(&state_list, cur, entry_list);
 #endif
 	if (cur->tag)
 		pf_tag_unref(cur->tag);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pool_put(&V_pf_state_pl, cur);
 	V_pf_status.fcounters[FCNT_STATE_REMOVALS]++;
 	V_pf_status.states--;
@@ -1653,7 +1654,7 @@
 #endif
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 int
 pf_purge_expired_states(u_int32_t maxcheck, int waslocked)
 #else
@@ -1663,7 +1664,7 @@
 {
 	static struct pf_state	*cur =3D NULL;
 	struct pf_state		*next;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	int			 locked =3D waslocked;
 #else
 	int			 locked =3D 0;
@@ -1672,7 +1673,7 @@
 	while (maxcheck--) {
 		/* wrap to start of list when we hit the end */
 		if (cur =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			cur =3D TAILQ_FIRST(&V_state_list);
 #else
 			cur =3D TAILQ_FIRST(&state_list);
@@ -1687,7 +1688,7 @@
 		if (cur->timeout =3D=3D PFTM_UNLINKED) {
 			/* free unlinked state */
 			if (! locked) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				if (!sx_try_upgrade(&V_pf_consistency_lock))
 					return (0);
 #else
@@ -1700,7 +1701,7 @@
 			/* unlink and free expired state */
 			pf_unlink_state(cur);
 			if (! locked) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				if (!sx_try_upgrade(&V_pf_consistency_lock))
 					return (0);
 #else
@@ -1713,7 +1714,7 @@
 		cur =3D next;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (!waslocked && locked)
 		sx_downgrade(&V_pf_consistency_lock);
=20
@@ -2200,7 +2201,7 @@
     struct tcphdr *th, struct pf_state_peer *dst)
 {
 	int hlen =3D (th->th_off << 2) - sizeof(*th), thoptlen =3D hlen;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	u_int8_t opts[TCP_MAXOLEN], *opt =3D opts;
 #else
 	u_int8_t opts[MAX_TCPOPTLEN], *opt =3D opts;
@@ -2248,7 +2249,7 @@
 	}
=20
 	if (copyback)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m_copyback(m, off + sizeof(*th), thoptlen, (caddr_t)opts);
 #else
 		m_copyback(m, off + sizeof(*th), thoptlen, opts);
@@ -2257,7 +2258,7 @@
 }
=20
 void
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pf_send_tcp(struct mbuf *replyto, const struct pf_rule *r, sa_family_t af,
 #else
 pf_send_tcp(const struct pf_rule *r, sa_family_t af,
@@ -2277,7 +2278,7 @@
 #endif /* INET6 */
 	struct tcphdr	*th;
 	char		*opt;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pf_mtag  *pf_mtag;
=20
 	KASSERT(
@@ -2325,7 +2326,7 @@
 	m =3D m_gethdr(M_DONTWAIT, MT_HEADER);
 	if (m =3D=3D NULL)
 		return;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef MAC
 	mac_netinet_firewall_send(m);
 #endif
@@ -2335,7 +2336,7 @@
 	}
 #endif
 	if (tag)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m->m_flags |=3D M_SKIP_FIREWALL;
 	pf_mtag->tag =3D rtag;
 #else
@@ -2344,20 +2345,20 @@
 #endif
=20
 	if (r !=3D NULL && r->rtableid >=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	{
 		M_SETFIB(m, r->rtableid);
 		pf_mtag->rtableid =3D r->rtableid;
 #else
 		m->m_pkthdr.pf.rtableid =3D r->rtableid;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	}
 #endif
=20
 #ifdef ALTQ
 	if (r !=3D NULL && r->qid) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_mtag->qid =3D r->qid;
=20
 		/* add hints for ecn */
@@ -2429,7 +2430,7 @@
 		h->ip_v =3D 4;
 		h->ip_hl =3D sizeof(*h) >> 2;
 		h->ip_tos =3D IPTOS_LOWDELAY;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		h->ip_off =3D V_path_mtu_discovery ? IP_DF : 0;
 		h->ip_len =3D len;
 		h->ip_ttl =3D ttl ? ttl : V_ip_defttl;
@@ -2440,7 +2441,7 @@
 #endif
 		h->ip_sum =3D 0;
 		if (eh =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 		ip_output(m, (void *)NULL, (void *)NULL, 0,
 		    (void *)NULL, (void *)NULL);
@@ -2465,7 +2466,7 @@
 			bcopy(eh->ether_dhost, e->ether_shost, ETHER_ADDR_LEN);
 			bcopy(eh->ether_shost, e->ether_dhost, ETHER_ADDR_LEN);
 			e->ether_type =3D eh->ether_type;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_UNLOCK();
 			/* XXX_IMPORT: later */
 			ip_output(m, (void *)NULL, &ro, 0,
@@ -2487,7 +2488,7 @@
 		h6->ip6_vfc |=3D IPV6_VERSION;
 		h6->ip6_hlim =3D IPV6_DEFHLIM;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 		ip6_output(m, NULL, NULL, 0, NULL, NULL, NULL);
 		PF_LOCK();
@@ -2504,14 +2505,14 @@
     struct pf_rule *r)
 {
 	struct mbuf	*m0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef INET
 	struct ip *ip;
 #endif
 	struct pf_mtag *pf_mtag;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	m0 =3D m_copypacket(m, M_DONTWAIT);
 	if (m0 =3D=3D NULL)
 		return;
@@ -2520,7 +2521,7 @@
 		return;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((pf_mtag =3D pf_get_mtag(m0)) =3D=3D NULL)
 		return;
 	/* XXX: revisit */
@@ -2530,20 +2531,20 @@
 #endif
=20
 	if (r->rtableid >=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	{
 		M_SETFIB(m0, r->rtableid);
 		pf_mtag->rtableid =3D r->rtableid;
 #else
 		m0->m_pkthdr.pf.rtableid =3D r->rtableid;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	}
 #endif
=20
 #ifdef ALTQ
 	if (r->qid) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_mtag->qid =3D r->qid;
 		/* add hints for ecn */
 		pf_mtag->hdr =3D mtod(m0, struct ip *);
@@ -2558,7 +2559,7 @@
 	switch (af) {
 #ifdef INET
 	case AF_INET:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		/* icmp_error() expects host byte ordering */
 		ip =3D mtod(m0, struct ip *);
 		NTOHS(ip->ip_len);
@@ -2573,11 +2574,11 @@
 #endif /* INET */
 #ifdef INET6
 	case AF_INET6:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		icmp6_error(m0, type, code, 0);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		break;
@@ -2721,7 +2722,7 @@
 }
=20
 int
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pf_match_tag(struct mbuf *m, struct pf_rule *r, int *tag,
     struct pf_mtag *pf_mtag)
 #else
@@ -2729,7 +2730,7 @@
 #endif
 {
 	if (*tag =3D=3D -1)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		*tag =3D pf_mtag->tag;
 #else
 		*tag =3D m->m_pkthdr.pf.tag;
@@ -2740,7 +2741,7 @@
 }
=20
 int
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pf_tag_packet(struct mbuf *m, int tag, int rtableid,
     struct pf_mtag *pf_mtag)
 #else
@@ -2751,13 +2752,13 @@
 		return (0);
=20
 	if (tag > 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_mtag->tag =3D tag;
 #else
 		m->m_pkthdr.pf.tag =3D tag;
 #endif
 	if (rtableid >=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	{
 		M_SETFIB(m, rtableid);
 	}
@@ -2777,7 +2778,7 @@
 	(*r)->anchor->match =3D 0;
 	if (match)
 		*match =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (*depth >=3D sizeof(V_pf_anchor_stack) /
 	    sizeof(V_pf_anchor_stack[0])) {
 #else
@@ -2789,7 +2790,7 @@
 		return;
 	} else if (*depth =3D=3D 0 && a !=3D NULL)
 		*a =3D *r;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	f =3D V_pf_anchor_stack + (*depth)++;
 #else
 	f =3D pf_anchor_stack + (*depth)++;
@@ -2822,7 +2823,7 @@
 	do {
 		if (*depth <=3D 0)
 			break;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		f =3D V_pf_anchor_stack + *depth - 1;
 #else
 		f =3D pf_anchor_stack + *depth - 1;
@@ -2913,7 +2914,7 @@
 #endif /* INET6 */
=20
 int
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pf_socket_lookup(int direction, struct pf_pdesc *pd, struct inpcb *inp_arg)
 #else
 pf_socket_lookup(int direction, struct pf_pdesc *pd)
@@ -2921,7 +2922,7 @@
 {
 	struct pf_addr		*saddr, *daddr;
 	u_int16_t		 sport, dport;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct inpcbinfo	*pi;
 #else
 	struct inpcbtable	*tb;
@@ -2934,7 +2935,7 @@
 	pd->lookup.gid =3D GID_MAX;
 	pd->lookup.pid =3D NO_PID;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (inp_arg !=3D NULL) {
 		INP_LOCK_ASSERT(inp_arg);
 		pd->lookup.uid =3D inp_arg->inp_cred->cr_uid;
@@ -2949,7 +2950,7 @@
 			return (-1);
 		sport =3D pd->hdr.tcp->th_sport;
 		dport =3D pd->hdr.tcp->th_dport;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pi =3D &V_tcbinfo;
 #else
 		tb =3D &tcbtable;
@@ -2960,7 +2961,7 @@
 			return (-1);
 		sport =3D pd->hdr.udp->uh_sport;
 		dport =3D pd->hdr.udp->uh_dport;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pi =3D &V_udbinfo;
 #else
 		tb =3D &udbtable;
@@ -2984,7 +2985,7 @@
 	switch (pd->af) {
 #ifdef INET
 	case AF_INET:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		/*
 		 * XXXRW: would be nice if we had an mbuf here so that we
 		 * could use in_pcblookup_mbuf().
@@ -3011,7 +3012,7 @@
 #endif /* INET */
 #ifdef INET6
 	case AF_INET6:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		/*
 		 * XXXRW: would be nice if we had an mbuf here so that we
 		 * could use in6_pcblookup_mbuf().
@@ -3041,7 +3042,7 @@
 	default:
 		return (-1);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	INP_RLOCK_ASSERT(inp);
 	pd->lookup.uid =3D inp->inp_cred->cr_uid;
 	pd->lookup.gid =3D inp->inp_cred->cr_groups[0];
@@ -3100,7 +3101,7 @@
 	int		 hlen;
 	u_int8_t	 hdr[60];
 	u_int8_t	*opt, optlen;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	u_int16_t	 mss =3D V_tcp_mssdflt;
 #else
 	u_int16_t	 mss =3D tcp_mssdflt;
@@ -3148,7 +3149,7 @@
 	struct route_in6	 ro6;
 #endif /* INET6 */
 	struct rtentry		*rt =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	int			 hlen =3D 0;
 	u_int16_t		 mss =3D V_tcp_mssdflt;
 #else
@@ -3165,7 +3166,7 @@
 		dst->sin_family =3D AF_INET;
 		dst->sin_len =3D sizeof(*dst);
 		dst->sin_addr =3D addr->v4;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef RTF_PRCLONING
 		rtalloc_ign(&ro, (RTF_CLONING | RTF_PRCLONING));
 #else /* !RTF_PRCLONING */
@@ -3185,7 +3186,7 @@
 		dst6->sin6_family =3D AF_INET6;
 		dst6->sin6_len =3D sizeof(*dst6);
 		dst6->sin6_addr =3D addr->v6;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef RTF_PRCLONING
 		rtalloc_ign((struct route *)&ro6,
 		    (RTF_CLONING | RTF_PRCLONING));
@@ -3202,7 +3203,7 @@
=20
 	if (rt && rt->rt_ifp) {
 		mss =3D rt->rt_ifp->if_mtu - hlen - sizeof(struct tcphdr);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		mss =3D max(V_tcp_mssdflt, mss);
 #else
 		mss =3D max(tcp_mssdflt, mss);
@@ -3245,7 +3246,7 @@
 	MD5_CTX ctx;
 	u_int32_t digest[4];
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (V_pf_tcp_secret_init =3D=3D 0) {
 		read_random(&V_pf_tcp_secret, sizeof(V_pf_tcp_secret));
 		MD5Init(&V_pf_tcp_secret_ctx);
@@ -3277,7 +3278,7 @@
 		MD5Update(&ctx, (char *)&pd->dst->v4, sizeof(struct in_addr));
 	}
 	MD5Final((u_char *)digest, &ctx);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pf_tcp_iss_off +=3D 4096;
 #define	ISN_RANDOM_INCREMENT (4096 - 1)
 	return (digest[0] + (arc4random() & ISN_RANDOM_INCREMENT) +
@@ -3293,7 +3294,7 @@
 pf_test_rule(struct pf_rule **rm, struct pf_state **sm, int direction,
     struct pfi_kif *kif, struct mbuf *m, int off, void *h,
     struct pf_pdesc *pd, struct pf_rule **am, struct pf_ruleset **rsm,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
     struct ifqueue *ifq, struct inpcb *inp)
 #else
     struct ifqueue *ifq)
@@ -3314,7 +3315,7 @@
 	int			 asd =3D 0;
 	int			 match =3D 0;
 	int			 state_icmp =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	u_int16_t		 sport =3D 0, dport =3D 0;
 	u_int16_t		 bproto_sum =3D 0, bip_sum =3D 0;
 #else
@@ -3329,7 +3330,7 @@
 		return (PF_DROP);
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (inp !=3D NULL)
 		pd->lookup.done =3D pf_socket_lookup(direction, pd, inp);
 	else if (V_debug_pfugidhack) {
@@ -3560,7 +3561,7 @@
 			r =3D TAILQ_NEXT(r, entries);
 		/* tcp/udp only. uid.op always 0 in other cases */
 		else if (r->uid.op && (pd->lookup.done || (pd->lookup.done =3D
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    pf_socket_lookup(direction, pd, inp), 1)) &&
 #else
 		    pf_socket_lookup(direction, pd), 1)) &&
@@ -3570,7 +3571,7 @@
 			r =3D TAILQ_NEXT(r, entries);
 		/* tcp/udp only. gid.op always 0 in other cases */
 		else if (r->gid.op && (pd->lookup.done || (pd->lookup.done =3D
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    pf_socket_lookup(direction, pd, inp), 1)) &&
 #else
 		    pf_socket_lookup(direction, pd), 1)) &&
@@ -3579,13 +3580,13 @@
 		    pd->lookup.gid))
 			r =3D TAILQ_NEXT(r, entries);
 		else if (r->prob &&
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    r->prob <=3D arc4random())
 #else
 		    r->prob <=3D arc4random_uniform(UINT_MAX - 1) + 1)
 #endif
 			r =3D TAILQ_NEXT(r, entries);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		else if (r->match_tag && !pf_match_tag(m, r, &tag, pd->pf_mtag))
 #else
 		else if (r->match_tag && !pf_match_tag(m, r, &tag))
@@ -3683,7 +3684,7 @@
 					ack++;
 				if (th->th_flags & TH_FIN)
 					ack++;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pf_send_tcp(m, r, af, pd->dst,
 #else
 				pf_send_tcp(r, af, pd->dst,
@@ -3705,7 +3706,7 @@
 	if (r->action =3D=3D PF_DROP)
 		goto cleanup;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pf_tag_packet(m, tag, rtableid, pd->pf_mtag)) {
 #else
 	if (pf_tag_packet(m, tag, rtableid)) {
@@ -3723,7 +3724,7 @@
 		if (action !=3D PF_PASS)
 			return (action);
 	} else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (sk !=3D NULL)
 			pool_put(&V_pf_state_key_pl, sk);
 		if (nk !=3D NULL)
@@ -3742,7 +3743,7 @@
=20
 #if NPFSYNC > 0
 	if (*sm !=3D NULL && !ISSET((*sm)->state_flags, PFSTATE_NOSYNC) &&
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	    direction =3D=3D PF_OUT && pfsync_up_ptr !=3D NULL && pfsync_up_ptr()=
) {
 #else
 	    direction =3D=3D PF_OUT && pfsync_up()) {
@@ -3753,7 +3754,7 @@
 		 * firewall has to know about it to allow
 		 * replies through it.
 		 */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pfsync_defer_ptr !=3D NULL &&
 			pfsync_defer_ptr(*sm, m))
 #else
@@ -3766,7 +3767,7 @@
 	return (PF_PASS);
=20
 cleanup:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (sk !=3D NULL)
 		pool_put(&V_pf_state_key_pl, sk);
 	if (nk !=3D NULL)
@@ -3791,7 +3792,7 @@
 	struct pf_state		*s =3D NULL;
 	struct pf_src_node	*sn =3D NULL;
 	struct tcphdr		*th =3D pd->hdr.tcp;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	u_int16_t		 mss =3D V_tcp_mssdflt;
 #else
 	u_int16_t		 mss =3D tcp_mssdflt;
@@ -3800,7 +3801,7 @@
=20
 	/* check maximums */
 	if (r->max_states && (r->states_cur >=3D r->max_states)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.lcounters[LCNT_STATES]++;
 #else
 		pf_status.lcounters[LCNT_STATES]++;
@@ -3821,7 +3822,7 @@
 		REASON_SET(&reason, PFRES_SRCLIMIT);
 		goto csfailed;
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	s =3D pool_get(&V_pf_state_pl, PR_NOWAIT | PR_ZERO);
 #else
 	s =3D pool_get(&pf_state_pl, PR_NOWAIT | PR_ZERO);
@@ -3916,7 +3917,7 @@
 			REASON_SET(&reason, PFRES_MEMORY);
 			pf_src_tree_remove_state(s);
 			STATE_DEC_COUNTERS(s);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_state_pl, s);
 #else
 			pool_put(&pf_state_pl, s);
@@ -3932,7 +3933,7 @@
 			pf_normalize_tcp_cleanup(s);
 			pf_src_tree_remove_state(s);
 			STATE_DEC_COUNTERS(s);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_state_pl, s);
 #else
 			pool_put(&pf_state_pl, s);
@@ -3952,7 +3953,7 @@
 		REASON_SET(&reason, PFRES_STATEINS);
 		pf_src_tree_remove_state(s);
 		STATE_DEC_COUNTERS(s);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pf_state_pl, s);
 #else
 		pool_put(&pf_state_pl, s);
@@ -3992,7 +3993,7 @@
 		mss =3D pf_calc_mss(pd->src, pd->af, mss);
 		mss =3D pf_calc_mss(pd->dst, pd->af, mss);
 		s->src.mss =3D mss;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_send_tcp(NULL, r, pd->af, pd->dst, pd->src, th->th_dport,
 #else
 		pf_send_tcp(r, pd->af, pd->dst, pd->src, th->th_dport,
@@ -4006,7 +4007,7 @@
 	return (PF_PASS);
=20
 csfailed:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (sk !=3D NULL)
 		pool_put(&V_pf_state_key_pl, sk);
 	if (nk !=3D NULL)
@@ -4019,7 +4020,7 @@
 #endif
=20
 	if (sn !=3D NULL && sn->states =3D=3D 0 && sn->expire =3D=3D 0) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_REMOVE(pf_src_tree, &V_tree_src_tracking, sn);
 		V_pf_status.scounters[SCNT_SRC_NODE_REMOVALS]++;
 		V_pf_status.src_nodes--;
@@ -4032,7 +4033,7 @@
 #endif
 	}
 	if (nsn !=3D sn && nsn !=3D NULL && nsn->states =3D=3D 0 && nsn->expire =
=3D=3D 0) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_REMOVE(pf_src_tree, &V_tree_src_tracking, nsn);
 		V_pf_status.scounters[SCNT_SRC_NODE_REMOVALS]++;
 		V_pf_status.src_nodes--;
@@ -4094,7 +4095,7 @@
 		else if (r->prob && r->prob <=3D
 		    (arc4random() % (UINT_MAX - 1) + 1))
 			r =3D TAILQ_NEXT(r, entries);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		else if (r->match_tag && !pf_match_tag(m, r, &tag, pd->pf_mtag))
 #else
 		else if (r->match_tag && !pf_match_tag(m, r, &tag))
@@ -4130,7 +4131,7 @@
 	if (r->action !=3D PF_PASS)
 		return (PF_DROP);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pf_tag_packet(m, tag, -1, pd->pf_mtag)) {
 #else
 	if (pf_tag_packet(m, tag, -1)) {
@@ -4389,7 +4390,7 @@
 		 * and keep updating the state TTL.
 		 */
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -4399,7 +4400,7 @@
 			pf_print_flags(th->th_flags);
 			printf(" seq=3D%u (%u) ack=3D%u len=3D%u ackskew=3D%d "
 			    "pkts=3D%llu:%llu dir=3D%s,%s\n", seq, orig_seq, ack,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    pd->p_len, ackskew, (unsigned long long)(*state)->packets[0],
 			    (unsigned long long)(*state)->packets[1],
 #else
@@ -4444,7 +4445,7 @@
 		    (*state)->src.state =3D=3D TCPS_SYN_SENT) {
 			/* Send RST for state mismatches during handshake */
 			if (!(th->th_flags & TH_RST))
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				pf_send_tcp(NULL, (*state)->rule.ptr, pd->af,
 #else
 				pf_send_tcp((*state)->rule.ptr, pd->af,
@@ -4457,7 +4458,7 @@
 			src->seqlo =3D 0;
 			src->seqhi =3D 1;
 			src->max_win =3D 1;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		} else if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 		} else if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -4468,7 +4469,7 @@
 			printf(" seq=3D%u (%u) ack=3D%u len=3D%u ackskew=3D%d "
 			    "pkts=3D%llu:%llu dir=3D%s,%s\n",
 			    seq, orig_seq, ack, pd->p_len, ackskew,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    (unsigned long long)(*state)->packets[0],
 			    (unsigned long long)(*state)->packets[1],
 #else
@@ -4588,7 +4589,7 @@
 		key.port[0] =3D th->th_dport;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 	STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -4614,7 +4615,7 @@
 				REASON_SET(reason, PFRES_SYNPROXY);
 				return (PF_DROP);
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pf_send_tcp(NULL, (*state)->rule.ptr, pd->af, pd->dst,
 #else
 			pf_send_tcp((*state)->rule.ptr, pd->af, pd->dst,
@@ -4648,7 +4649,7 @@
 			(*state)->src.max_win =3D MAX(ntohs(th->th_win), 1);
 			if ((*state)->dst.seqhi =3D=3D 1)
 				(*state)->dst.seqhi =3D htonl(arc4random());
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pf_send_tcp(NULL, (*state)->rule.ptr, pd->af,
 #else
 			pf_send_tcp((*state)->rule.ptr, pd->af,
@@ -4667,7 +4668,7 @@
 		} else {
 			(*state)->dst.max_win =3D MAX(ntohs(th->th_win), 1);
 			(*state)->dst.seqlo =3D ntohl(th->th_seq);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pf_send_tcp(NULL, (*state)->rule.ptr, pd->af, pd->dst,
 #else
 			pf_send_tcp((*state)->rule.ptr, pd->af, pd->dst,
@@ -4676,7 +4677,7 @@
 			    ntohl(th->th_ack), ntohl(th->th_seq) + 1,
 			    TH_ACK, (*state)->src.max_win, 0, 0, 0,
 			    (*state)->tag, NULL, NULL);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pf_send_tcp(NULL, (*state)->rule.ptr, pd->af,
 #else
 			pf_send_tcp((*state)->rule.ptr, pd->af,
@@ -4705,7 +4706,7 @@
 	if (((th->th_flags & (TH_SYN|TH_ACK)) =3D=3D TH_SYN) &&
 	    dst->state >=3D TCPS_FIN_WAIT_2 &&
 	    src->state >=3D TCPS_FIN_WAIT_2) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -4751,7 +4752,7 @@
=20
 	/* Copyback sequence modulation or stateful scrub changes if needed */
 	if (copyback)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m_copyback(m, off, sizeof(*th), (caddr_t)th);
 #else
 		m_copyback(m, off, sizeof(*th), th);
@@ -4782,7 +4783,7 @@
 		key.port[0] =3D uh->uh_dport;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 	STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -4824,7 +4825,7 @@
 			pf_change_ap(pd->dst, &uh->uh_dport, pd->ip_sum,
 			    &uh->uh_sum, &nk->addr[pd->didx],
 			    nk->port[pd->didx], 1, pd->af);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m_copyback(m, off, sizeof(*uh), (caddr_t)uh);
 #else
 		m_copyback(m, off, sizeof(*uh), uh);
@@ -4839,7 +4840,7 @@
     struct mbuf *m, int off, void *h, struct pf_pdesc *pd, u_short *reason)
 {
 	struct pf_addr  *saddr =3D pd->src, *daddr =3D pd->dst;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	u_int16_t	 icmpid =3D 0, *icmpsum;
 #else
 	u_int16_t	 icmpid, *icmpsum;
@@ -4895,7 +4896,7 @@
 			PF_ACPY(&key.addr[0], pd->dst, key.af);
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 		STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -4934,7 +4935,7 @@
 				}
=20
 				m_copyback(m, off, ICMP_MINLEN,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    (caddr_t)
 #endif
 				    pd->hdr.icmp);
@@ -4956,7 +4957,7 @@
=20
 				m_copyback(m, off,
 				    sizeof(struct icmp6_hdr),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    (caddr_t)
 #endif
 				    pd->hdr.icmp6);
@@ -4973,7 +4974,7 @@
 		 */
=20
 		struct pf_pdesc	pd2;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		bzero(&pd2, sizeof pd2);
 #endif
 #ifdef INET
@@ -4983,7 +4984,7 @@
 		struct ip6_hdr	h2_6;
 		int		terminal =3D 0;
 #endif /* INET6 */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		int		ipoff2 =3D 0;
 		int		off2 =3D 0;
 #else
@@ -5110,7 +5111,7 @@
 			key.port[pd2.sidx] =3D th.th_sport;
 			key.port[pd2.didx] =3D th.th_dport;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 			STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -5140,7 +5141,7 @@
 			if (!((*state)->state_flags & PFSTATE_SLOPPY) &&
 			    (!SEQ_GEQ(src->seqhi, seq) ||
 			    !SEQ_GEQ(seq, src->seqlo - (dst->max_win << dws)))) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 				if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -5157,7 +5158,7 @@
 				REASON_SET(reason, PFRES_BADSTATE);
 				return (PF_DROP);
 			} else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 				if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -5205,12 +5206,12 @@
 #ifdef INET
 				case AF_INET:
 					m_copyback(m, off, ICMP_MINLEN,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    pd->hdr.icmp);
 					m_copyback(m, ipoff2, sizeof(h2),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    &h2);
@@ -5220,19 +5221,19 @@
 				case AF_INET6:
 					m_copyback(m, off,
 					    sizeof(struct icmp6_hdr),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    pd->hdr.icmp6);
 					m_copyback(m, ipoff2, sizeof(h2_6),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    &h2_6);
 					break;
 #endif /* INET6 */
 				}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				m_copyback(m, off2, 8, (caddr_t)&th);
 #else
 				m_copyback(m, off2, 8, &th);
@@ -5260,7 +5261,7 @@
 			key.port[pd2.sidx] =3D uh.uh_sport;
 			key.port[pd2.didx] =3D uh.uh_dport;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 			STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -5295,11 +5296,11 @@
 #ifdef INET
 				case AF_INET:
 					m_copyback(m, off, ICMP_MINLEN,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    pd->hdr.icmp);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					m_copyback(m, ipoff2, sizeof(h2), (caddr_t)&h2);
 #else
 					m_copyback(m, ipoff2, sizeof(h2), &h2);
@@ -5310,19 +5311,19 @@
 				case AF_INET6:
 					m_copyback(m, off,
 					    sizeof(struct icmp6_hdr),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    pd->hdr.icmp6);
 					m_copyback(m, ipoff2, sizeof(h2_6),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    &h2_6);
 					break;
 #endif /* INET6 */
 				}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				m_copyback(m, off2, sizeof(uh), (caddr_t)&uh);
 #else
 				m_copyback(m, off2, sizeof(uh), &uh);
@@ -5349,7 +5350,7 @@
 			PF_ACPY(&key.addr[pd2.didx], pd2.dst, key.af);
 			key.port[0] =3D key.port[1] =3D iih.icmp_id;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 			STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -5380,7 +5381,7 @@
 					    pd2.ip_sum, icmpsum,
 					    pd->ip_sum, 0, AF_INET);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				m_copyback(m, off, ICMP_MINLEN, (caddr_t)pd->hdr.icmp);
 				m_copyback(m, ipoff2, sizeof(h2), (caddr_t)&h2);
 				m_copyback(m, off2, ICMP_MINLEN, (caddr_t)&iih);
@@ -5412,7 +5413,7 @@
 			PF_ACPY(&key.addr[pd2.didx], pd2.dst, key.af);
 			key.port[0] =3D key.port[1] =3D iih.icmp6_id;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 			STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -5443,7 +5444,7 @@
 					    pd2.ip_sum, icmpsum,
 					    pd->ip_sum, 0, AF_INET6);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				m_copyback(m, off, sizeof(struct icmp6_hdr),
 				    (caddr_t)pd->hdr.icmp6);
 				m_copyback(m, ipoff2, sizeof(h2_6), (caddr_t)&h2_6);
@@ -5468,7 +5469,7 @@
 			PF_ACPY(&key.addr[pd2.didx], pd2.dst, key.af);
 			key.port[0] =3D key.port[1] =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 			STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -5498,7 +5499,7 @@
 				switch (pd2.af) {
 #ifdef INET
 				case AF_INET:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					m_copyback(m, off, ICMP_MINLEN,
 					    (caddr_t)pd->hdr.icmp);
 					m_copyback(m, ipoff2, sizeof(h2), (caddr_t)&h2);
@@ -5513,12 +5514,12 @@
 				case AF_INET6:
 					m_copyback(m, off,
 					    sizeof(struct icmp6_hdr),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    pd->hdr.icmp6);
 					m_copyback(m, ipoff2, sizeof(h2_6),
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 					    (caddr_t)
 #endif
 					    &h2_6);
@@ -5552,7 +5553,7 @@
 		key.port[1] =3D key.port[0] =3D 0;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	STATE_LOOKUP(kif, &key, direction, *state, m, pd->pf_mtag);
 #else
 	STATE_LOOKUP(kif, &key, direction, *state, m);
@@ -5583,7 +5584,7 @@
 	if ((*state)->key[PF_SK_WIRE] !=3D (*state)->key[PF_SK_STACK]) {
 		struct pf_state_key *nk =3D (*state)->key[pd->didx];
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		KASSERT(nk, ("%s: nk is null", __FUNCTION__));
 		KASSERT(pd, ("%s: pd is null", __FUNCTION__));
 		KASSERT(pd->src, ("%s: pd->src is null", __FUNCTION__));
@@ -5679,7 +5680,7 @@
 int
 pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *kif)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef RADIX_MPATH
 	struct radix_node_head	*rnh;
 #endif
@@ -5687,11 +5688,11 @@
 	struct sockaddr_in	*dst;
 	int			 ret =3D 1;
 	int			 check_mpath;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	extern int		 ipmultipath;
 #endif
 #ifdef INET6
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	extern int		 ip6_multipath;
 #endif
 	struct sockaddr_in6	*dst6;
@@ -5704,7 +5705,7 @@
 	struct ifnet		*ifp;
=20
 	check_mpath =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef RADIX_MPATH
 	/* XXX: stick to table 0 for now */
 	rnh =3D rt_tables_get_rnh(0, af);
@@ -5719,7 +5720,7 @@
 		dst->sin_family =3D AF_INET;
 		dst->sin_len =3D sizeof(*dst);
 		dst->sin_addr =3D addr->v4;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 		if (ipmultipath)
 			check_mpath =3D 1;
 #endif
@@ -5736,7 +5737,7 @@
 		dst6->sin6_family =3D AF_INET6;
 		dst6->sin6_len =3D sizeof(*dst6);
 		dst6->sin6_addr =3D addr->v6;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 		if (ip6_multipath)
 			check_mpath =3D 1;
 #endif
@@ -5750,7 +5751,7 @@
 	if (kif !=3D NULL && kif->pfik_ifp->if_type =3D=3D IFT_ENC)
 		goto out;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 /* XXX MRT not always INET */ /* stick with table 0 though */
 #ifdef INET
 	if (af =3D=3D AF_INET)
@@ -5777,7 +5778,7 @@
 		rn =3D (struct radix_node *)ro.ro_rt;
 		do {
 			rt =3D (struct rtentry *)rn;
-#ifndef __FreeBSD__ /* CARPDEV */
+#ifndef __FreeBSD_kernel__ /* CARPDEV */
 			if (rt->rt_ifp->if_type =3D=3D IFT_CARP)
 				ifp =3D rt->rt_ifp->if_carpdev;
 			else
@@ -5786,7 +5787,7 @@
=20
 			if (kif->pfik_ifp =3D=3D ifp)
 				ret =3D 1;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef RADIX_MPATH
 			rn =3D rn_mpath_next(rn);
 #endif
@@ -5834,7 +5835,7 @@
 		return (0);
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 # ifdef RTF_PRCLONING
 	rtalloc_ign((struct route *)&ro, (RTF_CLONING|RTF_PRCLONING));
 # else /* !RTF_PRCLONING */
@@ -5850,7 +5851,7 @@
 #endif
=20
 	if (ro.ro_rt !=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		/* XXX_IMPORT: later */
 #else
 		if (ro.ro_rt->rt_labelid =3D=3D aw->v.rtlabel)
@@ -5876,7 +5877,7 @@
 	struct pf_addr		 naddr;
 	struct pf_src_node	*sn =3D NULL;
 	int			 error =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	int sw_csum;
 #endif
 #ifdef IPSEC
@@ -5887,7 +5888,7 @@
 	    (dir !=3D PF_IN && dir !=3D PF_OUT) || oifp =3D=3D NULL)
 		panic("pf_route: invalid parameters");
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pd->pf_mtag->routed++ > 3) {
 #else
 	if ((*m)->m_pkthdr.pf.routed++ > 3) {
@@ -5898,7 +5899,7 @@
 	}
=20
 	if (r->rt =3D=3D PF_DUPTO) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((m0 =3D m_dup(*m, M_DONTWAIT)) =3D=3D NULL)
 #else
 		if ((m0 =3D m_copym2(*m, 0, M_COPYALL, M_NOWAIT)) =3D=3D NULL)
@@ -5926,13 +5927,13 @@
 	dst->sin_addr =3D ip->ip_dst;
=20
 	if (r->rt =3D=3D PF_FASTROUTE) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		in_rtalloc(ro, 0);
 #else
 		rtalloc(ro);
 #endif
 		if (ro->ro_rt =3D=3D 0) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			KMOD_IPSTAT_INC(ips_noroute);
 #else
 			ipstat.ips_noroute++;
@@ -5969,7 +5970,7 @@
 		goto bad;
=20
 	if (oifp !=3D ifp) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 		if (pf_test(PF_OUT, ifp, &m0, NULL, NULL) !=3D PF_PASS) {
 			PF_LOCK();
@@ -5993,7 +5994,7 @@
 		ip =3D mtod(m0, struct ip *);
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* Copied from FreeBSD 5.1-CURRENT ip_output. */
 	m0->m_pkthdr.csum_flags |=3D CSUM_IP;
 	sw_csum =3D m0->m_pkthdr.csum_flags & ~ifp->if_hwassist;
@@ -6067,7 +6068,7 @@
 		if ((ifp->if_capabilities & IFCAP_CSUM_IPv4) &&
 		    ifp->if_bridge =3D=3D NULL) {
 			m0->m_pkthdr.csum_flags |=3D M_IPV4_CSUM_OUT;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			KMOD_IPSTAT_INC(ips_outhwcsum);
 #else
 			ipstat.ips_outhwcsum++;
@@ -6089,13 +6090,13 @@
 	 * Must be able to put at least 8 bytes per fragment.
 	 */
 	if (ip->ip_off & htons(IP_DF)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		KMOD_IPSTAT_INC(ips_cantfrag);
 #else
 		ipstat.ips_cantfrag++;
 #endif
 		if (r->rt !=3D PF_DUPTO) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			/* icmp_error() expects host byte ordering */
 			NTOHS(ip->ip_len);
 			NTOHS(ip->ip_off);
@@ -6113,7 +6114,7 @@
 	}
=20
 	m1 =3D m0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/*
 	 * XXX: is cheaper + less error prone than own function
 	 */
@@ -6124,7 +6125,7 @@
 	error =3D ip_fragment(m0, ifp, ifp->if_mtu);
 #endif
 	if (error) {
-#ifndef __FreeBSD__    /* ip_fragment does not do m_freem() on FreeBSD */
+#ifndef __FreeBSD_kernel__    /* ip_fragment does not do m_freem() on Free=
BSD */
 		m0 =3D NULL;
 #endif
 		goto bad;
@@ -6133,7 +6134,7 @@
 	for (m0 =3D m1; m0; m0 =3D m1) {
 		m1 =3D m0->m_nextpkt;
 		m0->m_nextpkt =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (error =3D=3D 0) {
 			PF_UNLOCK();
 			error =3D (*ifp->if_output)(ifp, m0, sintosa(dst),
@@ -6150,7 +6151,7 @@
 	}
=20
 	if (error =3D=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		KMOD_IPSTAT_INC(ips_fragmented);
 #else
 		ipstat.ips_fragmented++;
@@ -6187,7 +6188,7 @@
 	    (dir !=3D PF_IN && dir !=3D PF_OUT) || oifp =3D=3D NULL)
 		panic("pf_route6: invalid parameters");
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pd->pf_mtag->routed++ > 3) {
 #else
 	if ((*m)->m_pkthdr.pf.routed++ > 3) {
@@ -6198,7 +6199,7 @@
 	}
=20
 	if (r->rt =3D=3D PF_DUPTO) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((m0 =3D m_dup(*m, M_DONTWAIT)) =3D=3D NULL)
 #else
 		if ((m0 =3D m_copym2(*m, 0, M_COPYALL, M_NOWAIT)) =3D=3D NULL)
@@ -6226,7 +6227,7 @@
=20
 	/* Cheat. XXX why only in the v6 case??? */
 	if (r->rt =3D=3D PF_FASTROUTE) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m0->m_flags |=3D M_SKIP_FIREWALL;
 		PF_UNLOCK();
 		ip6_output(m0, NULL, NULL, 0, NULL, NULL, NULL);
@@ -6259,7 +6260,7 @@
 		goto bad;
=20
 	if (oifp !=3D ifp) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 		if (pf_test6(PF_OUT, ifp, &m0, NULL, NULL) !=3D PF_PASS) {
 			PF_LOCK();
@@ -6290,16 +6291,16 @@
 	if (IN6_IS_SCOPE_EMBED(&dst->sin6_addr))
 		dst->sin6_addr.s6_addr16[1] =3D htons(ifp->if_index);
 	if ((u_long)m0->m_pkthdr.len <=3D ifp->if_mtu) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		nd6_output(ifp, ifp, m0, dst, NULL);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 	} else {
 		in6_ifstat_inc(ifp, ifs6_in_toobig);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (r->rt !=3D PF_DUPTO) {
 			PF_UNLOCK();
 			icmp6_error(m0, ICMP6_PACKET_TOO_BIG, 0, ifp->if_mtu);
@@ -6324,7 +6325,7 @@
 }
 #endif /* INET6 */
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 /*
  * FreeBSD supports cksum offloads for the following drivers.
  *  em(4), fxp(4), ixgb(4), lge(4), ndis(4), nge(4), re(4),
@@ -6554,7 +6555,7 @@
 }
 #endif
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 struct pf_divert *
 pf_find_divert(struct mbuf *m)
 {
@@ -6586,7 +6587,7 @@
=20
 #ifdef INET
 int
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pf_test(int dir, struct ifnet *ifp, struct mbuf **m0,
     struct ether_header *eh, struct inpcb *inp)
 #else
@@ -6597,7 +6598,7 @@
 	struct pfi_kif		*kif;
 	u_short			 action, reason =3D 0, log =3D 0;
 	struct mbuf		*m =3D *m0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct ip		*h =3D NULL;
 	struct m_tag		*ipfwtag;
 	struct pf_rule		*a =3D NULL, *r =3D &V_pf_default_rule, *tr, *nr;
@@ -6610,7 +6611,7 @@
 	struct pf_pdesc		 pd;
 	int			 off, dirndx, pqid =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 	if (!V_pf_status.running)
 	{
@@ -6623,7 +6624,7 @@
 #endif
=20
 	memset(&pd, 0, sizeof(pd));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((pd.pf_mtag =3D pf_get_mtag(m)) =3D=3D NULL) {
 		PF_UNLOCK();
 		DPFPRINTF(PF_DEBUG_URGENT,
@@ -6631,7 +6632,7 @@
 		return (PF_DROP);
 	}
 #endif
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	if (ifp->if_type =3D=3D IFT_CARP && ifp->if_carpdev)
 		kif =3D (struct pfi_kif *)ifp->if_carpdev->if_pf_kif;
 	else
@@ -6639,7 +6640,7 @@
 		kif =3D (struct pfi_kif *)ifp->if_pf_kif;
=20
 	if (kif =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		DPFPRINTF(PF_DEBUG_URGENT,
@@ -6647,16 +6648,16 @@
 		return (PF_DROP);
 	}
 	if (kif->pfik_flags & PFI_IFLAG_SKIP)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	{
 		PF_UNLOCK();
 #endif
 		return (PF_PASS);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	}
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	M_ASSERTPKTHDR(m);
 #else
 #ifdef DIAGNOSTIC
@@ -6672,7 +6673,7 @@
 		goto done;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (m->m_flags & M_SKIP_FIREWALL) {
 		PF_UNLOCK();
 		return (PF_PASS);
@@ -6682,7 +6683,7 @@
 		return (PF_PASS);
 #endif
 =09
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (ip_divert_ptr !=3D NULL &&
 	    ((ipfwtag =3D m_tag_locate(m, MTAG_IPFW_RULE, 0, NULL)) !=3D NULL)) {
 		struct ipfw_rule_ref *rr =3D (struct ipfw_rule_ref *)(ipfwtag+1);
@@ -6754,7 +6755,7 @@
 		    &reason);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -6765,7 +6766,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif,
 			    m, off, h, &pd, &a, &ruleset, NULL, inp);
 #else
@@ -6794,7 +6795,7 @@
 		action =3D pf_test_state_udp(&s, dir, kif, m, off, h, &pd);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -6805,7 +6806,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif,
 			    m, off, h, &pd, &a, &ruleset, NULL, inp);
 #else
@@ -6828,7 +6829,7 @@
 		    &reason);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -6839,7 +6840,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif,
 			    m, off, h, &pd, &a, &ruleset, NULL, inp);
 #else
@@ -6862,7 +6863,7 @@
 		action =3D pf_test_state_other(&s, dir, kif, m, &pd);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -6873,7 +6874,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif, m, off, h,
 			    &pd, &a, &ruleset, NULL, inp);
 #else
@@ -6894,14 +6895,14 @@
 	}
=20
 	if ((s && s->tag) || r->rtableid)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_tag_packet(m, s ? s->tag : 0, r->rtableid, pd.pf_mtag);
 #else
 		pf_tag_packet(m, s ? s->tag : 0, r->rtableid);
 #endif
=20
 	if (dir =3D=3D PF_IN && s && s->key[PF_SK_STACK])
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pd.pf_mtag->statekey =3D s->key[PF_SK_STACK];
 #else
 		m->m_pkthdr.pf.statekey =3D s->key[PF_SK_STACK];
@@ -6909,7 +6910,7 @@
=20
 #ifdef ALTQ
 	if (action =3D=3D PF_PASS && r->qid) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pqid || (pd.tos & IPTOS_LOWDELAY))
 			pd.pf_mtag->qid =3D r->pqid;
 		else
@@ -6938,13 +6939,13 @@
 	    (s->nat_rule.ptr->action =3D=3D PF_RDR ||
 	    s->nat_rule.ptr->action =3D=3D PF_BINAT) &&
 	    (ntohl(pd.dst->v4.s_addr) >> IN_CLASSA_NSHIFT) =3D=3D IN_LOOPBACKNET)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m->m_flags |=3D M_SKIP_FIREWALL;
 #else
 		m->m_pkthdr.pf.flags |=3D PF_TAG_TRANSLATE_LOCALHOST;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (action =3D=3D PF_PASS && r->divert.port &&
 	    ip_divert_ptr !=3D NULL && !PACKET_LOOPED()) {
=20
@@ -7031,7 +7032,7 @@
 		}
 		tr =3D r;
 		nr =3D (s !=3D NULL) ? s->nat_rule.ptr : pd.nat_rule;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (nr !=3D NULL && r =3D=3D &V_pf_default_rule)
 #else
 		if (nr !=3D NULL && r =3D=3D &pf_default_rule)
@@ -7066,7 +7067,7 @@
 			pf_route(m0, r, dir, kif->pfik_ifp, s, &pd);
 		break;
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	return (action);
@@ -7075,7 +7076,7 @@
=20
 #ifdef INET6
 int
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pf_test6(int dir, struct ifnet *ifp, struct mbuf **m0,
     struct ether_header *eh, struct inpcb *inp)
 #else
@@ -7086,7 +7087,7 @@
 	struct pfi_kif		*kif;
 	u_short			 action, reason =3D 0, log =3D 0;
 	struct mbuf		*m =3D *m0, *n =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct ip6_hdr		*h =3D NULL;
 	struct pf_rule		*a =3D NULL, *r =3D &V_pf_default_rule, *tr, *nr;
 #else
@@ -7098,7 +7099,7 @@
 	struct pf_pdesc		 pd;
 	int			 off, terminal =3D 0, dirndx, rh_cnt =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 	if (!V_pf_status.running) {
 		PF_UNLOCK();
@@ -7110,7 +7111,7 @@
 #endif
=20
 	memset(&pd, 0, sizeof(pd));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((pd.pf_mtag =3D pf_get_mtag(m)) =3D=3D NULL) {
 		PF_UNLOCK();
 		DPFPRINTF(PF_DEBUG_URGENT,
@@ -7118,7 +7119,7 @@
 		return (PF_DROP);
 	}
 #endif
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	if (ifp->if_type =3D=3D IFT_CARP && ifp->if_carpdev)
 		kif =3D (struct pfi_kif *)ifp->if_carpdev->if_pf_kif;
 	else
@@ -7126,7 +7127,7 @@
 		kif =3D (struct pfi_kif *)ifp->if_pf_kif;
=20
 	if (kif =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		DPFPRINTF(PF_DEBUG_URGENT,
@@ -7134,16 +7135,16 @@
 		return (PF_DROP);
 	}
 	if (kif->pfik_flags & PFI_IFLAG_SKIP)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	{
 		PF_UNLOCK();
 #endif
 		return (PF_PASS);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	}
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	M_ASSERTPKTHDR(m);
 #else
 #ifdef DIAGNOSTIC
@@ -7159,14 +7160,14 @@
 		goto done;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pd.pf_mtag->flags & PF_TAG_GENERATED) {
 		PF_UNLOCK();
 #else
 	if (m->m_pkthdr.pf.flags & PF_TAG_GENERATED)
 #endif
 		return (PF_PASS);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	}
 #endif
=20
@@ -7294,7 +7295,7 @@
 		    &reason);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -7305,7 +7306,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif,
 			    m, off, h, &pd, &a, &ruleset, NULL, inp);
 #else
@@ -7334,7 +7335,7 @@
 		action =3D pf_test_state_udp(&s, dir, kif, m, off, h, &pd);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -7345,7 +7346,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif,
 			    m, off, h, &pd, &a, &ruleset, NULL, inp);
 #else
@@ -7375,7 +7376,7 @@
 		    m, off, h, &pd, &reason);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -7386,7 +7387,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif,
 			    m, off, h, &pd, &a, &ruleset, NULL, inp);
 #else
@@ -7400,7 +7401,7 @@
 		action =3D pf_test_state_other(&s, dir, kif, m, &pd);
 		if (action =3D=3D PF_PASS) {
 #if NPFSYNC > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (pfsync_update_state_ptr !=3D NULL)
 				pfsync_update_state_ptr(s);
 #else
@@ -7411,7 +7412,7 @@
 			a =3D s->anchor.ptr;
 			log =3D s->log;
 		} else if (s =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			action =3D pf_test_rule(&r, &s, dir, kif, m, off, h,
 			    &pd, &a, &ruleset, NULL, inp);
 #else
@@ -7438,14 +7439,14 @@
 	}
=20
 	if ((s && s->tag) || r->rtableid)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_tag_packet(m, s ? s->tag : 0, r->rtableid, pd.pf_mtag);
 #else
 		pf_tag_packet(m, s ? s->tag : 0, r->rtableid);
 #endif
=20
 	if (dir =3D=3D PF_IN && s && s->key[PF_SK_STACK])
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pd.pf_mtag->statekey =3D s->key[PF_SK_STACK];
 #else
 		m->m_pkthdr.pf.statekey =3D s->key[PF_SK_STACK];
@@ -7453,7 +7454,7 @@
=20
 #ifdef ALTQ
 	if (action =3D=3D PF_PASS && r->qid) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (pd.tos & IPTOS_LOWDELAY)
 			pd.pf_mtag->qid =3D r->pqid;
 		else
@@ -7476,13 +7477,13 @@
 	    (s->nat_rule.ptr->action =3D=3D PF_RDR ||
 	    s->nat_rule.ptr->action =3D=3D PF_BINAT) &&
 	    IN6_IS_ADDR_LOOPBACK(&pd.dst->v6))
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		m->m_flags |=3D M_SKIP_FIREWALL;
 #else
 		m->m_pkthdr.pf.flags |=3D PF_TAG_TRANSLATE_LOCALHOST;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX: Anybody working on it?! */
 	if (r->divert.port)
 		printf("pf: divert(9) is not supported for IPv6\n");
@@ -7540,7 +7541,7 @@
 		}
 		tr =3D r;
 		nr =3D (s !=3D NULL) ? s->nat_rule.ptr : pd.nat_rule;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (nr !=3D NULL && r =3D=3D &V_pf_default_rule)
 #else
 		if (nr !=3D NULL && r =3D=3D &pf_default_rule)
@@ -7574,7 +7575,7 @@
 		break;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	return (action);
@@ -7584,7 +7585,7 @@
 int
 pf_check_congestion(struct ifqueue *ifq)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX_IMPORT: later */
 	return (0);
 #else
@@ -7602,7 +7603,7 @@
 void
 pf_pkt_addr_changed(struct mbuf *m)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pf_mtag	*pf_tag;
=20
 	if ((pf_tag =3D pf_find_mtag(m)) !=3D NULL)
Index: sys/contrib/pf/net/pf_ruleset.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
--- sys/contrib/pf/net/pf_ruleset.c	(revision 230747)
+++ sys/contrib/pf/net/pf_ruleset.c	(working copy)
@@ -35,12 +35,13 @@
  *
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 #endif
=20
-#include <sys/param.h>
 #include <sys/socket.h>
 #ifdef _KERNEL
 # include <sys/systm.h>
@@ -61,7 +62,7 @@
=20
=20
 #ifdef _KERNEL
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define DPFPRINTF(format, x...)				\
 	if (V_pf_status.debug >=3D PF_DEBUG_NOISY)	\
 		printf(format , ##x)
@@ -70,7 +71,7 @@
 	if (pf_status.debug >=3D PF_DEBUG_NOISY)		\
 		printf(format , ##x)
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define rs_malloc(x)		malloc(x, M_TEMP, M_NOWAIT|M_ZERO)
 #else
 #define rs_malloc(x)		malloc(x, M_TEMP, M_WAITOK|M_CANFAIL|M_ZERO)
@@ -96,7 +97,7 @@
 #endif /* PFDEBUG */
 #endif /* _KERNEL */
=20
-#if defined(__FreeBSD__) && !defined(_KERNEL)
+#if defined(__FreeBSD_kernel__) && !defined(_KERNEL)
 #undef V_pf_anchors
 #define V_pf_anchors		 pf_anchors
=20
@@ -104,7 +105,7 @@
 #define pf_main_ruleset		 pf_main_anchor.ruleset
 #endif
=20
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if defined(__FreeBSD_kernel__) && defined(_KERNEL)
 VNET_DEFINE(struct pf_anchor_global,	pf_anchors);
 VNET_DEFINE(struct pf_anchor,		pf_main_anchor);
 #else
@@ -178,7 +179,7 @@
 	if (key =3D=3D NULL)
 		return (NULL);
 	strlcpy(key->path, path, sizeof(key->path));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	found =3D RB_FIND(pf_anchor_global, &V_pf_anchors, key);
 #else
 	found =3D RB_FIND(pf_anchor_global, &pf_anchors, key);
@@ -208,7 +209,7 @@
 {
 	char			*p, *q, *r;
 	struct pf_ruleset	*ruleset;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pf_anchor	*anchor =3D NULL, *dup, *parent =3D NULL;
 #else
 	struct pf_anchor	*anchor, *dup, *parent =3D NULL;
@@ -263,7 +264,7 @@
 			strlcat(anchor->path, "/", sizeof(anchor->path));
 		}
 		strlcat(anchor->path, anchor->name, sizeof(anchor->path));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((dup =3D RB_INSERT(pf_anchor_global, &V_pf_anchors, anchor)) !=3D
 #else
 		if ((dup =3D RB_INSERT(pf_anchor_global, &pf_anchors, anchor)) !=3D
@@ -284,7 +285,7 @@
 				    "RB_INSERT2 '%s' '%s' collides with "
 				    "'%s' '%s'\n", anchor->path, anchor->name,
 				    dup->path, dup->name);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				RB_REMOVE(pf_anchor_global, &V_pf_anchors,
 #else
 				RB_REMOVE(pf_anchor_global, &pf_anchors,
@@ -324,7 +325,7 @@
 			    !TAILQ_EMPTY(ruleset->rules[i].inactive.ptr) ||
 			    ruleset->rules[i].inactive.open)
 				return;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		RB_REMOVE(pf_anchor_global, &V_pf_anchors, ruleset->anchor);
 #else
 		RB_REMOVE(pf_anchor_global, &pf_anchors, ruleset->anchor);
Index: 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
--- sys/contrib/pf/net/if_pflow.h	(revision 230747)
+++ sys/contrib/pf/net/if_pflow.h	(working copy)
@@ -66,7 +66,7 @@
 	unsigned int		 sc_maxcount;
 	u_int64_t		 sc_gcounter;
 	struct ip_moptions	 sc_imo;
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	struct callout		 sc_tmo;
 #else
 	struct timeout		 sc_tmo;
Index: sys/contrib/pf/net/pf_table.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
--- sys/contrib/pf/net/pf_table.c	(revision 230747)
+++ sys/contrib/pf/net/pf_table.c	(working copy)
@@ -30,7 +30,9 @@
  *
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include "opt_inet.h"
 #include "opt_inet6.h"
=20
@@ -38,12 +40,11 @@
 __FBSDID("$FreeBSD$");
 #endif
=20
-#include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/socket.h>
 #include <sys/mbuf.h>
 #include <sys/kernel.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/malloc.h>
 #else
 #include <sys/pool.h>
@@ -52,7 +53,7 @@
 #include <net/if.h>
 #include <net/route.h>
 #include <netinet/in.h>
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <netinet/ip_ipsp.h>
 #endif
 #include <net/pfvar.h>
@@ -64,7 +65,7 @@
 			return (EINVAL);	\
 	} while (0)
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static inline int
 _copyin(const void *uaddr, void *kaddr, size_t len)
 {
@@ -175,7 +176,7 @@
=20
 #define	senderr(e)	do { rv =3D (e); goto _bad; } while (0)
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 VNET_DEFINE(uma_zone_t,			pfr_ktable_pl);
 VNET_DEFINE(uma_zone_t,			pfr_kentry_pl);
 VNET_DEFINE(uma_zone_t,			pfr_kcounters_pl);
@@ -255,7 +256,7 @@
 void
 pfr_initialize(void)
 {
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	pool_init(&pfr_ktable_pl, sizeof(struct pfr_ktable), 0, 0, 0,
 	    "pfrktable", NULL);
 	pool_init(&pfr_kentry_pl, sizeof(struct pfr_kentry), 0, 0, 0,
@@ -661,13 +662,13 @@
 	w.pfrw_addr =3D addr;
 	w.pfrw_free =3D kt->pfrkt_cnt;
 	w.pfrw_flags =3D flags;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	rv =3D kt->pfrkt_ip4->rnh_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
 #else
 	rv =3D rn_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
 #endif
 	if (!rv)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rv =3D kt->pfrkt_ip6->rnh_walktree(kt->pfrkt_ip6, pfr_walktree,
 		    &w);
 #else
@@ -714,13 +715,13 @@
 	w.pfrw_flags =3D flags;
 	if (flags & PFR_FLAG_ATOMIC)
 		s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	rv =3D kt->pfrkt_ip4->rnh_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
 #else
 	rv =3D rn_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
 #endif
 	if (!rv)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rv =3D kt->pfrkt_ip6->rnh_walktree(kt->pfrkt_ip6, pfr_walktree,=20
 		    &w);
 #else
@@ -841,7 +842,7 @@
 	w.pfrw_op =3D sweep ? PFRW_SWEEP : PFRW_ENQUEUE;
 	w.pfrw_workq =3D workq;
 	if (kt->pfrkt_ip4 !=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (kt->pfrkt_ip4->rnh_walktree(kt->pfrkt_ip4, pfr_walktree,=20
 		    &w))
 #else
@@ -849,7 +850,7 @@
 #endif
 			printf("pfr_enqueue_addrs: IPv4 walktree failed.\n");
 	if (kt->pfrkt_ip6 !=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (kt->pfrkt_ip6->rnh_walktree(kt->pfrkt_ip6, pfr_walktree,=20
 		    &w))
 #else
@@ -867,13 +868,13 @@
=20
 	bzero(&w, sizeof(w));
 	w.pfrw_op =3D PFRW_MARK;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (kt->pfrkt_ip4->rnh_walktree(kt->pfrkt_ip4, pfr_walktree, &w))
 #else
 	if (rn_walktree(kt->pfrkt_ip4, pfr_walktree, &w))
 #endif
 		printf("pfr_mark_addrs: IPv4 walktree failed.\n");
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (kt->pfrkt_ip6->rnh_walktree(kt->pfrkt_ip6, pfr_walktree, &w))
 #else
 	if (rn_walktree(kt->pfrkt_ip6, pfr_walktree, &w))
@@ -886,7 +887,7 @@
 pfr_lookup_addr(struct pfr_ktable *kt, struct pfr_addr *ad, int exact)
 {
 	union sockaddr_union	 sa, mask;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct radix_node_head	*head =3D NULL;
 #else
 	struct radix_node_head	*head;
@@ -905,7 +906,7 @@
 	if (ADDR_NETWORK(ad)) {
 		pfr_prepare_network(&mask, ad->pfra_af, ad->pfra_net);
 		s =3D splsoftnet(); /* rn_lookup makes use of globals */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK_ASSERT();
 #endif
 		ke =3D (struct pfr_kentry *)rn_lookup(&sa, &mask, head);
@@ -927,7 +928,7 @@
 {
 	struct pfr_kentry	*ke;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	ke =3D  pool_get(&V_pfr_kentry_pl, PR_NOWAIT | PR_ZERO);
 #else
 	if (intr)
@@ -963,7 +964,7 @@
 pfr_destroy_kentry(struct pfr_kentry *ke)
 {
 	if (ke->pfrke_counters)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pool_put(&V_pfr_kcounters_pl, ke->pfrke_counters);
 	pool_put(&V_pfr_kentry_pl, ke);
 #else
@@ -1051,7 +1052,7 @@
 		if (negchange)
 			p->pfrke_not =3D !p->pfrke_not;
 		if (p->pfrke_counters) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pfr_kcounters_pl, p->pfrke_counters);
 #else
 			pool_put(&pfr_kcounters_pl, p->pfrke_counters);
@@ -1108,7 +1109,7 @@
 {
 	union sockaddr_union	 mask;
 	struct radix_node	*rn;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct radix_node_head	*head =3D NULL;
 #else
 	struct radix_node_head	*head;
@@ -1122,18 +1123,18 @@
 		head =3D kt->pfrkt_ip6;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #endif
 	if (KENTRY_NETWORK(ke)) {
 		pfr_prepare_network(&mask, ke->pfrke_af, ke->pfrke_net);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rn =3D rn_addroute(&ke->pfrke_sa, &mask, head, ke->pfrke_node);
 #else
 		rn =3D rn_addroute(&ke->pfrke_sa, &mask, head, ke->pfrke_node, 0);
 #endif
 	} else
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rn =3D rn_addroute(&ke->pfrke_sa, NULL, head, ke->pfrke_node);
 #else
 		rn =3D rn_addroute(&ke->pfrke_sa, NULL, head, ke->pfrke_node, 0);
@@ -1148,7 +1149,7 @@
 {
 	union sockaddr_union	 mask;
 	struct radix_node	*rn;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct radix_node_head	*head =3D NULL;
 #else
 	struct radix_node_head	*head;
@@ -1161,18 +1162,18 @@
 		head =3D kt->pfrkt_ip6;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #endif
 	if (KENTRY_NETWORK(ke)) {
 		pfr_prepare_network(&mask, ke->pfrke_af, ke->pfrke_net);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rn =3D rn_delete(&ke->pfrke_sa, &mask, head);
 #else
 		rn =3D rn_delete(&ke->pfrke_sa, &mask, head, NULL);
 #endif
 	} else
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		rn =3D rn_delete(&ke->pfrke_sa, NULL, head);
 #else
 		rn =3D rn_delete(&ke->pfrke_sa, NULL, head, NULL);
@@ -1267,7 +1268,7 @@
 		if (ke->pfrke_af =3D=3D AF_INET) {
 			if (w->pfrw_dyn->pfid_acnt4++ > 0)
 				break;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pfr_prepare_network(&V_pfr_mask, AF_INET, ke->pfrke_net);
 #else
 			pfr_prepare_network(&pfr_mask, AF_INET, ke->pfrke_net);
@@ -1275,7 +1276,7 @@
 			w->pfrw_dyn->pfid_addr4 =3D *SUNION2PF(
 			    &ke->pfrke_sa, AF_INET);
 			w->pfrw_dyn->pfid_mask4 =3D *SUNION2PF(
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    &V_pfr_mask, AF_INET);
 #else
 			    &pfr_mask, AF_INET);
@@ -1283,7 +1284,7 @@
 		} else if (ke->pfrke_af =3D=3D AF_INET6){
 			if (w->pfrw_dyn->pfid_acnt6++ > 0)
 				break;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pfr_prepare_network(&V_pfr_mask, AF_INET6, ke->pfrke_net);
 #else
 			pfr_prepare_network(&pfr_mask, AF_INET6, ke->pfrke_net);
@@ -1291,7 +1292,7 @@
 			w->pfrw_dyn->pfid_addr6 =3D *SUNION2PF(
 			    &ke->pfrke_sa, AF_INET6);
 			w->pfrw_dyn->pfid_mask6 =3D *SUNION2PF(
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    &V_pfr_mask, AF_INET6);
 #else
 			    &pfr_mask, AF_INET6);
@@ -2077,7 +2078,7 @@
 	struct pfr_ktable	*kt;
 	struct pf_ruleset	*rs;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	kt =3D pool_get(&V_pfr_ktable_pl, PR_NOWAIT|PR_ZERO);
 #else
 	if (intr)
@@ -2132,7 +2133,7 @@
 		pfr_clean_node_mask(kt, &addrq);
 		pfr_destroy_kentries(&addrq);
 	}
-#if defined(__FreeBSD__) && (__FreeBSD_version >=3D 500100)
+#if defined(__FreeBSD_kernel__) && (__FreeBSD_version >=3D 500100)
 	if (kt->pfrkt_ip4 !=3D NULL) {
 		RADIX_NODE_HEAD_DESTROY(kt->pfrkt_ip4);
 		free((caddr_t)kt->pfrkt_ip4, M_RTABLE);
@@ -2153,7 +2154,7 @@
 		kt->pfrkt_rs->tables--;
 		pf_remove_if_empty_ruleset(kt->pfrkt_rs);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pool_put(&V_pfr_ktable_pl, kt);
 #else
 	pool_put(&pfr_ktable_pl, kt);
@@ -2192,7 +2193,7 @@
 	switch (af) {
 #ifdef INET
 	case AF_INET:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pfr_sin.sin_addr.s_addr =3D a->addr32[0];
 		ke =3D (struct pfr_kentry *)rn_match(&V_pfr_sin, kt->pfrkt_ip4);
 #else
@@ -2205,7 +2206,7 @@
 #endif /* INET */
 #ifdef INET6
 	case AF_INET6:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		bcopy(a, &V_pfr_sin6.sin6_addr, sizeof(V_pfr_sin6.sin6_addr));
 		ke =3D (struct pfr_kentry *)rn_match(&V_pfr_sin6, kt->pfrkt_ip6);
 #else
@@ -2239,7 +2240,7 @@
 	switch (af) {
 #ifdef INET
 	case AF_INET:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pfr_sin.sin_addr.s_addr =3D a->addr32[0];
 		ke =3D (struct pfr_kentry *)rn_match(&V_pfr_sin, kt->pfrkt_ip4);
 #else
@@ -2252,7 +2253,7 @@
 #endif /* INET */
 #ifdef INET6
 	case AF_INET6:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		bcopy(a, &V_pfr_sin6.sin6_addr, sizeof(V_pfr_sin6.sin6_addr));
 		ke =3D (struct pfr_kentry *)rn_match(&V_pfr_sin6, kt->pfrkt_ip6);
 #else
@@ -2276,7 +2277,7 @@
 	if (ke !=3D NULL && op_pass !=3D PFR_OP_XPASS &&
 	    (kt->pfrkt_flags & PFR_TFLAG_COUNTERS)) {
 		if (ke->pfrke_counters =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			ke->pfrke_counters =3D pool_get(&V_pfr_kcounters_pl,
 #else
 			ke->pfrke_counters =3D pool_get(&pfr_kcounters_pl,
@@ -2339,7 +2340,7 @@
 pfr_pool_get(struct pfr_ktable *kt, int *pidx, struct pf_addr *counter,
     struct pf_addr **raddr, struct pf_addr **rmask, sa_family_t af)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfr_kentry	*ke, *ke2 =3D NULL;
 	struct pf_addr		*addr =3D NULL;
 #else
@@ -2349,7 +2350,7 @@
 	union sockaddr_union	 mask;
 	int			 idx =3D -1, use_counter =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (af =3D=3D AF_INET)
 		addr =3D (struct pf_addr *)&V_pfr_sin.sin_addr;
 	else if (af =3D=3D AF_INET6)
@@ -2378,13 +2379,13 @@
 		kt->pfrkt_nomatch++;
 		return (1);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pfr_prepare_network(&V_pfr_mask, af, ke->pfrke_net);
 #else
 	pfr_prepare_network(&pfr_mask, af, ke->pfrke_net);
 #endif
 	*raddr =3D SUNION2PF(&ke->pfrke_sa, af);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	*rmask =3D SUNION2PF(&V_pfr_mask, af);
 #else
 	*rmask =3D SUNION2PF(&pfr_mask, af);
@@ -2413,7 +2414,7 @@
 	}
 	for (;;) {
 		/* we don't want to use a nested block */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (af =3D=3D AF_INET)
 			ke2 =3D (struct pfr_kentry *)rn_match(&V_pfr_sin,
 			    kt->pfrkt_ip4);
@@ -2439,7 +2440,7 @@
=20
 		/* we need to increase the counter past the nested block */
 		pfr_prepare_network(&mask, AF_INET, ke2->pfrke_net);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_POOLMASK(addr, addr, SUNION2PF(&mask, af), &V_pfr_ffaddr, af);
 #else
 		PF_POOLMASK(addr, addr, SUNION2PF(&mask, af), &pfr_ffaddr, af);
@@ -2467,7 +2468,7 @@
 	switch (af) {
 #ifdef INET
 	case AF_INET:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		kt->pfrkt_ip4->rnh_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
 #else
 		rn_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
@@ -2476,7 +2477,7 @@
 #endif /* INET */
 #ifdef INET6
 	case AF_INET6:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		kt->pfrkt_ip6->rnh_walktree(kt->pfrkt_ip6, pfr_walktree, &w);
 #else
 		rn_walktree(kt->pfrkt_ip6, pfr_walktree, &w);
@@ -2502,13 +2503,13 @@
 	dyn->pfid_acnt4 =3D 0;
 	dyn->pfid_acnt6 =3D 0;
 	if (!dyn->pfid_af || dyn->pfid_af =3D=3D AF_INET)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		kt->pfrkt_ip4->rnh_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
 #else
 		rn_walktree(kt->pfrkt_ip4, pfr_walktree, &w);
 #endif
 	if (!dyn->pfid_af || dyn->pfid_af =3D=3D AF_INET6)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		kt->pfrkt_ip6->rnh_walktree(kt->pfrkt_ip6, pfr_walktree, &w);
 #else
 		rn_walktree(kt->pfrkt_ip6, pfr_walktree, &w);
Index: 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
--- sys/contrib/pf/net/if_pfsync.c	(revision 230747)
+++ sys/contrib/pf/net/if_pfsync.c	(working copy)
@@ -51,7 +51,9 @@
  * 1.170 - SIOCSIFMTU checks
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_pf.h"
@@ -62,9 +64,8 @@
 #define	NBPFILTER	1
 #endif /* __FreeBSD__ */
=20
-#include <sys/param.h>
 #include <sys/kernel.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/bus.h>
 #include <sys/interrupt.h>
 #include <sys/priv.h>
@@ -74,7 +75,7 @@
 #include <sys/time.h>
 #include <sys/mbuf.h>
 #include <sys/socket.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/endian.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
@@ -88,19 +89,19 @@
 #include <sys/timeout.h>
 #endif
 #include <sys/sysctl.h>
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <sys/pool.h>
 #endif
=20
 #include <net/if.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #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__
+#ifdef __FreeBSD_kernel__
 #include <net/vnet.h>
 #endif
=20
@@ -120,7 +121,7 @@
 #include <netinet6/nd6.h>
 #endif /* INET6 */
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <netinet/ip_carp.h>
 #else
 #include "carp.h"
@@ -132,7 +133,7 @@
 #include <net/pfvar.h>
 #include <net/if_pfsync.h>
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include "bpfilter.h"
 #include "pfsync.h"
 #endif
@@ -217,7 +218,7 @@
 	TAILQ_ENTRY(pfsync_deferral)		 pd_entry;
 	struct pf_state				*pd_st;
 	struct mbuf				*pd_m;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct callout				 pd_tmo;
 #else
 	struct timeout				 pd_tmo;
@@ -233,14 +234,14 @@
 #endif
=20
 struct pfsync_softc {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct ifnet		*sc_ifp;
 #else
 	struct ifnet		 sc_if;
 #endif
 	struct ifnet		*sc_sync_if;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	uma_zone_t		 sc_pool;
 #else
 	struct pool		 sc_pool;
@@ -250,7 +251,7 @@
=20
 	struct in_addr		 sc_sync_peer;
 	u_int8_t		 sc_maxupdates;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	int			 pfsync_sync_ok;
 #endif
=20
@@ -269,7 +270,7 @@
=20
 	u_int32_t		 sc_ureq_sent;
 	int			 sc_bulk_tries;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct callout		 sc_bulkfail_tmo;
 #else
 	struct timeout		 sc_bulkfail_tmo;
@@ -278,7 +279,7 @@
 	u_int32_t		 sc_ureq_received;
 	struct pf_state		*sc_bulk_next;
 	struct pf_state		*sc_bulk_last;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct callout		 sc_bulk_tmo;
 #else
 	struct timeout		 sc_bulk_tmo;
@@ -286,14 +287,14 @@
=20
 	TAILQ_HEAD(, tdb)	 sc_tdb_q;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct callout		 sc_tmo;
 #else
 	struct timeout		 sc_tmo;
 #endif
 };
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static MALLOC_DEFINE(M_PFSYNC, "pfsync", "pfsync data");
 static VNET_DEFINE(struct pfsync_softc	*, pfsyncif) =3D NULL;
 #define	V_pfsyncif		VNET(pfsyncif)
@@ -326,7 +327,7 @@
 #endif
=20
 void	pfsyncattach(int);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 int	pfsync_clone_create(struct if_clone *, int, caddr_t);
 void	pfsync_clone_destroy(struct ifnet *);
 #else
@@ -337,7 +338,7 @@
 	    struct pf_state_peer *);
 void	pfsync_update_net_tdb(struct pfsync_tdb *);
 int	pfsyncoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	    struct route *);
 #else
 	    struct rtentry *);
@@ -365,18 +366,18 @@
 void	pfsync_bulk_update(void *);
 void	pfsync_bulk_fail(void *);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 /* XXX: ugly */
 #define	betoh64		(unsigned long long)be64toh
 #define	timeout_del	callout_stop
 #endif
=20
 #define PFSYNC_MAX_BULKTRIES	12
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 int	pfsync_sync_ok;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 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)
@@ -393,7 +394,7 @@
 	if_clone_attach(&pfsync_cloner);
 }
 int
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pfsync_clone_create(struct if_clone *ifc, int unit, caddr_t param)
 #else
 pfsync_clone_create(struct if_clone *ifc, int unit)
@@ -406,7 +407,7 @@
 	if (unit !=3D 0)
 		return (EINVAL);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	sc =3D malloc(sizeof(struct pfsync_softc), M_PFSYNC, M_WAITOK | M_ZERO);
 	sc->pfsync_sync_ok =3D 1;
 #else
@@ -417,7 +418,7 @@
 	for (q =3D 0; q < PFSYNC_S_COUNT; q++)
 		TAILQ_INIT(&sc->sc_qs[q]);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	sc->sc_pool =3D uma_zcreate("pfsync", PFSYNC_PLSIZE, NULL, NULL, NULL,
 	    NULL, UMA_ALIGN_PTR, 0);
 #else
@@ -432,14 +433,14 @@
 	sc->sc_len =3D PFSYNC_MINPKT;
 	sc->sc_maxupdates =3D 128;
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	sc->sc_imo.imo_membership =3D (struct in_multi **)malloc(
 	    (sizeof(struct in_multi *) * IP_MIN_MEMBERSHIPS), M_IPMOPTS,
 	    M_WAITOK | M_ZERO);
 	sc->sc_imo.imo_max_memberships =3D IP_MIN_MEMBERSHIPS;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	ifp =3D sc->sc_ifp =3D if_alloc(IFT_PFSYNC);
 	if (ifp =3D=3D NULL) {
 		uma_zdestroy(sc->sc_pool);
@@ -459,7 +460,7 @@
 	ifp->if_snd.ifq_maxlen =3D ifqmaxlen;
 	ifp->if_hdrlen =3D sizeof(struct pfsync_header);
 	ifp->if_mtu =3D ETHERMTU;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	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);
@@ -470,7 +471,7 @@
 #endif
=20
 	if_attach(ifp);
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	if_alloc_sadl(ifp);
=20
 #if NCARP > 0
@@ -479,14 +480,14 @@
 #endif
=20
 #if NBPFILTER > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	bpfattach(ifp, DLT_PFSYNC, PFSYNC_HDRLEN);
 #else
 	bpfattach(&sc->sc_if.if_bpf, ifp, DLT_PFSYNC, PFSYNC_HDRLEN);
 #endif
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfsyncif =3D sc;
 #else
 	pfsyncif =3D sc;
@@ -495,7 +496,7 @@
 	return (0);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void
 #else
 int
@@ -504,13 +505,13 @@
 {
 	struct pfsync_softc *sc =3D ifp->if_softc;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	timeout_del(&sc->sc_bulkfail_tmo);
 	timeout_del(&sc->sc_bulk_tmo);
 	timeout_del(&sc->sc_tmo);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 	if (!sc->pfsync_sync_ok && carp_demote_adj_p)
 		(*carp_demote_adj_p)(-V_pfsync_carp_adj, "pfsync destroy");
@@ -530,12 +531,12 @@
 	while (sc->sc_deferred > 0)
 		pfsync_undefer(TAILQ_FIRST(&sc->sc_deferrals), 0);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	UMA_DESTROY(sc->sc_pool);
 #else
 	pool_destroy(&sc->sc_pool);
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if_free(ifp);
 	if (sc->sc_imo.imo_membership)
 		pfsync_multicast_cleanup(sc);
@@ -545,13 +546,13 @@
 	free(sc, M_DEVBUF);
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfsyncif =3D NULL;
 #else
 	pfsyncif =3D NULL;
 #endif
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	return (0);
 #endif
 }
@@ -560,11 +561,11 @@
 pfsync_if_dequeue(struct ifnet *ifp)
 {
 	struct mbuf *m;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	int s;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	IF_LOCK(&ifp->if_snd);
 	_IF_DROP(&ifp->if_snd);
 	_IF_DEQUEUE(&ifp->if_snd, m);
@@ -587,7 +588,7 @@
 	struct mbuf *m;
=20
 	while ((m =3D pfsync_if_dequeue(ifp)) !=3D NULL) {
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 		IF_DROP(&ifp->if_snd);
 #endif
 		m_freem(m);
@@ -599,7 +600,7 @@
     struct pf_state_peer *d)
 {
 	if (s->scrub.scrub_flag && d->scrub =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		d->scrub =3D pool_get(&V_pf_state_scrub_pl, PR_NOWAIT | PR_ZERO);
 #else
 		d->scrub =3D pool_get(&pf_state_scrub_pl, PR_NOWAIT | PR_ZERO);
@@ -611,7 +612,7 @@
 	return (0);
 }
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 void
 pfsync_state_export(struct pfsync_state *sp, struct pf_state *st)
 {
@@ -684,7 +685,7 @@
 	int pool_flags;
 	int error;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
=20
 	if (sp->creatorid =3D=3D 0 && V_pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -697,7 +698,7 @@
 	}
=20
 	if ((kif =3D pfi_kif_get(sp->ifname)) =3D=3D NULL) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC)
@@ -719,7 +720,7 @@
 		r =3D pf_main_ruleset.rules[
 		    PF_RULESET_FILTER].active.ptr_array[ntohl(sp->rule)];
 	else
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		r =3D &V_pf_default_rule;
 #else
 		r =3D &pf_default_rule;
@@ -728,7 +729,7 @@
 	if ((r->max_states && r->states_cur >=3D r->max_states))
 		goto cleanup;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (flags & PFSYNC_SI_IOCTL)
 		pool_flags =3D PR_WAITOK | PR_ZERO;
 	else
@@ -837,7 +838,7 @@
 	error =3D ENOMEM;
 	if (skw =3D=3D sks)
 		sks =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (skw !=3D NULL)
 		pool_put(&V_pf_state_key_pl, skw);
 	if (sks !=3D NULL)
@@ -851,7 +852,7 @@
=20
 cleanup_state:	/* pf_state_insert frees the state keys */
 	if (st) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (st->dst.scrub)
 			pool_put(&V_pf_state_scrub_pl, st->dst.scrub);
 		if (st->src.scrub)
@@ -869,13 +870,13 @@
 }
=20
 void
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pfsync_input(struct mbuf *m, __unused int off)
 #else
 pfsync_input(struct mbuf *m, ...)
 #endif
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -891,7 +892,7 @@
 	V_pfsyncstats.pfsyncs_ipackets++;
=20
 	/* verify that we have a sync interface configured */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (!sc || !sc->sc_sync_if || !V_pf_status.running)
 #else
 	if (!sc || !sc->sc_sync_if || !pf_status.running)
@@ -904,7 +905,7 @@
 		goto done;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	sc->sc_ifp->if_ipackets++;
 	sc->sc_ifp->if_ibytes +=3D m->m_pkthdr.len;
 #else
@@ -950,7 +951,7 @@
 	pkt.src =3D ip->ip_src;
 	pkt.flags =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	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))
@@ -1001,14 +1002,14 @@
 	clr =3D (struct pfsync_clr *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
 		creatorid =3D clr[i].creatorid;
=20
 		if (clr[i].ifname[0] =3D=3D '\0') {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			for (st =3D RB_MIN(pf_state_tree_id, &V_tree_id);
 			    st; st =3D nexts) {
 				nexts =3D RB_NEXT(pf_state_tree_id, &V_tree_id, st);
@@ -1027,14 +1028,14 @@
 				continue;
=20
 			/* XXX correct? */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			for (sk =3D RB_MIN(pf_state_tree, &V_pf_statetbl);
 #else
 			for (sk =3D RB_MIN(pf_state_tree, &pf_statetbl);
 #endif
 			    sk; sk =3D nextsk) {
 				nextsk =3D RB_NEXT(pf_state_tree,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    &V_pf_statetbl, sk);
 #else
 				    &pf_statetbl, sk);
@@ -1049,7 +1050,7 @@
 			}
 		}
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1075,7 +1076,7 @@
 	sa =3D (struct pfsync_state *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
@@ -1087,7 +1088,7 @@
 		    sp->dst.state > PF_TCPS_PROXY_DST ||
 		    sp->direction > PF_OUT ||
 		    (sp->af !=3D AF_INET && sp->af !=3D AF_INET6)) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -1104,7 +1105,7 @@
 			break;
 		}
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1132,7 +1133,7 @@
 	iaa =3D (struct pfsync_ins_ack *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
@@ -1148,7 +1149,7 @@
 		if (ISSET(st->state_flags, PFSTATE_ACK))
 			pfsync_deferred(st, 0);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1216,7 +1217,7 @@
 	sa =3D (struct pfsync_state *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
@@ -1226,7 +1227,7 @@
 		if (sp->timeout >=3D PFTM_MAX ||
 		    sp->src.state > PF_TCPS_PROXY_DST ||
 		    sp->dst.state > PF_TCPS_PROXY_DST) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -1268,7 +1269,7 @@
 		}
=20
 		if (sfail) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -1292,7 +1293,7 @@
 		st->timeout =3D sp->timeout;
 		st->pfsync_time =3D time_uptime;
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1323,7 +1324,7 @@
 	ua =3D (struct pfsync_upd_c *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
@@ -1333,7 +1334,7 @@
 		if (up->timeout >=3D PFTM_MAX ||
 		    up->src.state > PF_TCPS_PROXY_DST ||
 		    up->dst.state > PF_TCPS_PROXY_DST) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -1374,7 +1375,7 @@
 		}
=20
 		if (sfail) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -1398,7 +1399,7 @@
 		st->timeout =3D up->timeout;
 		st->pfsync_time =3D time_uptime;
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1424,7 +1425,7 @@
 	}
 	ura =3D (struct pfsync_upd_req *)(mp->m_data + offp);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
@@ -1447,7 +1448,7 @@
 			pfsync_update_state_req(st);
 		}
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
=20
@@ -1473,7 +1474,7 @@
 	sa =3D (struct pfsync_state *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
@@ -1490,7 +1491,7 @@
 		SET(st->state_flags, PFSTATE_NOSYNC);
 		pf_unlink_state(st);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1517,7 +1518,7 @@
 	sa =3D (struct pfsync_del_c *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++) {
@@ -1535,7 +1536,7 @@
 		SET(st->state_flags, PFSTATE_NOSYNC);
 		pf_unlink_state(st);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1546,7 +1547,7 @@
 int
 pfsync_in_bus(struct pfsync_pkt *pkt, struct mbuf *m, int offset, int coun=
t)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -1569,7 +1570,7 @@
=20
 	switch (bus->status) {
 	case PFSYNC_BUS_START:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		callout_reset(&sc->sc_bulkfail_tmo, 4 * hz +
 		    V_pf_pool_limits[PF_LIMIT_STATES].limit /
 		    ((sc->sc_ifp->if_mtu - PFSYNC_MINPKT) /
@@ -1581,7 +1582,7 @@
 		    ((sc->sc_if.if_mtu - PFSYNC_MINPKT) /
 		    sizeof(struct pfsync_state)));
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC)
@@ -1596,7 +1597,7 @@
 			sc->sc_ureq_sent =3D 0;
 			sc->sc_bulk_tries =3D 0;
 			timeout_del(&sc->sc_bulkfail_tmo);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (!sc->pfsync_sync_ok && carp_demote_adj_p)
 				(*carp_demote_adj_p)(-V_pfsync_carp_adj,
 				    "pfsync bulk done");
@@ -1608,7 +1609,7 @@
 #endif
 			pfsync_sync_ok =3D 1;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC)
@@ -1616,7 +1617,7 @@
 				printf("pfsync: received valid "
 				    "bulk update end\n");
 		} else {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC)
@@ -1650,12 +1651,12 @@
 	tp =3D (struct pfsync_tdb *)(mp->m_data + offp);
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	for (i =3D 0; i < count; i++)
 		pfsync_update_net_tdb(&tp[i]);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -1698,7 +1699,7 @@
 	return;
=20
 bad:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 	if (pf_status.debug >=3D PF_DEBUG_MISC)
@@ -1734,7 +1735,7 @@
=20
 int
 pfsyncoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct route *rt)
 #else
 	struct rtentry *rt)
@@ -1748,7 +1749,7 @@
 int
 pfsyncioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
 {
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	struct proc *p =3D curproc;
 #endif
 	struct pfsync_softc *sc =3D ifp->if_softc;
@@ -1766,7 +1767,7 @@
 	case SIOCSIFDSTADDR:
 #endif
 	case SIOCSIFFLAGS:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (ifp->if_flags & IFF_UP)
 			ifp->if_drv_flags |=3D IFF_DRV_RUNNING;
 		else
@@ -1785,11 +1786,11 @@
 			return (EINVAL);
 		if (ifr->ifr_mtu < ifp->if_mtu) {
 			s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_LOCK();
 #endif
 			pfsync_sendout();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_UNLOCK();
 #endif
 			splx(s);
@@ -1807,7 +1808,7 @@
 		return (copyout(&pfsyncr, ifr->ifr_data, sizeof(pfsyncr)));
=20
 	case SIOCSETPFSYNC:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if ((error =3D priv_check(curthread, PRIV_NETINET_PF)) !=3D 0)
 #else
 		if ((error =3D suser(p, p->p_acflag)) !=3D 0)
@@ -1816,11 +1817,11 @@
 		if ((error =3D copyin(ifr->ifr_data, &pfsyncr, sizeof(pfsyncr))))
 			return (error);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		if (pfsyncr.pfsyncr_syncpeer.s_addr =3D=3D 0)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			sc->sc_sync_peer.s_addr =3D htonl(INADDR_PFSYNC_GROUP);
 #else
 			sc->sc_sync_peer.s_addr =3D INADDR_PFSYNC_GROUP;
@@ -1830,19 +1831,19 @@
 			    pfsyncr.pfsyncr_syncpeer.s_addr;
=20
 		if (pfsyncr.pfsyncr_maxupdates > 255)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		{
 			PF_UNLOCK();
 #endif
 			return (EINVAL);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		}
 #endif
 		sc->sc_maxupdates =3D pfsyncr.pfsyncr_maxupdates;
=20
 		if (pfsyncr.pfsyncr_syncdev[0] =3D=3D 0) {
 			sc->sc_sync_if =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_UNLOCK();
 			if (imo->imo_membership)
 				pfsync_multicast_cleanup(sc);
@@ -1856,17 +1857,17 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		if ((sifp =3D ifunit(pfsyncr.pfsyncr_syncdev)) =3D=3D NULL)
 			return (EINVAL);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (sifp->if_mtu < sc->sc_ifp->if_mtu ||
 #else
 		if (sifp->if_mtu < sc->sc_if.if_mtu ||
@@ -1877,7 +1878,7 @@
 			pfsync_sendout();
 		sc->sc_sync_if =3D sifp;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (imo->imo_membership) {
 			PF_UNLOCK();
 			pfsync_multicast_cleanup(sc);
@@ -1890,7 +1891,7 @@
 		}
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (sc->sc_sync_if &&
 		    sc->sc_sync_peer.s_addr =3D=3D htonl(INADDR_PFSYNC_GROUP)) {
 			PF_UNLOCK();
@@ -1931,7 +1932,7 @@
 		ip->ip_hl =3D sizeof(sc->sc_template) >> 2;
 		ip->ip_tos =3D IPTOS_LOWDELAY;
 		/* len and id are set later */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		ip->ip_off =3D IP_DF;
 #else
 		ip->ip_off =3D htons(IP_DF);
@@ -1944,7 +1945,7 @@
 		if (sc->sc_sync_if) {
 			/* Request a full state table update. */
 			sc->sc_ureq_sent =3D time_uptime;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (sc->pfsync_sync_ok && carp_demote_adj_p)
 				(*carp_demote_adj_p)(V_pfsync_carp_adj,
 				    "pfsync bulk start");
@@ -1956,13 +1957,13 @@
 #endif
 			pfsync_sync_ok =3D 0;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC)
 #endif
 				printf("pfsync: requesting bulk update\n");
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			callout_reset(&sc->sc_bulkfail_tmo, 5 * hz,
 			    pfsync_bulk_fail, V_pfsyncif);
 #else
@@ -1970,7 +1971,7 @@
 #endif
 			pfsync_request_update(0, 0);
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_UNLOCK();
 #endif
 		splx(s);
@@ -2057,7 +2058,7 @@
=20
 		TAILQ_FOREACH(st, &sc->sc_qs[q], sync_list) {
 #ifdef PFSYNC_DEBUG
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			KASSERT(st->sync_state =3D=3D q,
 				("%s: st->sync_state =3D=3D q",
 					__FUNCTION__));
@@ -2089,7 +2090,7 @@
 	sc->sc_len =3D PFSYNC_MINPKT;
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void pfsync_sendout()
 {
 	pfsync_sendout1(1);
@@ -2106,7 +2107,7 @@
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
 #if NBPFILTER > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct ifnet *ifp =3D sc->sc_ifp;
 #else
 	struct ifnet *ifp =3D &sc->sc_if;
@@ -2124,7 +2125,7 @@
 	int offset;
 	int q, count =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #else
 	splassert(IPL_NET);
@@ -2142,7 +2143,7 @@
 		return;
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	m =3D m_get2(M_NOWAIT, MT_DATA, M_PKTHDR, max_linkhdr + sc->sc_len);
 	if (m =3D=3D NULL) {
 		sc->sc_ifp->if_oerrors++;
@@ -2177,7 +2178,7 @@
 	bcopy(&sc->sc_template, ip, sizeof(*ip));
 	offset =3D sizeof(*ip);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	ip->ip_len =3D m->m_pkthdr.len;
 #else
 	ip->ip_len =3D htons(m->m_pkthdr.len);
@@ -2191,7 +2192,7 @@
=20
 	ph->version =3D PFSYNC_VERSION;
 	ph->len =3D htons(sc->sc_len - sizeof(*ip));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	bcopy(V_pf_status.pf_chksum, ph->pfcksum, PF_MD5_DIGEST_LENGTH);
 #else
 	bcopy(pf_status.pf_chksum, ph->pfcksum, PF_MD5_DIGEST_LENGTH);
@@ -2208,7 +2209,7 @@
 		count =3D 0;
 		TAILQ_FOREACH(st, &sc->sc_qs[q], sync_list) {
 #ifdef PFSYNC_DEBUG
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			KASSERT(st->sync_state =3D=3D q,
 				("%s: st->sync_state =3D=3D q",
 					__FUNCTION__));
@@ -2292,7 +2293,7 @@
 	if (ifp->if_bpf) {
 		m->m_data +=3D sizeof(*ip);
 		m->m_len =3D m->m_pkthdr.len =3D sc->sc_len - sizeof(*ip);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		BPF_MTAP(ifp, m);
 #else
 		bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_OUT);
@@ -2308,7 +2309,7 @@
 	}
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	sc->sc_ifp->if_opackets++;
 	sc->sc_ifp->if_obytes +=3D m->m_pkthdr.len;
 	sc->sc_len =3D PFSYNC_MINPKT;
@@ -2338,13 +2339,13 @@
 void
 pfsync_insert_state(struct pf_state *st)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #else
 	splassert(IPL_SOFTNET);
@@ -2360,7 +2361,7 @@
 		return;
=20
 #ifdef PFSYNC_DEBUG
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT(st->sync_state =3D=3D PFSYNC_S_NONE,
 		("%s: st->sync_state =3D=3D PFSYNC_S_NONE", __FUNCTION__));
 #else
@@ -2369,7 +2370,7 @@
 #endif
=20
 	if (sc->sc_len =3D=3D PFSYNC_MINPKT)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		callout_reset(&sc->sc_tmo, 1 * hz, pfsync_timeout,
 		    V_pfsyncif);
 #else
@@ -2389,14 +2390,14 @@
 int
 pfsync_defer(struct pf_state *st, struct mbuf *m)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
 	struct pfsync_deferral *pd;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #else
 	splassert(IPL_SOFTNET);
@@ -2410,7 +2411,7 @@
 		return (0);
 	sc->sc_deferred++;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	m->m_flags |=3D M_SKIP_FIREWALL;
 #else
 	m->m_pkthdr.pf.flags |=3D PF_TAG_GENERATED;
@@ -2421,7 +2422,7 @@
 	pd->pd_m =3D m;
=20
 	TAILQ_INSERT_TAIL(&sc->sc_deferrals, pd, pd_entry);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	callout_init(&pd->pd_tmo, CALLOUT_MPSAFE);
 	callout_reset(&pd->pd_tmo, defer, pfsync_defer_tmo,
 		pd);
@@ -2436,14 +2437,14 @@
 void
 pfsync_undefer(struct pfsync_deferral *pd, int drop)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
 	int s;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #else
 	splassert(IPL_SOFTNET);
@@ -2458,13 +2459,13 @@
 		m_freem(pd->pd_m);
 	else {
 		s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		/* XXX: use pf_defered?! */
 		PF_UNLOCK();
 #endif
 		ip_output(pd->pd_m, (void *)NULL, (void *)NULL, 0,
 		    (void *)NULL, (void *)NULL);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		PF_LOCK();
 #endif
 		splx(s);
@@ -2476,18 +2477,18 @@
 void
 pfsync_defer_tmo(void *arg)
 {
-#if defined(__FreeBSD__) && defined(VIMAGE)
+#if defined(__FreeBSD_kernel__) && defined(VIMAGE)
 	struct pfsync_deferral *pd =3D arg;
 #endif
 	int s;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	CURVNET_SET(pd->pd_m->m_pkthdr.rcvif->if_vnet); /* XXX */
 	PF_LOCK();
 #endif
 	pfsync_undefer(arg, 0);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 	CURVNET_RESTORE();
 #endif
@@ -2497,7 +2498,7 @@
 void
 pfsync_deferred(struct pf_state *st, int drop)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -2519,14 +2520,14 @@
 void
 pfsync_update_state(struct pf_state *st)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
 	int sync =3D 0;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #else
 	splassert(IPL_SOFTNET);
@@ -2544,7 +2545,7 @@
 	}
=20
 	if (sc->sc_len =3D=3D PFSYNC_MINPKT)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		callout_reset(&sc->sc_tmo, 1 * hz, pfsync_timeout,
 		    V_pfsyncif);
 #else
@@ -2585,7 +2586,7 @@
 void
 pfsync_request_update(u_int32_t creatorid, u_int64_t id)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -2613,7 +2614,7 @@
 	if (TAILQ_EMPTY(&sc->sc_upd_req_list))
 		nlen +=3D sizeof(struct pfsync_subheader);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (sc->sc_len + nlen > sc->sc_ifp->if_mtu) {
 #else
 	if (sc->sc_len + nlen > sc->sc_if.if_mtu) {
@@ -2635,7 +2636,7 @@
 void
 pfsync_update_state_req(struct pf_state *st)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -2676,13 +2677,13 @@
 void
 pfsync_delete_state(struct pf_state *st)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #else
 	splassert(IPL_SOFTNET);
@@ -2700,7 +2701,7 @@
 	}
=20
 	if (sc->sc_len =3D=3D PFSYNC_MINPKT)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		callout_reset(&sc->sc_tmo, 1 * hz, pfsync_timeout,
 		    V_pfsyncif);
 #else
@@ -2737,13 +2738,13 @@
 		struct pfsync_clr clr;
 	} __packed r;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 #else
 	splassert(IPL_SOFTNET);
@@ -2766,7 +2767,7 @@
 void
 pfsync_q_ins(struct pf_state *st, int q)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -2776,7 +2777,7 @@
=20
 	PF_LOCK_ASSERT();
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT(st->sync_state =3D=3D PFSYNC_S_NONE,
 		("%s: st->sync_state =3D=3D PFSYNC_S_NONE", __FUNCTION__));
 #else
@@ -2785,7 +2786,7 @@
=20
 #if 1 || defined(PFSYNC_DEBUG)
 	if (sc->sc_len < PFSYNC_MINPKT)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		panic("pfsync pkt len is too low %zu", sc->sc_len);
 #else
 		panic("pfsync pkt len is too low %d", sc->sc_len);
@@ -2794,7 +2795,7 @@
 	if (TAILQ_EMPTY(&sc->sc_qs[q]))
 		nlen +=3D sizeof(struct pfsync_subheader);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (sc->sc_len + nlen > sc->sc_ifp->if_mtu) {
 #else
 	if (sc->sc_len + nlen > sc->sc_if.if_mtu) {
@@ -2814,14 +2815,14 @@
 void
 pfsync_q_del(struct pf_state *st)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
 	int q =3D st->sync_state;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	KASSERT(st->sync_state !=3D PFSYNC_S_NONE,
 		("%s: st->sync_state !=3D PFSYNC_S_NONE", __FUNCTION__));
 #else
@@ -2840,7 +2841,7 @@
 void
 pfsync_update_tdb(struct tdb *t, int output)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -2884,7 +2885,7 @@
 void
 pfsync_delete_tdb(struct tdb *t)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -2939,20 +2940,20 @@
 void
 pfsync_bulk_start(void)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 	if (pf_status.debug >=3D PF_DEBUG_MISC)
 #endif
 		printf("pfsync: received bulk update request\n");
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK_ASSERT();
 	if (TAILQ_EMPTY(&V_state_list))
 #else
@@ -2962,7 +2963,7 @@
 	else {
 		sc->sc_ureq_received =3D time_uptime;
 		if (sc->sc_bulk_next =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			sc->sc_bulk_next =3D TAILQ_FIRST(&V_state_list);
 #else
 			sc->sc_bulk_next =3D TAILQ_FIRST(&state_list);
@@ -2985,7 +2986,7 @@
 	PF_LOCK_ASSERT();
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	CURVNET_SET(sc->sc_ifp->if_vnet);
 #endif
 	for (;;) {
@@ -2998,7 +2999,7 @@
=20
 		st =3D TAILQ_NEXT(st, entry_list);
 		if (st =3D=3D NULL)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			st =3D TAILQ_FIRST(&V_state_list);
 #else
 			st =3D TAILQ_FIRST(&state_list);
@@ -3012,7 +3013,7 @@
 			break;
 		}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (i > 1 && (sc->sc_ifp->if_mtu - sc->sc_len) <
 #else
 		if (i > 1 && (sc->sc_if.if_mtu - sc->sc_len) <
@@ -3020,7 +3021,7 @@
 		    sizeof(struct pfsync_state)) {
 			/* we've filled a packet */
 			sc->sc_bulk_next =3D st;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			callout_reset(&sc->sc_bulk_tmo, 1,
 			    pfsync_bulk_update, sc);
 #else
@@ -3030,7 +3031,7 @@
 		}
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	CURVNET_RESTORE();
 #endif
 	splx(s);
@@ -3044,7 +3045,7 @@
 		struct pfsync_bus bus;
 	} __packed r;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -3057,7 +3058,7 @@
 	r.subh.action =3D PFSYNC_ACT_BUS;
 	r.subh.count =3D htons(1);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	r.bus.creatorid =3D V_pf_status.hostid;
 #else
 	r.bus.creatorid =3D pf_status.hostid;
@@ -3073,13 +3074,13 @@
 {
 	struct pfsync_softc *sc =3D arg;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	CURVNET_SET(sc->sc_ifp->if_vnet);
 #endif
=20
 	if (sc->sc_bulk_tries++ < PFSYNC_MAX_BULKTRIES) {
 		/* Try again */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		callout_reset(&sc->sc_bulkfail_tmo, 5 * hz,
 		    pfsync_bulk_fail, V_pfsyncif);
 #else
@@ -3092,7 +3093,7 @@
 		/* Pretend like the transfer was ok */
 		sc->sc_ureq_sent =3D 0;
 		sc->sc_bulk_tries =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (!sc->pfsync_sync_ok && carp_demote_adj_p)
 			(*carp_demote_adj_p)(-V_pfsync_carp_adj,
 			    "pfsync bulk fail");
@@ -3104,7 +3105,7 @@
 #endif
 		pfsync_sync_ok =3D 1;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (V_pf_status.debug >=3D PF_DEBUG_MISC)
 #else
 		if (pf_status.debug >=3D PF_DEBUG_MISC)
@@ -3112,7 +3113,7 @@
 			printf("pfsync: failed to receive bulk update\n");
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	CURVNET_RESTORE();
 #endif
 }
@@ -3120,7 +3121,7 @@
 void
 pfsync_send_plus(void *plus, size_t pluslen)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -3129,7 +3130,7 @@
=20
 	PF_LOCK_ASSERT();
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (sc->sc_len + pluslen > sc->sc_ifp->if_mtu) {
 #else
 	if (sc->sc_len + pluslen > sc->sc_if.if_mtu) {
@@ -3150,13 +3151,13 @@
 int
 pfsync_up(void)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (sc =3D=3D NULL || !ISSET(sc->sc_ifp->if_flags, IFF_DRV_RUNNING))
 #else
 	if (sc =3D=3D NULL || !ISSET(sc->sc_if.if_flags, IFF_RUNNING))
@@ -3169,7 +3170,7 @@
 int
 pfsync_state_in_use(struct pf_state *st)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct pfsync_softc *sc =3D V_pfsyncif;
 #else
 	struct pfsync_softc *sc =3D pfsyncif;
@@ -3192,35 +3193,35 @@
 void
 pfsync_timeout(void *arg)
 {
-#if defined(__FreeBSD__) && defined(VIMAGE)
+#if defined(__FreeBSD_kernel__) && defined(VIMAGE)
 	struct pfsync_softc *sc =3D arg;
 #endif
 	int s;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	CURVNET_SET(sc->sc_ifp->if_vnet);
 #endif
=20
 	pfsync_tmos++;
=20
 	s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	pfsync_sendout();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	CURVNET_RESTORE();
 #endif
 }
=20
 /* this is a softnet/netisr handler */
 void
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 pfsyncintr(void *arg)
 {
 	struct pfsync_softc *sc =3D arg;
@@ -3281,7 +3282,7 @@
 	return (ENOPROTOOPT);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static int
 pfsync_multicast_setup(struct pfsync_softc *sc)
 {
Index: sys/contrib/pf/net/pf_lb.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
--- sys/contrib/pf/net/pf_lb.c	(revision 230747)
+++ sys/contrib/pf/net/pf_lb.c	(working copy)
@@ -35,7 +35,9 @@
  *
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include "opt_inet.h"
 #include "opt_inet6.h"
=20
@@ -43,7 +45,7 @@
 __FBSDID("$FreeBSD$");
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include "opt_bpf.h"
 #include "opt_pf.h"
=20
@@ -78,7 +80,6 @@
 #include "pflow.h"
 #endif
=20
-#include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
 #include <sys/filio.h>
@@ -86,14 +87,14 @@
 #include <sys/socketvar.h>
 #include <sys/kernel.h>
 #include <sys/time.h>
-#ifdef  __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/sysctl.h>
 #endif
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <sys/pool.h>
 #endif
 #include <sys/proc.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/kthread.h>
 #include <sys/lock.h>
 #include <sys/sx.h>
@@ -101,7 +102,7 @@
 #include <sys/rwlock.h>
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/md5.h>
 #else
 #include <crypto/md5.h>
@@ -129,7 +130,7 @@
 #include <netinet/icmp_var.h>
 #include <netinet/if_ether.h>
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <dev/rndvar.h>
 #endif
 #include <net/pfvar.h>
@@ -148,7 +149,7 @@
 #endif /* INET6 */
=20
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define DPFPRINTF(n, x)	if (V_pf_status.debug >=3D (n)) printf x
 #else
 #define DPFPRINTF(n, x)	if (pf_status.debug >=3D (n)) printf x
@@ -278,7 +279,7 @@
 		    !pf_match_port(dst->port_op, dst->port[0],
 		    dst->port[1], dport))
 			r =3D r->skip[PF_SKIP_DST_PORT].ptr;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		else if (r->match_tag && !pf_match_tag(m, r, &tag, pd->pf_mtag))
 #else
 		else if (r->match_tag && !pf_match_tag(m, r, &tag))
@@ -303,7 +304,7 @@
 			pf_step_out_of_anchor(&asd, &ruleset, rs_num, &r,
 			    NULL, NULL);
 	}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (pf_tag_packet(m, tag, rtableid, pd->pf_mtag))
 #else
 	if (pf_tag_packet(m, tag, rtableid))
@@ -369,7 +370,7 @@
 				high =3D tmp;
 			}
 			/* low < high */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			cut =3D htonl(arc4random()) % (1 + high - low) + low;
 #else
 			cut =3D arc4random_uniform(1 + high - low) + low;
@@ -378,7 +379,7 @@
 			for (tmp =3D cut; tmp <=3D high; ++(tmp)) {
 				key.port[0] =3D htons(tmp);
 				if (pf_find_state_all(&key, PF_IN, NULL) =3D=3D
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    NULL) {
 #else
 				    NULL && !in_baddynamic(tmp, proto)) {
@@ -390,7 +391,7 @@
 			for (tmp =3D cut - 1; tmp >=3D low; --(tmp)) {
 				key.port[0] =3D htons(tmp);
 				if (pf_find_state_all(&key, PF_IN, NULL) =3D=3D
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 				    NULL) {
 #else
 				    NULL && !in_baddynamic(tmp, proto)) {
@@ -437,7 +438,7 @@
 			k.rule.ptr =3D r;
 		else
 			k.rule.ptr =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		V_pf_status.scounters[SCNT_SRC_NODE_SEARCH]++;
 		*sn =3D RB_FIND(pf_src_tree, &V_tree_src_tracking, &k);
 #else
@@ -446,7 +447,7 @@
 #endif
 		if (*sn !=3D NULL && !PF_AZERO(&(*sn)->raddr, af)) {
 			PF_ACPY(naddr, &(*sn)->raddr, af);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			if (V_pf_status.debug >=3D PF_DEBUG_MISC) {
 #else
 			if (pf_status.debug >=3D PF_DEBUG_MISC) {
@@ -597,7 +598,7 @@
 	if (*sn !=3D NULL)
 		PF_ACPY(&(*sn)->raddr, naddr, af);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (V_pf_status.debug >=3D PF_DEBUG_MISC &&
 #else
 	if (pf_status.debug >=3D PF_DEBUG_MISC &&
@@ -775,7 +776,7 @@
 		 * Pretend there was no match.
 		 */
 		if (!bcmp(*skp, *nkp, sizeof(struct pf_state_key_cmp))) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			pool_put(&V_pf_state_key_pl, *nkp);
 			pool_put(&V_pf_state_key_pl, *skp);
 #else
Index: sys/contrib/pf/net/pf_if.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
--- sys/contrib/pf/net/pf_if.c	(revision 230747)
+++ sys/contrib/pf/net/pf_if.c	(working copy)
@@ -32,7 +32,9 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
=20
-#if defined(__FreeBSD__)
+#include <sys/param.h>
+
+#if defined(__FreeBSD_kernel__)
 #include "opt_inet.h"
 #include "opt_inet6.h"
=20
@@ -40,9 +42,8 @@
 __FBSDID("$FreeBSD$");
 #endif
=20
-#include <sys/param.h>
 #include <sys/systm.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/malloc.h>
 #endif
 #include <sys/mbuf.h>
@@ -50,17 +51,17 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/kernel.h>
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <sys/device.h>
 #endif
 #include <sys/time.h>
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <sys/pool.h>
 #endif
=20
 #include <net/if.h>
 #include <net/if_types.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <net/vnet.h>
 #endif
=20
@@ -76,7 +77,7 @@
 #include <netinet/ip6.h>
 #endif /* INET6 */
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 VNET_DEFINE(struct pfi_kif *,	 pfi_all);
 VNET_DEFINE(uma_zone_t,		 pfi_addr_pl);
 VNET_DEFINE(struct pfi_ifhead,	 pfi_ifs);
@@ -98,7 +99,7 @@
 int			  pfi_buffer_cnt;
 int			  pfi_buffer_max;
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 eventhandler_tag	 pfi_attach_cookie;
 eventhandler_tag	 pfi_detach_cookie;
 eventhandler_tag	 pfi_attach_group_cookie;
@@ -117,7 +118,7 @@
 int		 pfi_if_compare(struct pfi_kif *, struct pfi_kif *);
 int		 pfi_skip_if(const char *, struct pfi_kif *);
 int		 pfi_unmask(void *);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void		 pfi_attach_ifnet_event(void * __unused, struct ifnet *);
 void		 pfi_detach_ifnet_event(void * __unused, struct ifnet *);
 void		 pfi_attach_group_event(void *, struct ifg_group *);
@@ -135,18 +136,18 @@
 void
 pfi_initialize(void)
 {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (V_pfi_all !=3D NULL)	/* already initialized */
 #else
 	if (pfi_all !=3D NULL)	/* already initialized */
 #endif
 		return;
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	pool_init(&V_pfi_addr_pl, sizeof(struct pfi_dynaddr), 0, 0, 0,
 	    "pfiaddrpl", &pool_allocator_nointr);
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_buffer_max =3D 64;
 	V_pfi_buffer =3D malloc(V_pfi_buffer_max * sizeof(*V_pfi_buffer),
 	    PFI_MTYPE, M_WAITOK);
@@ -160,7 +161,7 @@
 	if ((pfi_all =3D pfi_kif_get(IFG_ALL)) =3D=3D NULL)
 #endif
 		panic("pfi_kif_get for pfi_all failed");
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct ifg_group *ifg;
 	struct ifnet *ifp;
=20
@@ -186,7 +187,7 @@
 #endif
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void
 pfi_cleanup(void)
 {
@@ -224,7 +225,7 @@
=20
 	bzero(&s, sizeof(s));
 	strlcpy(s.pfik_name, kif_name, sizeof(s.pfik_name));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((kif =3D RB_FIND(pfi_ifhead, &V_pfi_ifs, (struct pfi_kif *)&s)) !=3D =
NULL)
 #else
 	if ((kif =3D RB_FIND(pfi_ifhead, &pfi_ifs, (struct pfi_kif *)&s)) !=3D NU=
LL)
@@ -232,7 +233,7 @@
 		return (kif);
=20
 	/* create new one */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((kif =3D malloc(sizeof(*kif), PFI_MTYPE, M_NOWAIT | M_ZERO)) =3D=3D N=
ULL)
 #else
 	if ((kif =3D malloc(sizeof(*kif), PFI_MTYPE, M_DONTWAIT|M_ZERO)) =3D=3D N=
ULL)
@@ -240,7 +241,7 @@
 		return (NULL);
=20
 	strlcpy(kif->pfik_name, kif_name, sizeof(kif->pfik_name));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/*
 	 * It seems that the value of time_second is in unintialzied state
 	 * when pf sets interface statistics clear time in boot phase if pf
@@ -254,7 +255,7 @@
 #endif
 	TAILQ_INIT(&kif->pfik_dynaddrs);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_INSERT(pfi_ifhead, &V_pfi_ifs, kif);
 #else
 	RB_INSERT(pfi_ifhead, &pfi_ifs, kif);
@@ -305,7 +306,7 @@
 		panic("pfi_kif_unref with unknown type");
 	}
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (kif->pfik_ifp !=3D NULL || kif->pfik_group !=3D NULL || kif =3D=3D V_=
pfi_all)
 #else
 	if (kif->pfik_ifp !=3D NULL || kif->pfik_group !=3D NULL || kif =3D=3D pf=
i_all)
@@ -315,7 +316,7 @@
 	if (kif->pfik_rules || kif->pfik_states)
 		return;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_REMOVE(pfi_ifhead, &V_pfi_ifs, kif);
 #else
 	RB_REMOVE(pfi_ifhead, &pfi_ifs, kif);
@@ -347,7 +348,7 @@
=20
 	pfi_initialize();
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_update++;
 #else
 	pfi_update++;
@@ -358,7 +359,7 @@
 	kif->pfik_ifp =3D ifp;
 	ifp->if_pf_kif =3D (caddr_t)kif;
=20
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	if ((kif->pfik_ah_cookie =3D hook_establish(ifp->if_addrhooks, 1,
 	    pfi_kifaddr_update, kif)) =3D=3D NULL)
 		panic("pfi_attach_ifnet: cannot allocate '%s' address hook",
@@ -380,12 +381,12 @@
 		return;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_update++;
 #else
 	pfi_update++;
 #endif
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	hook_disestablish(ifp->if_addrhooks, kif->pfik_ah_cookie);
 #endif
 	pfi_kif_update(kif);
@@ -404,7 +405,7 @@
=20
 	pfi_initialize();
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_update++;
 #else
 	pfi_update++;
@@ -428,7 +429,7 @@
 		return;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_update++;
 #else
 	pfi_update++;
@@ -447,7 +448,7 @@
 	int			 s;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_update++;
 #else
 	pfi_update++;
@@ -505,7 +506,7 @@
=20
 	if (aw->type !=3D PF_ADDR_DYNIFTL)
 		return (0);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX: revisit! */
 	if ((dyn =3D pool_get(&V_pfi_addr_pl, PR_WAITOK | PR_ZERO))
 #else
@@ -567,7 +568,7 @@
 		pf_remove_if_empty_ruleset(ruleset);
 	if (dyn->pfid_kif !=3D NULL)
 		pfi_kif_unref(dyn->pfid_kif, PFI_KIF_REF_RULE);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pool_put(&V_pfi_addr_pl, dyn);
 #else
 	pool_put(&pfi_addr_pl, dyn);
@@ -605,14 +606,14 @@
 	kif =3D dyn->pfid_kif;
 	kt =3D dyn->pfid_kt;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (kt->pfrkt_larg !=3D V_pfi_update) {
 #else
 	if (kt->pfrkt_larg !=3D pfi_update) {
 #endif
 		/* this table needs to be brought up-to-date */
 		pfi_table_update(kt, kif, dyn->pfid_net, dyn->pfid_iflags);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		kt->pfrkt_larg =3D V_pfi_update;
 #else
 		kt->pfrkt_larg =3D pfi_update;
@@ -627,7 +628,7 @@
 	int			 e, size2 =3D 0;
 	struct ifg_member	*ifgm;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_buffer_cnt =3D 0;
 #else
 	pfi_buffer_cnt =3D 0;
@@ -639,7 +640,7 @@
 		TAILQ_FOREACH(ifgm, &kif->pfik_group->ifg_members, ifgm_next)
 			pfi_instance_add(ifgm->ifgm_ifp, net, flags);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((e =3D pfr_set_addrs(&kt->pfrkt_t, V_pfi_buffer, V_pfi_buffer_cnt, &s=
ize2,
 	    NULL, NULL, NULL, 0, PFR_TFLAG_ALLMASK)))
 		printf("pfi_table_update: cannot set %d new addresses "
@@ -667,7 +668,7 @@
 		af =3D ia->ifa_addr->sa_family;
 		if (af !=3D AF_INET && af !=3D AF_INET6)
 			continue;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		/*
 		 * XXX: For point-to-point interfaces, (ifname:0) and IPv4,
 		 *      jump over addresses without a proper route to work
@@ -727,7 +728,7 @@
 	struct pfr_addr	*p;
 	int		 i;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if (V_pfi_buffer_cnt >=3D V_pfi_buffer_max) {
 		int		 new_max =3D V_pfi_buffer_max * 2;
 #else
@@ -737,7 +738,7 @@
=20
 		if (new_max > PFI_BUFFER_MAX) {
 			printf("pfi_address_add: address buffer full (%d/%d)\n",
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    V_pfi_buffer_cnt, PFI_BUFFER_MAX);
 #else
 			    pfi_buffer_cnt, PFI_BUFFER_MAX);
@@ -745,21 +746,21 @@
 			return;
 		}
 		p =3D malloc(new_max * sizeof(*V_pfi_buffer), PFI_MTYPE,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    M_NOWAIT);
 #else
 		    M_DONTWAIT);
 #endif
 		if (p =3D=3D NULL) {
 			printf("pfi_address_add: no memory to grow buffer "
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			    "(%d/%d)\n", V_pfi_buffer_cnt, PFI_BUFFER_MAX);
 #else
 			    "(%d/%d)\n", pfi_buffer_cnt, PFI_BUFFER_MAX);
 #endif
 			return;
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		memcpy(V_pfi_buffer, p, V_pfi_buffer_cnt * sizeof(*V_pfi_buffer));
 		/* no need to zero buffer */
 		free(V_pfi_buffer, PFI_MTYPE);
@@ -775,7 +776,7 @@
 	}
 	if (af =3D=3D AF_INET && net > 32)
 		net =3D 128;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	p =3D V_pfi_buffer + V_pfi_buffer_cnt++;
 #else
 	p =3D pfi_buffer + pfi_buffer_cnt++;
@@ -812,7 +813,7 @@
 	aw->p.dyn->pfid_kif =3D NULL;
 	pfr_detach_table(aw->p.dyn->pfid_kt);
 	aw->p.dyn->pfid_kt =3D NULL;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	pool_put(&V_pfi_addr_pl, aw->p.dyn);
 #else
 	pool_put(&pfi_addr_pl, aw->p.dyn);
@@ -837,7 +838,7 @@
 	struct pfi_kif		*kif =3D (struct pfi_kif *)v;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	V_pfi_update++;
 #else
 	pfi_update++;
@@ -863,7 +864,7 @@
=20
 	strlcpy(key.pfik_name, name, sizeof(key.pfik_name));
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	p =3D RB_FIND(pfi_ifhead, &V_pfi_ifs, (struct pfi_kif *)&key);
 #else
 	p =3D RB_FIND(pfi_ifhead, &pfi_ifs, (struct pfi_kif *)&key);
@@ -915,12 +916,12 @@
 {
 	struct pfi_kif	*p, *nextp;
 	int		 s, n =3D 0;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	int		 error;
 #endif
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	for (p =3D RB_MIN(pfi_ifhead, &V_pfi_ifs); p; p =3D nextp) {
 		nextp =3D RB_NEXT(pfi_ifhead, &V_pfi_ifs, p);
 #else
@@ -933,7 +934,7 @@
 			if (!p->pfik_tzero)
 				p->pfik_tzero =3D time_second;
 			pfi_kif_ref(p, PFI_KIF_REF_RULE);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			PF_COPYOUT(p, buf++, sizeof(*buf), error);
 			if (error) {
 #else
@@ -943,7 +944,7 @@
 				splx(s);
 				return (EFAULT);
 			}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 			nextp =3D RB_NEXT(pfi_ifhead, &V_pfi_ifs, p);
 #else
 			nextp =3D RB_NEXT(pfi_ifhead, &pfi_ifs, p);
@@ -982,7 +983,7 @@
 	int		 s;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_FOREACH(p, pfi_ifhead, &V_pfi_ifs) {
 #else
 	RB_FOREACH(p, pfi_ifhead, &pfi_ifs) {
@@ -1002,7 +1003,7 @@
 	int		 s;
=20
 	s =3D splsoftnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	RB_FOREACH(p, pfi_ifhead, &V_pfi_ifs) {
 #else
 	RB_FOREACH(p, pfi_ifhead, &pfi_ifs) {
@@ -1035,7 +1036,7 @@
 	return (b);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 void
 pfi_attach_ifnet_event(void *arg __unused, struct ifnet *ifp)
 {
Index: sys/contrib/pf/net/pfvar.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
--- sys/contrib/pf/net/pfvar.h	(revision 230747)
+++ sys/contrib/pf/net/pfvar.h	(working copy)
@@ -37,7 +37,7 @@
 #include <sys/types.h>
 #include <sys/queue.h>
 #include <sys/tree.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <sys/lock.h>
 #include <sys/sx.h>
 #else
@@ -46,7 +46,7 @@
=20
 #include <net/radix.h>
 #include <net/route.h>
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <net/if_clone.h>
 #include <net/pf_mtag.h>
 #include <vm/uma.h>
@@ -54,7 +54,7 @@
 #include <netinet/ip_ipsp.h>
 #endif
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #include <netinet/in.h>
 #endif
=20
@@ -62,7 +62,7 @@
=20
 struct ip;
 struct ip6_hdr;
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 struct inpcb;
 #endif
=20
@@ -173,7 +173,7 @@
 		}			 a;
 		char			 ifname[IFNAMSIZ];
 		char			 tblname[PF_TABLE_NAME_SIZE];
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #define	RTLABEL_LEN	32
 #endif
 		char			 rtlabelname[RTLABEL_LEN];
@@ -211,7 +211,7 @@
  * Address manipulation macros
  */
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #define	splsoftnet()	splnet()
=20
 #define	HTONL(x)	(x) =3D htonl((__uint32_t)(x))
@@ -236,7 +236,7 @@
 	if (var)					\
 		uma_zdestroy(var)
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 extern struct mtx pf_task_mtx;
=20
 #define	PF_LOCK_ASSERT()	mtx_assert(&pf_task_mtx, MA_OWNED)
@@ -826,7 +826,7 @@
 	u_int64_t		 id;
 	u_int32_t		 creatorid;
 	u_int8_t		 direction;
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	u_int8_t		 pad[2];
 	u_int8_t		 local_flags;
 #define	PFSTATE_EXPIRING 0x01
@@ -916,7 +916,7 @@
 	sa_family_t	 af;
 	u_int8_t	 proto;
 	u_int8_t	 direction;
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	u_int8_t	 local_flags;
 #define	PFSTATE_EXPIRING		0x01
 	u_int8_t	 pad;
@@ -928,7 +928,7 @@
 	u_int8_t	 updates;
 } __packed;
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #ifdef _KERNEL
 /* pfsync */
 typedef int		pfsync_state_import_t(struct pfsync_state *, u_int8_t);
@@ -1208,7 +1208,7 @@
 RB_HEAD(pfi_ifhead, pfi_kif);
=20
 /* state tables */
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #ifdef _KERNEL
 VNET_DECLARE(struct pf_state_tree,	 pf_statetbl);
 #define	V_pf_statetbl			 VNET(pf_statetbl)
@@ -1270,7 +1270,7 @@
 	struct pf_addr	*dst;		/* dst address */
 	u_int16_t *sport;
 	u_int16_t *dport;
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	struct pf_mtag	*pf_mtag;
 #endif
=20
@@ -1396,7 +1396,7 @@
 			*(a) =3D (x); \
 	} while (0)
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #define REASON_SET(a, x) \
 	do { \
 		if ((a) !=3D NULL) \
@@ -1481,7 +1481,7 @@
 	u_int32_t		 parent_qid;	/* parent queue id */
 	u_int32_t		 bandwidth;	/* queue bandwidth */
 	u_int8_t		 priority;	/* priority */
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	u_int8_t		 local_flags;	/* dynamic interface */
 #define	PFALTQ_FLAG_IF_REMOVED		0x01
 #endif
@@ -1761,7 +1761,7 @@
 #define	DIOCSETIFFLAG	_IOWR('D', 89, struct pfioc_iface)
 #define	DIOCCLRIFFLAG	_IOWR('D', 90, struct pfioc_iface)
 #define	DIOCKILLSRCNODES	_IOWR('D', 91, struct pfioc_src_node_kill)
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 struct pf_ifspeed {
 	char			ifname[IFNAMSIZ];
 	u_int32_t		baudrate;
@@ -1772,7 +1772,7 @@
 #ifdef _KERNEL
 RB_HEAD(pf_src_tree, pf_src_node);
 RB_PROTOTYPE(pf_src_tree, pf_src_node, entry, pf_src_compare);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct pf_src_tree,	 tree_src_tracking);
 #define	V_tree_src_tracking		 VNET(tree_src_tracking)
 #else
@@ -1782,7 +1782,7 @@
 RB_HEAD(pf_state_tree_id, pf_state);
 RB_PROTOTYPE(pf_state_tree_id, pf_state,
     entry_id, pf_state_compare_id);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct pf_state_tree_id,	 tree_id);
 #define	V_tree_id			 VNET(tree_id)
 VNET_DECLARE(struct pf_state_queue,	 state_list);
@@ -1793,14 +1793,14 @@
 #endif
=20
 TAILQ_HEAD(pf_poolqueue, pf_pool);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct pf_poolqueue,	 pf_pools[2]);
 #define	V_pf_pools			 VNET(pf_pools)
 #else
 extern struct pf_poolqueue		  pf_pools[2];
 #endif
 TAILQ_HEAD(pf_altqqueue, pf_altq);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct pf_altqqueue,	 pf_altqs[2]);
 #define	V_pf_altqs			 VNET(pf_altqs)
 VNET_DECLARE(struct pf_palist,		 pf_pabuf);
@@ -1810,7 +1810,7 @@
 extern struct pf_palist			  pf_pabuf;
 #endif
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(u_int32_t,			 ticket_altqs_active);
 #define	V_ticket_altqs_active		 VNET(ticket_altqs_active)
 VNET_DECLARE(u_int32_t,			 ticket_altqs_inactive);
@@ -1842,7 +1842,7 @@
 extern void			 pf_tbladdr_remove(struct pf_addr_wrap *);
 extern void			 pf_tbladdr_copyout(struct pf_addr_wrap *);
 extern void			 pf_calc_skip_steps(struct pf_rulequeue *);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #ifdef ALTQ
 extern	void			 pf_altq_ifnet_event(struct ifnet *, int);
 #endif
@@ -1879,7 +1879,7 @@
 extern struct pool		 pf_state_scrub_pl;
 #endif
 extern void			 pf_purge_thread(void *);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 extern int			 pf_purge_expired_src_nodes(int);
 extern int			 pf_purge_expired_states(u_int32_t , int);
 #else
@@ -1904,7 +1904,7 @@
 extern u_int16_t		 pf_cksum_fixup(u_int16_t, u_int16_t, u_int16_t,
 				    u_int8_t);
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct ifnet *,		 sync_ifp);
 #define	V_sync_ifp		 	 VNET(sync_ifp);
 VNET_DECLARE(struct pf_rule,		 pf_default_rule);
@@ -1917,12 +1917,12 @@
 				    u_int8_t);
 void				 pf_rm_rule(struct pf_rulequeue *,
 				    struct pf_rule *);
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
 struct pf_divert		*pf_find_divert(struct mbuf *);
 #endif
=20
 #ifdef INET
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 int	pf_test(int, struct ifnet *, struct mbuf **, struct ether_header *,
     struct inpcb *);
 #else
@@ -1931,7 +1931,7 @@
 #endif /* INET */
=20
 #ifdef INET6
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 int	pf_test6(int, struct ifnet *, struct mbuf **, struct ether_header *,
     struct inpcb *);
 #else
@@ -1942,7 +1942,7 @@
 void	pf_addr_inc(struct pf_addr *, sa_family_t);
 #endif /* INET6 */
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 u_int32_t	pf_new_isn(struct pf_state *);
 #endif
 void   *pf_pull_hdr(struct mbuf *, int, void *, int, u_short *, u_short *,
@@ -1979,7 +1979,7 @@
 void	pf_purge_expired_fragments(void);
 int	pf_routable(struct pf_addr *addr, sa_family_t af, struct pfi_kif *);
 int	pf_rtlabel_match(struct pf_addr *, sa_family_t, struct pf_addr_wrap *);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 int	pf_socket_lookup(int, struct pf_pdesc *,  struct inpcb *);
 #else
 int	pf_socket_lookup(int, struct pf_pdesc *);
@@ -2024,7 +2024,7 @@
 int	pfr_ina_define(struct pfr_table *, struct pfr_addr *, int, int *,
 	    int *, u_int32_t, int);
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct pfi_kif *,		 pfi_all);
 #define	V_pfi_all	 		 VNET(pfi_all)
 #else
@@ -2032,7 +2032,7 @@
 #endif
=20
 void		 pfi_initialize(void);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 void		 pfi_cleanup(void);
 #endif
 struct pfi_kif	*pfi_kif_get(const char *);
@@ -2054,7 +2054,7 @@
 int		 pfi_set_flags(const char *, int);
 int		 pfi_clear_flags(const char *, int);
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 int		 pf_match_tag(struct mbuf *, struct pf_rule *, int *,
 		    struct pf_mtag *);
 #else
@@ -2064,7 +2064,7 @@
 void		 pf_tag2tagname(u_int16_t, char *);
 void		 pf_tag_ref(u_int16_t);
 void		 pf_tag_unref(u_int16_t);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 int		 pf_tag_packet(struct mbuf *, int, int, struct pf_mtag *);
 #else
 int		 pf_tag_packet(struct mbuf *, int, int);
@@ -2073,14 +2073,14 @@
 void		 pf_qid2qname(u_int32_t, char *);
 void		 pf_qid_unref(u_int32_t);
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct pf_status,		 pf_status);
 #define	V_pf_status			 VNET(pf_status)
 #else
 extern struct pf_status	pf_status;
 #endif
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(uma_zone_t,		 pf_frent_pl);
 #define	V_pf_frent_pl			 VNET(pf_frent_pl)
 VNET_DECLARE(uma_zone_t,		 pf_frag_pl);
@@ -2096,14 +2096,14 @@
 	void		*pp;
 	unsigned	 limit;
 };
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 VNET_DECLARE(struct pf_pool_limit,		 pf_pool_limits[PF_LIMIT_MAX]);
 #define	V_pf_pool_limits			 VNET(pf_pool_limits)
 #else
 extern struct pf_pool_limit	pf_pool_limits[PF_LIMIT_MAX];
 #endif
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 struct pf_frent {
 	LIST_ENTRY(pf_frent) fr_next;
 	struct ip *fr_ip;
@@ -2137,7 +2137,7 @@
=20
 #endif /* _KERNEL */
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #ifdef _KERNEL
 VNET_DECLARE(struct pf_anchor_global,		 pf_anchors);
 #define	V_pf_anchors				 VNET(pf_anchors)
@@ -2165,7 +2165,7 @@
 struct pf_ruleset	*pf_find_or_create_ruleset(const char *);
 void			 pf_rs_initialize(void);
=20
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
 #ifdef _KERNEL
 int			 pf_anchor_copyout(const struct pf_ruleset *,
 			    const struct pf_rule *, struct pfioc_rule *);
@@ -2186,7 +2186,7 @@
 	    const struct tcphdr *);
 void	pf_osfp_flush(void);
 int	pf_osfp_get(struct pf_osfp_ioctl *);
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 int	pf_osfp_initialize(void);
 void	pf_osfp_cleanup(void);
 #else
Index: 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
--- sys/contrib/pf/net/if_pflog.c	(revision 230747)
+++ sys/contrib/pf/net/if_pflog.c	(working copy)
@@ -33,7 +33,9 @@
  * PURPOSE.
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include "opt_inet.h"
 #include "opt_inet6.h"
 #include "opt_bpf.h"
@@ -59,12 +61,11 @@
 #include "pflog.h"
 #endif /* __FreeBSD__ */
=20
-#include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/mbuf.h>
 #include <sys/proc.h>
 #include <sys/socket.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <sys/kernel.h>
 #include <sys/limits.h>
 #include <sys/malloc.h>
@@ -75,7 +76,7 @@
 #endif
=20
 #include <net/if.h>
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #include <net/if_clone.h>
 #endif
 #include <net/if_types.h>
@@ -99,7 +100,7 @@
 #include <net/pfvar.h>
 #include <net/if_pflog.h>
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef INET
 #include <machine/in_cksum.h>
 #endif /* INET */
@@ -115,14 +116,14 @@
=20
 void	pflogattach(int);
 int	pflogoutput(struct ifnet *, struct mbuf *, struct sockaddr *,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	    struct route *);
 #else
 	    struct rtentry *);
 #endif
 int	pflogioctl(struct ifnet *, u_long, caddr_t);
 void	pflogstart(struct ifnet *);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static int pflog_clone_create(struct if_clone *, int, caddr_t);
 static void pflog_clone_destroy(struct ifnet *);
 #else
@@ -131,7 +132,7 @@
 #endif
=20
 LIST_HEAD(, pflog_softc)	pflogif_list;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 IFC_SIMPLE_DECLARE(pflog, 1);
 #else
 struct if_clone	pflog_cloner =3D
@@ -150,7 +151,7 @@
 	if_clone_attach(&pflog_cloner);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static int
 pflog_clone_create(struct if_clone *ifc, int unit, caddr_t param)
 #else
@@ -170,7 +171,7 @@
 		return (ENOMEM);
=20
 	pflogif->sc_unit =3D unit;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	ifp =3D pflogif->sc_ifp =3D if_alloc(IFT_PFLOG);
 	if (ifp =3D=3D NULL) {
 		free(pflogif, M_DEVBUF);
@@ -186,18 +187,18 @@
 	ifp->if_ioctl =3D pflogioctl;
 	ifp->if_output =3D pflogoutput;
 	ifp->if_start =3D pflogstart;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	ifp->if_type =3D IFT_PFLOG;
 #endif
 	ifp->if_snd.ifq_maxlen =3D ifqmaxlen;
 	ifp->if_hdrlen =3D PFLOG_HDRLEN;
 	if_attach(ifp);
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	if_alloc_sadl(ifp);
 #endif
=20
 #if NBPFILTER > 0
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	bpfattach(ifp, DLT_PFLOG, PFLOG_HDRLEN);
 #else
 	bpfattach(&pflogif->sc_if.if_bpf, ifp, DLT_PFLOG, PFLOG_HDRLEN);
@@ -205,13 +206,13 @@
 #endif
=20
 	s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	/* XXX: Why pf(4) lock?! Better add a pflog lock?! */
 	PF_LOCK();
 #endif
 	LIST_INSERT_HEAD(&pflogif_list, pflogif, sc_list);
 	pflogifs[unit] =3D ifp;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -219,7 +220,7 @@
 	return (0);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static void
 pflog_clone_destroy(struct ifnet *ifp)
 #else
@@ -231,12 +232,12 @@
 	int			 s;
=20
 	s =3D splnet();
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_LOCK();
 #endif
 	pflogifs[pflogif->sc_unit] =3D NULL;
 	LIST_REMOVE(pflogif, sc_list);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	PF_UNLOCK();
 #endif
 	splx(s);
@@ -245,11 +246,11 @@
 	bpfdetach(ifp);
 #endif
 	if_detach(ifp);
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if_free(ifp);
 #endif
 	free(pflogif, M_DEVBUF);
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	return (0);
 #endif
 }
@@ -261,12 +262,12 @@
 pflogstart(struct ifnet *ifp)
 {
 	struct mbuf *m;
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 	int s;
 #endif
=20
 	for (;;) {
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		IF_LOCK(&ifp->if_snd);
 		_IF_DROP(&ifp->if_snd);
 		_IF_DEQUEUE(&ifp->if_snd, m);
@@ -287,7 +288,7 @@
=20
 int
 pflogoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	struct route *rt)
 #else
 	struct rtentry *rt)
@@ -303,7 +304,7 @@
 {
 	switch (cmd) {
 	case SIOCSIFFLAGS:
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (ifp->if_flags & IFF_UP)
 			ifp->if_drv_flags |=3D IFF_DRV_RUNNING;
 		else
@@ -355,7 +356,7 @@
 			    sizeof(hdr.ruleset));
 	}
 	if (rm->log & PF_LOG_SOCKET_LOOKUP && !pd->lookup.done)
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		/*
 		 * XXX: This should not happen as we force an early lookup
 		 * via debug.pfugidhack
@@ -387,7 +388,7 @@
=20
 	ifn->if_opackets++;
 	ifn->if_obytes +=3D m->m_pkthdr.len;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	BPF_MTAP2(ifn, &hdr, PFLOG_HDRLEN, m);
 #else
 	bpf_mtap_hdr(ifn->if_bpf, (char *)&hdr, PFLOG_HDRLEN, m,
@@ -398,7 +399,7 @@
 	return (0);
 }
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 static int
 pflog_modevent(module_t mod, int type, void *data)
 {
Index: sys/contrib/pf/net/if_pfsync.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
--- sys/contrib/pf/net/if_pfsync.h	(revision 230747)
+++ sys/contrib/pf/net/if_pfsync.h	(working copy)
@@ -268,7 +268,7 @@
 	int		 pfsyncr_authlevel;
 };
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 #define	SIOCSETPFSYNC   _IOW('i', 247, struct ifreq)
 #define	SIOCGETPFSYNC   _IOWR('i', 248, struct ifreq)
 #endif
@@ -288,7 +288,7 @@
 #define	PFSYNC_S_DEFER	0xfe
 #define	PFSYNC_S_NONE	0xff
=20
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 void			pfsync_input(struct mbuf *, __unused int);
 #else
 void			pfsync_input(struct mbuf *, ...);
@@ -300,7 +300,7 @@
 #define	PFSYNC_SI_CKSUM		0x02
 #define	PFSYNC_SI_ACK		0x04
 int			pfsync_state_import(struct pfsync_state *, u_int8_t);
-#ifndef __FreeBSD__
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__)
 void			pfsync_state_export(struct pfsync_state *,
 			    struct pf_state *);
 #endif
Index: 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
--- sys/contrib/pf/net/if_pflog.h	(revision 230747)
+++ sys/contrib/pf/net/if_pflog.h	(working copy)
@@ -30,7 +30,7 @@
 #define	PFLOGIFS_MAX	16
=20
 struct pflog_softc {
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	struct ifnet		*sc_ifp;	/* the interface pointer */
 #else
 	struct ifnet		sc_if;		/* the interface */
@@ -74,7 +74,7 @@
 #define	OLD_PFLOG_HDRLEN	sizeof(struct old_pfloghdr)
=20
 #ifdef _KERNEL
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 struct pf_rule;
 struct pf_ruleset;
 struct pfi_kif;
Index: sys/contrib/pf/net/pf_osfp.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
--- sys/contrib/pf/net/pf_osfp.c	(revision 230747)
+++ sys/contrib/pf/net/pf_osfp.c	(working copy)
@@ -17,16 +17,17 @@
  *
  */
=20
-#ifdef __FreeBSD__
+#include <sys/param.h>
+
+#ifdef __FreeBSD_kernel__
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 #endif
=20
-#include <sys/param.h>
 #include <sys/socket.h>
 #ifdef _KERNEL
 #include <sys/systm.h>
-#ifndef __FreeBSD__
+#ifndef __FreeBSD_kernel__
 #include <sys/pool.h>
 #endif
 #endif /* _KERNEL */
@@ -47,7 +48,7 @@
=20
=20
 #ifdef _KERNEL
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define	DPFPRINTF(format, x...)		\
 	if (V_pf_status.debug >=3D PF_DEBUG_NOISY)	\
 		printf(format , ##x)
@@ -56,7 +57,7 @@
 	if (pf_status.debug >=3D PF_DEBUG_NOISY)	\
 		printf(format , ##x)
 #endif
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 typedef uma_zone_t pool_t;
 #else
 typedef struct pool pool_t;
@@ -76,7 +77,7 @@
 #define	pool_put(pool, item)	free(item)
 #define	pool_init(pool, size, a, ao, f, m, p)	(*(pool)) =3D (size)
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #define	NTOHS(x) (x) =3D ntohs((u_int16_t)(x))
 #endif
=20
@@ -89,7 +90,7 @@
 #endif /* _KERNEL */
=20
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 SLIST_HEAD(pf_osfp_list, pf_os_fingerprint);
 VNET_DEFINE(struct pf_osfp_list,	pf_osfp_list);
 #define	V_pf_osfp_list			VNET(pf_osfp_list)
@@ -284,7 +285,7 @@
 	    (fp.fp_flags & PF_OSFP_WSCALE_DC) ? "*" : "",
 	    fp.fp_wscale);
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((fpresult =3D pf_osfp_find(&V_pf_osfp_list, &fp,
 #else
 	if ((fpresult =3D pf_osfp_find(&pf_osfp_list, &fp,
@@ -325,14 +326,14 @@
 }
=20
 /* Initialize the OS fingerprint system */
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 int
 #else
 void
 #endif
 pf_osfp_initialize(void)
 {
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#if defined(__FreeBSD_kernel__) && defined(_KERNEL)
 	int error =3D ENOMEM;
=20
 	do {
@@ -351,7 +352,7 @@
 	SLIST_INIT(&pf_osfp_list);
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 #ifdef _KERNEL
 	return (error);
 #else
@@ -360,7 +361,7 @@
 #endif
 }
=20
-#if defined(__FreeBSD__) && (_KERNEL)
+#if defined(__FreeBSD_kernel__) && (_KERNEL)
 void
 pf_osfp_cleanup(void)
 {
@@ -377,7 +378,7 @@
 	struct pf_os_fingerprint *fp;
 	struct pf_osfp_entry *entry;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	while ((fp =3D SLIST_FIRST(&V_pf_osfp_list))) {
 		SLIST_REMOVE_HEAD(&V_pf_osfp_list, fp_next);
 #else
@@ -436,7 +437,7 @@
 	    fpioc->fp_os.fp_os);
 #endif
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	if ((fp =3D pf_osfp_find_exact(&V_pf_osfp_list, &fpadd))) {
 #else
 	if ((fp =3D pf_osfp_find_exact(&pf_osfp_list, &fpadd))) {
@@ -446,7 +447,7 @@
 				return (EEXIST);
 		}
 		if ((entry =3D pool_get(&pf_osfp_entry_pl,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    PR_NOWAIT)) =3D=3D NULL)
 #else
 		    PR_WAITOK|PR_LIMITFAIL)) =3D=3D NULL)
@@ -454,7 +455,7 @@
 			return (ENOMEM);
 	} else {
 		if ((fp =3D pool_get(&pf_osfp_pl,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    PR_NOWAIT)) =3D=3D NULL)
 #else
 		    PR_WAITOK|PR_LIMITFAIL)) =3D=3D NULL)
@@ -471,7 +472,7 @@
 		fp->fp_ttl =3D fpioc->fp_ttl;
 		SLIST_INIT(&fp->fp_oses);
 		if ((entry =3D pool_get(&pf_osfp_entry_pl,
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		    PR_NOWAIT)) =3D=3D NULL) {
 #else
 		    PR_WAITOK|PR_LIMITFAIL)) =3D=3D NULL) {
@@ -479,7 +480,7 @@
 			pool_put(&pf_osfp_pl, fp);
 			return (ENOMEM);
 		}
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		pf_osfp_insert(&V_pf_osfp_list, fp);
 #else
 		pf_osfp_insert(&pf_osfp_list, fp);
@@ -625,7 +626,7 @@
=20
=20
 	memset(fpioc, 0, sizeof(*fpioc));
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	SLIST_FOREACH(fp, &V_pf_osfp_list, fp_next) {
 #else
 	SLIST_FOREACH(fp, &pf_osfp_list, fp_next) {
@@ -656,7 +657,7 @@
 {
 	struct pf_os_fingerprint *f, *f2, find;
=20
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 	SLIST_FOREACH(f, &V_pf_osfp_list, fp_next) {
 #else
 	SLIST_FOREACH(f, &pf_osfp_list, fp_next) {
@@ -672,7 +673,7 @@
 			find.fp_wsize *=3D (find.fp_mss + 40);
 		else if (f->fp_flags & PF_OSFP_WSIZE_MOD)
 			find.fp_wsize *=3D 2;
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
 		if (f !=3D (f2 =3D pf_osfp_find(&V_pf_osfp_list, &find, 0))) {
 #else
 		if (f !=3D (f2 =3D pf_osfp_find(&pf_osfp_list, &find, 0))) {

--NzB8fVQJ5HfG6fxh--

--i0/AhcQY5QxfSsSZ
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/kFreeBSD)

iQIcBAEBCAAGBQJPJuB5AAoJELd1onhloKnOGr0P/0CMRrNRKSl4DcyrEQV5Y0Ms
veK5+pLzdyeFQ9hJtJhlGc7tqALEJ5BYxJwhNogUA92/XZ3+jHf8r4sa1Gdqy5ir
yf3PwqXHZZ+Fas/ys6brTBCWaeJhYqGSj6uYckuSlKSDWyQjNTtFevCmS1uQrwOQ
7r8nk2AIwokMIbTXXYGJk61eKBS8hbUxl66xV0yPofMf5yq1qT0WTp3X/0a8k4o3
+SeJ4AXI9Cc1AFXumdwmG5t+EqnAkDW6r7Ju1ZVAv3Iuk/C0bQTlFXJeim179v7x
dw6GlUwhcoj6wLdDrn5mG3vM4CMq8bFjZbuQhh+EZFd9q0UaW8HVeJs0bth+Kx/J
sNTrf6yliZZX/ar+iSX5SOjEN0xFl5xP0rjlmyZOR1F3RxqU1YGkLfkbgPjaQkKq
xq395MXk4gL/3YXz8euGHP6BfkO1RyZX/Q4KDR/0oj28ncAA6HXPkA3mC+9MmHQY
8Sw4oPQEGp3J6fUFOTv31R3ESbXuWlKCv4PLX36KDQlfyteJUq/LCZpWJO9L6iDq
OtR57c52jR4JfBCO2YrdMYaZT+UwtnAPHzaSgThjZE/IFBKtzqXGpZ+khIrxNHGA
/9rVzEMk+tthAnwgAZYstHHCNjjKDk0P5YAgGUJzZtIpSjVN33NAaVjRKPMowWXt
p1VeQ2AaAsuY3MkEKCjN
=GJ1N
-----END PGP SIGNATURE-----

--i0/AhcQY5QxfSsSZ--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120130182459.GA1096>