]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/pf_norm.c
xnu-4903.270.47.tar.gz
[apple/xnu.git] / bsd / net / pf_norm.c
index 3cb22e9ceb1200ef82108bf3fbf831a691ef8b39..9c28415dedc26a91ab246d8026b2a2e421ea8cd3 100644 (file)
 #include <net/pfvar.h>
 
 struct pf_frent {
-       LIST_ENTRY(pf_frent)    fr_next;
-       struct mbuf             *fr_m;
-#define fr_ip          fr_u.fru_ipv4
-#define fr_ip6         fr_u.fru_ipv6
+       LIST_ENTRY(pf_frent)    fr_next;
+       struct mbuf             *fr_m;
+#define fr_ip           fr_u.fru_ipv4
+#define fr_ip6          fr_u.fru_ipv6
        union {
-               struct ip       *fru_ipv4;
-               struct ip6_hdr  *fru_ipv6;
+               struct ip       *fru_ipv4;
+               struct ip6_hdr  *fru_ipv6;
        } fr_u;
-       struct ip6_frag         fr_ip6f_opt;
-       int                     fr_ip6f_hlen;
+       struct ip6_frag         fr_ip6f_opt;
+       int                     fr_ip6f_hlen;
 };
 
 struct pf_frcache {
        LIST_ENTRY(pf_frcache) fr_next;
-       uint16_t        fr_off;
-       uint16_t        fr_end;
+       uint16_t        fr_off;
+       uint16_t        fr_end;
 };
 
-#define PFFRAG_SEENLAST        0x0001          /* Seen the last fragment for this */
-#define PFFRAG_NOBUFFER        0x0002          /* Non-buffering fragment cache */
-#define PFFRAG_DROP    0x0004          /* Drop all fragments */
-#define BUFFER_FRAGMENTS(fr)   (!((fr)->fr_flags & PFFRAG_NOBUFFER))
+#define PFFRAG_SEENLAST 0x0001          /* Seen the last fragment for this */
+#define PFFRAG_NOBUFFER 0x0002          /* Non-buffering fragment cache */
+#define PFFRAG_DROP     0x0004          /* Drop all fragments */
+#define BUFFER_FRAGMENTS(fr)    (!((fr)->fr_flags & PFFRAG_NOBUFFER))
 
 struct pf_fragment {
        RB_ENTRY(pf_fragment) fr_entry;
        TAILQ_ENTRY(pf_fragment) frag_next;
-       struct pf_addr  fr_srcx;
-       struct pf_addr  fr_dstx;
-       u_int8_t        fr_p;           /* protocol of this fragment */
-       u_int8_t        fr_flags;       /* status flags */
-       u_int16_t       fr_max;         /* fragment data max */
-#define fr_id          fr_uid.fru_id4
-#define fr_id6         fr_uid.fru_id6
+       struct pf_addr  fr_srcx;
+       struct pf_addr  fr_dstx;
+       u_int8_t        fr_p;           /* protocol of this fragment */
+       u_int8_t        fr_flags;       /* status flags */
+       u_int16_t       fr_max;         /* fragment data max */
+#define fr_id           fr_uid.fru_id4
+#define fr_id6          fr_uid.fru_id6
        union {
-               u_int16_t       fru_id4;
-               u_int32_t       fru_id6;
+               u_int16_t       fru_id4;
+               u_int32_t       fru_id6;
        } fr_uid;
-       int             fr_af;
-       u_int32_t       fr_timeout;
-#define fr_queue       fr_u.fru_queue
-#define fr_cache       fr_u.fru_cache
+       int             fr_af;
+       u_int32_t       fr_timeout;
+#define fr_queue        fr_u.fru_queue
+#define fr_cache        fr_u.fru_cache
        union {
-               LIST_HEAD(pf_fragq, pf_frent) fru_queue;        /* buffering */
-               LIST_HEAD(pf_cacheq, pf_frcache) fru_cache;     /* non-buf */
+               LIST_HEAD(pf_fragq, pf_frent) fru_queue;        /* buffering */
+               LIST_HEAD(pf_cacheq, pf_frcache) fru_cache;     /* non-buf */
        } fr_u;
-       uint32_t        fr_csum_flags;  /* checksum flags */
-       uint32_t        fr_csum;        /* partial checksum value */
+       uint32_t        fr_csum_flags;  /* checksum flags */
+       uint32_t        fr_csum;        /* partial checksum value */
 };
 
-static TAILQ_HEAD(pf_fragqueue, pf_fragment)   pf_fragqueue;
-static TAILQ_HEAD(pf_cachequeue, pf_fragment)  pf_cachequeue;
+static TAILQ_HEAD(pf_fragqueue, pf_fragment)    pf_fragqueue;
+static TAILQ_HEAD(pf_cachequeue, pf_fragment)   pf_cachequeue;
 
 static __inline int  pf_frag_compare(struct pf_fragment *,
     struct pf_fragment *);
-static RB_HEAD(pf_frag_tree, pf_fragment)      pf_frag_tree, pf_cache_tree;
+static RB_HEAD(pf_frag_tree, pf_fragment)       pf_frag_tree, pf_cache_tree;
 RB_PROTOTYPE_SC(__private_extern__, pf_frag_tree, pf_fragment, fr_entry,
     pf_frag_compare);
 RB_GENERATE(pf_frag_tree, pf_fragment, fr_entry, pf_frag_compare);
@@ -158,9 +158,9 @@ static void pf_free_fragment(struct pf_fragment *);
 static struct pf_fragment *pf_find_fragment_by_key(struct pf_fragment *,
     struct pf_frag_tree *);
 static __inline struct pf_fragment *
-    pf_find_fragment_by_ipv4_header(struct ip *, struct pf_frag_tree *);
+pf_find_fragment_by_ipv4_header(struct ip *, struct pf_frag_tree *);
 static __inline struct pf_fragment *
-    pf_find_fragment_by_ipv6_header(struct ip6_hdr *, struct ip6_frag *,
+pf_find_fragment_by_ipv6_header(struct ip6_hdr *, struct ip6_frag *,
     struct pf_frag_tree *);
 static struct mbuf *pf_reassemble(struct mbuf *, struct pf_fragment **,
     struct pf_frent *, int);
@@ -173,32 +173,32 @@ static struct mbuf *pf_frag6cache(struct mbuf **, struct ip6_hdr*,
 static int pf_normalize_tcpopt(struct pf_rule *, int, struct pfi_kif *,
     struct pf_pdesc *, pbuf_t *, struct tcphdr *, int, int *);
 
-#define        DPFPRINTF(x) do {                               \
-       if (pf_status.debug >= PF_DEBUG_MISC) {         \
-               printf("%s: ", __func__);               \
-               printf x ;                              \
-       }                                               \
+#define DPFPRINTF(x) do {                               \
+       if (pf_status.debug >= PF_DEBUG_MISC) {         \
+               printf("%s: ", __func__);               \
+               printf x ;                              \
+       }                                               \
 } while (0)
 
 /* Globals */
-struct pool             pf_frent_pl, pf_frag_pl;
-static struct pool      pf_cache_pl, pf_cent_pl;
-struct pool             pf_state_scrub_pl;
+struct pool              pf_frent_pl, pf_frag_pl;
+static struct pool       pf_cache_pl, pf_cent_pl;
+struct pool              pf_state_scrub_pl;
 
-static int              pf_nfrents, pf_ncache;
+static int               pf_nfrents, pf_ncache;
 
 void
 pf_normalize_init(void)
 {
-       pool_init(&pf_frent_pl, sizeof (struct pf_frent), 0, 0, 0, "pffrent",
+       pool_init(&pf_frent_pl, sizeof(struct pf_frent), 0, 0, 0, "pffrent",
            NULL);
-       pool_init(&pf_frag_pl, sizeof (struct pf_fragment), 0, 0, 0, "pffrag",
+       pool_init(&pf_frag_pl, sizeof(struct pf_fragment), 0, 0, 0, "pffrag",
            NULL);
-       pool_init(&pf_cache_pl, sizeof (struct pf_fragment), 0, 0, 0,
+       pool_init(&pf_cache_pl, sizeof(struct pf_fragment), 0, 0, 0,
            "pffrcache", NULL);
-       pool_init(&pf_cent_pl, sizeof (struct pf_frcache), 0, 0, 0, "pffrcent",
+       pool_init(&pf_cent_pl, sizeof(struct pf_frcache), 0, 0, 0, "pffrcent",
            NULL);
-       pool_init(&pf_state_scrub_pl, sizeof (struct pf_state_scrub), 0, 0, 0,
+       pool_init(&pf_state_scrub_pl, sizeof(struct pf_state_scrub), 0, 0, 0,
            "pfstscr", NULL);
 
        pool_sethiwat(&pf_frag_pl, PFFRAG_FRAG_HIWAT);
@@ -225,75 +225,77 @@ pf_normalize_destroy(void)
 int
 pf_normalize_isempty(void)
 {
-       return (TAILQ_EMPTY(&pf_fragqueue) && TAILQ_EMPTY(&pf_cachequeue));
+       return TAILQ_EMPTY(&pf_fragqueue) && TAILQ_EMPTY(&pf_cachequeue);
 }
 
 static __inline int
 pf_frag_compare(struct pf_fragment *a, struct pf_fragment *b)
 {
-       int     diff;
+       int     diff;
 
-       if ((diff = a->fr_af - b->fr_af))
-               return (diff);
-       else if ((diff = a->fr_p - b->fr_p))
-               return (diff);
-       else {
+       if ((diff = a->fr_af - b->fr_af)) {
+               return diff;
+       } else if ((diff = a->fr_p - b->fr_p)) {
+               return diff;
+       else {
                struct pf_addr *sa = &a->fr_srcx;
                struct pf_addr *sb = &b->fr_srcx;
                struct pf_addr *da = &a->fr_dstx;
                struct pf_addr *db = &b->fr_dstx;
-               
+
                switch (a->fr_af) {
 #ifdef INET
                case AF_INET:
-                       if ((diff = a->fr_id - b->fr_id))
-                               return (diff);
-                       else if (sa->v4addr.s_addr < sb->v4addr.s_addr)
-                               return (-1);
-                       else if (sa->v4addr.s_addr > sb->v4addr.s_addr)
-                               return (1);
-                       else if (da->v4addr.s_addr < db->v4addr.s_addr)
-                               return (-1);
-                       else if (da->v4addr.s_addr > db->v4addr.s_addr)
-                               return (1);
+                       if ((diff = a->fr_id - b->fr_id)) {
+                               return diff;
+                       } else if (sa->v4addr.s_addr < sb->v4addr.s_addr) {
+                               return -1;
+                       } else if (sa->v4addr.s_addr > sb->v4addr.s_addr) {
+                               return 1;
+                       } else if (da->v4addr.s_addr < db->v4addr.s_addr) {
+                               return -1;
+                       } else if (da->v4addr.s_addr > db->v4addr.s_addr) {
+                               return 1;
+                       }
                        break;
 #endif
 #ifdef INET6
                case AF_INET6:
-                       if ((diff = a->fr_id6 - b->fr_id6))
-                               return (diff);
-                       else if (sa->addr32[3] < sb->addr32[3])
-                               return (-1);
-                       else if (sa->addr32[3] > sb->addr32[3])
-                               return (1);
-                       else if (sa->addr32[2] < sb->addr32[2])
-                               return (-1);
-                       else if (sa->addr32[2] > sb->addr32[2])
-                               return (1);
-                       else if (sa->addr32[1] < sb->addr32[1])
-                               return (-1);
-                       else if (sa->addr32[1] > sb->addr32[1])
-                               return (1);
-                       else if (sa->addr32[0] < sb->addr32[0])
-                               return (-1);
-                       else if (sa->addr32[0] > sb->addr32[0])
-                               return (1);
-                       else if (da->addr32[3] < db->addr32[3])
-                               return (-1);
-                       else if (da->addr32[3] > db->addr32[3])
-                               return (1);
-                       else if (da->addr32[2] < db->addr32[2])
-                               return (-1);
-                       else if (da->addr32[2] > db->addr32[2])
-                               return (1);
-                       else if (da->addr32[1] < db->addr32[1])
-                               return (-1);
-                       else if (da->addr32[1] > db->addr32[1])
-                               return (1);
-                       else if (da->addr32[0] < db->addr32[0])
-                               return (-1);
-                       else if (da->addr32[0] > db->addr32[0])
-                               return (1);
+                       if ((diff = a->fr_id6 - b->fr_id6)) {
+                               return diff;
+                       } else if (sa->addr32[3] < sb->addr32[3]) {
+                               return -1;
+                       } else if (sa->addr32[3] > sb->addr32[3]) {
+                               return 1;
+                       } else if (sa->addr32[2] < sb->addr32[2]) {
+                               return -1;
+                       } else if (sa->addr32[2] > sb->addr32[2]) {
+                               return 1;
+                       } else if (sa->addr32[1] < sb->addr32[1]) {
+                               return -1;
+                       } else if (sa->addr32[1] > sb->addr32[1]) {
+                               return 1;
+                       } else if (sa->addr32[0] < sb->addr32[0]) {
+                               return -1;
+                       } else if (sa->addr32[0] > sb->addr32[0]) {
+                               return 1;
+                       } else if (da->addr32[3] < db->addr32[3]) {
+                               return -1;
+                       } else if (da->addr32[3] > db->addr32[3]) {
+                               return 1;
+                       } else if (da->addr32[2] < db->addr32[2]) {
+                               return -1;
+                       } else if (da->addr32[2] > db->addr32[2]) {
+                               return 1;
+                       } else if (da->addr32[1] < db->addr32[1]) {
+                               return -1;
+                       } else if (da->addr32[1] > db->addr32[1]) {
+                               return 1;
+                       } else if (da->addr32[0] < db->addr32[0]) {
+                               return -1;
+                       } else if (da->addr32[0] > db->addr32[0]) {
+                               return 1;
+                       }
                        break;
 #endif
                default:
@@ -301,7 +303,7 @@ pf_frag_compare(struct pf_fragment *a, struct pf_fragment *b)
                        break;
                }
        }
-       return (0);
+       return 0;
 }
 
 void
@@ -313,46 +315,48 @@ pf_purge_expired_fragments(void)
 
        while ((frag = TAILQ_LAST(&pf_fragqueue, pf_fragqueue)) != NULL) {
                VERIFY(BUFFER_FRAGMENTS(frag));
-               if (frag->fr_timeout > expire)
+               if (frag->fr_timeout > expire) {
                        break;
+               }
 
                switch (frag->fr_af) {
                case AF_INET:
-                     DPFPRINTF(("expiring IPv4 %d(0x%llx) from queue.\n",
-                         ntohs(frag->fr_id),
-                         (uint64_t)VM_KERNEL_ADDRPERM(frag)));
-                     break;
+                       DPFPRINTF(("expiring IPv4 %d(0x%llx) from queue.\n",
+                           ntohs(frag->fr_id),
+                           (uint64_t)VM_KERNEL_ADDRPERM(frag)));
+                       break;
                case AF_INET6:
-                     DPFPRINTF(("expiring IPv6 %d(0x%llx) from queue.\n",
-                         ntohl(frag->fr_id6),
-                         (uint64_t)VM_KERNEL_ADDRPERM(frag)));
-                     break;
+                       DPFPRINTF(("expiring IPv6 %d(0x%llx) from queue.\n",
+                           ntohl(frag->fr_id6),
+                           (uint64_t)VM_KERNEL_ADDRPERM(frag)));
+                       break;
                default:
-                     VERIFY(0 && "only IPv4 and IPv6 supported");
-                     break;
+                       VERIFY(0 && "only IPv4 and IPv6 supported");
+                       break;
                }
                pf_free_fragment(frag);
        }
 
        while ((frag = TAILQ_LAST(&pf_cachequeue, pf_cachequeue)) != NULL) {
                VERIFY(!BUFFER_FRAGMENTS(frag));
-               if (frag->fr_timeout > expire)
+               if (frag->fr_timeout > expire) {
                        break;
+               }
 
                switch (frag->fr_af) {
                case AF_INET:
-                     DPFPRINTF(("expiring IPv4 %d(0x%llx) from cache.\n",
-                         ntohs(frag->fr_id),
-                         (uint64_t)VM_KERNEL_ADDRPERM(frag)));
-                     break;
+                       DPFPRINTF(("expiring IPv4 %d(0x%llx) from cache.\n",
+                           ntohs(frag->fr_id),
+                           (uint64_t)VM_KERNEL_ADDRPERM(frag)));
+                       break;
                case AF_INET6:
-                     DPFPRINTF(("expiring IPv6 %d(0x%llx) from cache.\n",
-                         ntohl(frag->fr_id6),
-                         (uint64_t)VM_KERNEL_ADDRPERM(frag)));
-                     break;
+                       DPFPRINTF(("expiring IPv6 %d(0x%llx) from cache.\n",
+                           ntohl(frag->fr_id6),
+                           (uint64_t)VM_KERNEL_ADDRPERM(frag)));
+                       break;
                default:
-                     VERIFY(0 && "only IPv4 and IPv6 supported");
-                     break;
+                       VERIFY(0 && "only IPv4 and IPv6 supported");
+                       break;
                }
                pf_free_fragment(frag);
                VERIFY(TAILQ_EMPTY(&pf_cachequeue) ||
@@ -367,16 +371,17 @@ pf_purge_expired_fragments(void)
 static void
 pf_flush_fragments(void)
 {
-       struct pf_fragment      *frag;
-       int                      goal;
+       struct pf_fragment      *frag;
+       int                      goal;
 
        goal = pf_nfrents * 9 / 10;
        DPFPRINTF(("trying to free > %d frents\n",
            pf_nfrents - goal));
        while (goal < pf_nfrents) {
                frag = TAILQ_LAST(&pf_fragqueue, pf_fragqueue);
-               if (frag == NULL)
+               if (frag == NULL) {
                        break;
+               }
                pf_free_fragment(frag);
        }
 
@@ -386,8 +391,9 @@ pf_flush_fragments(void)
            pf_ncache - goal));
        while (goal < pf_ncache) {
                frag = TAILQ_LAST(&pf_cachequeue, pf_cachequeue);
-               if (frag == NULL)
+               if (frag == NULL) {
                        break;
+               }
                pf_free_fragment(frag);
        }
 }
@@ -397,8 +403,8 @@ pf_flush_fragments(void)
 static void
 pf_free_fragment(struct pf_fragment *frag)
 {
-       struct pf_frent         *frent;
-       struct pf_frcache       *frcache;
+       struct pf_frent         *frent;
+       struct pf_frcache       *frcache;
 
        /* Free all fragments */
        if (BUFFER_FRAGMENTS(frag)) {
@@ -437,7 +443,7 @@ pf_ip6hdr2key(struct pf_fragment *key, struct ip6_hdr *ip6,
        key->fr_srcx.v6addr = ip6->ip6_src;
        key->fr_dstx.v6addr = ip6->ip6_dst;
 }
+
 static void
 pf_ip2key(struct pf_fragment *key, struct ip *ip)
 {
@@ -452,7 +458,7 @@ static struct pf_fragment *
 pf_find_fragment_by_key(struct pf_fragment *key, struct pf_frag_tree *tree)
 {
        struct pf_fragment *frag;
-       
+
        frag = RB_FIND(pf_frag_tree, tree, key);
        if (frag != NULL) {
                /* XXX Are we sure we want to update the timeout? */
@@ -465,10 +471,10 @@ pf_find_fragment_by_key(struct pf_fragment *key, struct pf_frag_tree *tree)
                        TAILQ_INSERT_HEAD(&pf_cachequeue, frag, frag_next);
                }
        }
-       
-       return (frag);
+
+       return frag;
 }
-  
+
 static __inline struct pf_fragment *
 pf_find_fragment_by_ipv4_header(struct ip *ip, struct pf_frag_tree *tree)
 {
@@ -481,9 +487,9 @@ static __inline struct pf_fragment *
 pf_find_fragment_by_ipv6_header(struct ip6_hdr *ip6, struct ip6_frag *fh,
     struct pf_frag_tree *tree)
 {
-      struct pf_fragment key;
-      pf_ip6hdr2key(&key, ip6, fh);
-      return pf_find_fragment_by_key(&key, tree);
+       struct pf_fragment key;
+       pf_ip6hdr2key(&key, ip6, fh);
+       return pf_find_fragment_by_key(&key, tree);
 }
 
 /* Removes a fragment from the fragment queue and frees the fragment */
@@ -502,20 +508,20 @@ pf_remove_fragment(struct pf_fragment *frag)
        }
 }
 
-#define FR_IP_OFF(fr)  ((ntohs((fr)->fr_ip->ip_off) & IP_OFFMASK) << 3)
+#define FR_IP_OFF(fr)   ((ntohs((fr)->fr_ip->ip_off) & IP_OFFMASK) << 3)
 static struct mbuf *
 pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
     struct pf_frent *frent, int mff)
 {
-       struct mbuf     *m = m0, *m2;
-       struct pf_frent *frea, *next;
-       struct pf_frent *frep = NULL;
-       struct ip       *ip = frent->fr_ip;
-       uint32_t         hlen = ip->ip_hl << 2;
-       u_int16_t        off = (ntohs(ip->ip_off) & IP_OFFMASK) << 3;
-       u_int16_t        ip_len = ntohs(ip->ip_len) - ip->ip_hl * 4;
-       u_int16_t        fr_max = ip_len + off;
-       uint32_t         csum, csum_flags;
+       struct mbuf     *m = m0, *m2;
+       struct pf_frent *frea, *next;
+       struct pf_frent *frep = NULL;
+       struct ip       *ip = frent->fr_ip;
+       uint32_t         hlen = ip->ip_hl << 2;
+       u_int16_t        off = (ntohs(ip->ip_off) & IP_OFFMASK) << 3;
+       u_int16_t        ip_len = ntohs(ip->ip_len) - ip->ip_hl * 4;
+       u_int16_t        fr_max = ip_len + off;
+       uint32_t         csum, csum_flags;
 
        VERIFY(*frag == NULL || BUFFER_FRAGMENTS(*frag));
 
@@ -531,7 +537,7 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
         * has already performed its header checksum validation.  Also take
         * care of any trailing bytes and subtract out their partial sum.
         */
-       if (ip->ip_p == IPPROTO_UDP && hlen == sizeof (struct ip) &&
+       if (ip->ip_p == IPPROTO_UDP && hlen == sizeof(struct ip) &&
            (m->m_pkthdr.csum_flags &
            (CSUM_DATA_VALID | CSUM_PARTIAL | CSUM_PSEUDO_HDR)) ==
            (CSUM_DATA_VALID | CSUM_PARTIAL)) {
@@ -552,10 +558,11 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
                        /* callee folds in sum */
                        csum = m_adj_sum16(m, start, hlen,
                            (ip->ip_len - hlen), csum);
-                       if (hlen > start)
+                       if (hlen > start) {
                                swbytes += (hlen - start);
-                       else
+                       } else {
                                swbytes += (start - hlen);
+                       }
 #if BYTE_ORDER != BIG_ENDIAN
                        if (start < hlen) {
                                NTOHS(ip->ip_off);
@@ -565,10 +572,12 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
                }
                csum_flags = m->m_pkthdr.csum_flags;
 
-               if (swbytes != 0)
+               if (swbytes != 0) {
                        udp_in_cksum_stats(swbytes);
-               if (trailer != 0)
+               }
+               if (trailer != 0) {
                        m_adj(m, -trailer);
+               }
        } else {
                csum = 0;
                csum_flags = 0;
@@ -587,8 +596,9 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
                if (*frag == NULL) {
                        pf_flush_fragments();
                        *frag = pool_get(&pf_frag_pl, PR_NOWAIT);
-                       if (*frag == NULL)
+                       if (*frag == NULL) {
                                goto drop_fragment;
+                       }
                }
 
                (*frag)->fr_flags = 0;
@@ -618,18 +628,20 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
         * as that of the existing ones, accumulate checksum.  Otherwise,
         * invalidate checksum offload info for the entire datagram.
         */
-       if (csum_flags != 0 && csum_flags == (*frag)->fr_csum_flags)
+       if (csum_flags != 0 && csum_flags == (*frag)->fr_csum_flags) {
                (*frag)->fr_csum += csum;
-       else if ((*frag)->fr_csum_flags != 0)
+       } else if ((*frag)->fr_csum_flags != 0) {
                (*frag)->fr_csum_flags = 0;
+       }
 
        /*
         * Find a fragment after the current one:
         *  - off contains the real shifted offset.
         */
        LIST_FOREACH(frea, &(*frag)->fr_queue, fr_next) {
-               if (FR_IP_OFF(frea) > off)
+               if (FR_IP_OFF(frea) > off) {
                        break;
+               }
                frep = frea;
        }
 
@@ -638,12 +650,13 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
        if (frep != NULL &&
            FR_IP_OFF(frep) + ntohs(frep->fr_ip->ip_len) - frep->fr_ip->ip_hl *
            4 > off) {
-               u_int16_t       precut;
+               u_int16_t       precut;
 
                precut = FR_IP_OFF(frep) + ntohs(frep->fr_ip->ip_len) -
                    frep->fr_ip->ip_hl * 4 - off;
-               if (precut >= ip_len)
+               if (precut >= ip_len) {
                        goto drop_fragment;
+               }
                m_adj(frent->fr_m, precut);
                DPFPRINTF(("overlap -%d\n", precut));
                /* Enforce 8 byte boundaries */
@@ -655,7 +668,7 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
 
        for (; frea != NULL && ip_len + off > FR_IP_OFF(frea);
            frea = next) {
-               u_int16_t       aftercut;
+               u_int16_t       aftercut;
 
                aftercut = ip_len + off - FR_IP_OFF(frea);
                DPFPRINTF(("adjust overlap %d\n", aftercut));
@@ -679,20 +692,24 @@ pf_reassemble(struct mbuf *m0, struct pf_fragment **frag,
 
 insert:
        /* Update maximum data size */
-       if ((*frag)->fr_max < fr_max)
+       if ((*frag)->fr_max < fr_max) {
                (*frag)->fr_max = fr_max;
+       }
        /* This is the last segment */
-       if (!mff)
+       if (!mff) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
+       }
 
-       if (frep == NULL)
+       if (frep == NULL) {
                LIST_INSERT_HEAD(&(*frag)->fr_queue, frent, fr_next);
-       else
+       } else {
                LIST_INSERT_AFTER(frep, frent, fr_next);
+       }
 
        /* Check if we are completely reassembled */
-       if (!((*frag)->fr_flags & PFFRAG_SEENLAST))
-               return (NULL);
+       if (!((*frag)->fr_flags & PFFRAG_SEENLAST)) {
+               return NULL;
+       }
 
        /* Check if we have all the data */
        off = 0;
@@ -705,12 +722,13 @@ insert:
                        DPFPRINTF(("missing fragment at %d, next %d, max %d\n",
                            off, next == NULL ? -1 : FR_IP_OFF(next),
                            (*frag)->fr_max));
-                       return (NULL);
+                       return NULL;
                }
        }
        DPFPRINTF(("%d < %d?\n", off, (*frag)->fr_max));
-       if (off < (*frag)->fr_max)
-               return (NULL);
+       if (off < (*frag)->fr_max) {
+               return NULL;
+       }
 
        /* We have all the data */
        frent = LIST_FIRST(&(*frag)->fr_queue);
@@ -719,7 +737,7 @@ insert:
                DPFPRINTF(("drop: too big: %d\n", off));
                pf_free_fragment(*frag);
                *frag = NULL;
-               return (NULL);
+               return NULL;
        }
        next = LIST_NEXT(frent, fr_next);
 
@@ -749,7 +767,7 @@ insert:
                ADDCARRY(csum);
 
                m->m_pkthdr.csum_rx_val = csum;
-               m->m_pkthdr.csum_rx_start = sizeof (struct ip);
+               m->m_pkthdr.csum_rx_start = sizeof(struct ip);
                m->m_pkthdr.csum_flags = (*frag)->fr_csum_flags;
        } else if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) ||
            (m->m_pkthdr.pkt_flags & PKTF_LOOP)) {
@@ -774,33 +792,34 @@ insert:
        /* XXX this should be done elsewhere */
        if (m->m_flags & M_PKTHDR) {
                int plen = 0;
-               for (m2 = m; m2; m2 = m2->m_next)
+               for (m2 = m; m2; m2 = m2->m_next) {
                        plen += m2->m_len;
+               }
                m->m_pkthdr.len = plen;
        }
 
        DPFPRINTF(("complete: 0x%llx(%d)\n",
            (uint64_t)VM_KERNEL_ADDRPERM(m), ntohs(ip->ip_len)));
-       return (m);
+       return m;
 
 drop_fragment:
        /* Oops - fail safe - drop packet */
        pool_put(&pf_frent_pl, frent);
        pf_nfrents--;
        m_freem(m);
-       return (NULL);
+       return NULL;
 }
 
 static struct mbuf *
 pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
     int drop, int *nomem)
 {
-       struct mbuf             *m = *m0;
-       struct pf_frcache       *frp, *fra, *cur = NULL;
-       int                      ip_len = ntohs(h->ip_len) - (h->ip_hl << 2);
-       u_int16_t                off = ntohs(h->ip_off) << 3;
-       u_int16_t                fr_max = ip_len + off;
-       int                      hosed = 0;
+       struct mbuf             *m = *m0;
+       struct pf_frcache       *frp, *fra, *cur = NULL;
+       int                      ip_len = ntohs(h->ip_len) - (h->ip_hl << 2);
+       u_int16_t                off = ntohs(h->ip_off) << 3;
+       u_int16_t                fr_max = ip_len + off;
+       int                      hosed = 0;
 
        VERIFY(*frag == NULL || !BUFFER_FRAGMENTS(*frag));
 
@@ -810,8 +829,9 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                if (*frag == NULL) {
                        pf_flush_fragments();
                        *frag = pool_get(&pf_cache_pl, PR_NOWAIT);
-                       if (*frag == NULL)
+                       if (*frag == NULL) {
                                goto no_mem;
+                       }
                }
 
                /* Get an entry for the queue */
@@ -852,15 +872,16 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
         */
        frp = NULL;
        LIST_FOREACH(fra, &(*frag)->fr_cache, fr_next) {
-               if (fra->fr_off > off)
+               if (fra->fr_off > off) {
                        break;
+               }
                frp = fra;
        }
 
        VERIFY(frp != NULL || fra != NULL);
 
        if (frp != NULL) {
-               int     precut;
+               int     precut;
 
                precut = frp->fr_end - off;
                if (precut >= ip_len) {
@@ -902,8 +923,9 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                                 * I'll pull a rabbit out of my laptop.
                                 */
                                *m0 = m_copym(m, 0, h->ip_hl << 2, M_NOWAIT);
-                               if (*m0 == NULL)
+                               if (*m0 == NULL) {
                                        goto no_mem;
+                               }
                                VERIFY((*m0)->m_next == NULL);
                                m_adj(m, precut + (h->ip_hl << 2));
                                m_cat(*m0, m);
@@ -911,8 +933,9 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                                if (m->m_flags & M_PKTHDR) {
                                        int plen = 0;
                                        struct mbuf *t;
-                                       for (t = m; t; t = t->m_next)
+                                       for (t = m; t; t = t->m_next) {
                                                plen += t->m_len;
+                                       }
                                        m->m_pkthdr.len = plen;
                                }
 
@@ -936,8 +959,9 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                            fr_max));
 
                        cur = pool_get(&pf_cent_pl, PR_NOWAIT);
-                       if (cur == NULL)
+                       if (cur == NULL) {
                                goto no_mem;
+                       }
                        pf_ncache++;
 
                        cur->fr_off = off;
@@ -947,8 +971,8 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
        }
 
        if (fra != NULL) {
-               int     aftercut;
-               int     merge = 0;
+               int     aftercut;
+               int     merge = 0;
 
                aftercut = fr_max - fra->fr_off;
                if (aftercut == 0) {
@@ -972,8 +996,9 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                                if (m->m_flags & M_PKTHDR) {
                                        int plen = 0;
                                        struct mbuf *t;
-                                       for (t = m; t; t = t->m_next)
+                                       for (t = m; t; t = t->m_next) {
                                                plen += t->m_len;
+                                       }
                                        m->m_pkthdr.len = plen;
                                }
                                h = mtod(m, struct ip *);
@@ -990,8 +1015,9 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                            fra->fr_end));
 
                        cur = pool_get(&pf_cent_pl, PR_NOWAIT);
-                       if (cur == NULL)
+                       if (cur == NULL) {
                                goto no_mem;
+                       }
                        pf_ncache++;
 
                        cur->fr_off = off;
@@ -1013,7 +1039,6 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                                pool_put(&pf_cent_pl, cur);
                                pf_ncache--;
                                cur = NULL;
-
                        } else if (frp && fra->fr_off <= frp->fr_end) {
                                /* Need to merge in a modified 'frp' */
                                VERIFY(cur == NULL);
@@ -1026,7 +1051,6 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
                                pool_put(&pf_cent_pl, frp);
                                pf_ncache--;
                                frp = NULL;
-
                        }
                }
        }
@@ -1043,12 +1067,14 @@ pf_fragcache(struct mbuf **m0, struct ip *h, struct pf_fragment **frag, int mff,
 
 pass:
        /* Update maximum data size */
-       if ((*frag)->fr_max < fr_max)
+       if ((*frag)->fr_max < fr_max) {
                (*frag)->fr_max = fr_max;
+       }
 
        /* This is the last segment */
-       if (!mff)
+       if (!mff) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
+       }
 
        /* Check if we are completely reassembled */
        if (((*frag)->fr_flags & PFFRAG_SEENLAST) &&
@@ -1061,34 +1087,37 @@ pass:
                *frag = NULL;
        }
 
-       return (m);
+       return m;
 
 no_mem:
        *nomem = 1;
 
        /* Still need to pay attention to !IP_MF */
-       if (!mff && *frag != NULL)
+       if (!mff && *frag != NULL) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
+       }
 
        m_freem(m);
-       return (NULL);
+       return NULL;
 
 drop_fragment:
 
        /* Still need to pay attention to !IP_MF */
-       if (!mff && *frag != NULL)
+       if (!mff && *frag != NULL) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
+       }
 
        if (drop) {
                /* This fragment has been deemed bad.  Don't reass */
-               if (((*frag)->fr_flags & PFFRAG_DROP) == 0)
+               if (((*frag)->fr_flags & PFFRAG_DROP) == 0) {
                        DPFPRINTF(("fragcache[%d]: dropping overall fragment\n",
                            h->ip_id));
+               }
                (*frag)->fr_flags |= PFFRAG_DROP;
        }
 
        m_freem(m);
-       return (NULL);
+       return NULL;
 }
 
 #define FR_IP6_OFF(fr) \
@@ -1104,7 +1133,7 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
        struct ip6_frag *ip6f;
        int plen, off, fr_max;
        uint32_t uoff, csum, csum_flags;
-       
+
        VERIFY(*frag == NULL || BUFFER_FRAGMENTS(*frag));
        m = *m0;
        frep = NULL;
@@ -1128,12 +1157,12 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
         * care of any trailing bytes and subtract out their partial sum.
         */
        if (ip6f->ip6f_nxt == IPPROTO_UDP &&
-           uoff == (sizeof (*ip6) + sizeof (*ip6f)) &&
+           uoff == (sizeof(*ip6) + sizeof(*ip6f)) &&
            (m->m_pkthdr.csum_flags &
            (CSUM_DATA_VALID | CSUM_PARTIAL | CSUM_PSEUDO_HDR)) ==
            (CSUM_DATA_VALID | CSUM_PARTIAL)) {
                uint32_t start = m->m_pkthdr.csum_rx_start;
-               uint32_t ip_len = (sizeof (*ip6) + ntohs(ip6->ip6_plen));
+               uint32_t ip_len = (sizeof(*ip6) + ntohs(ip6->ip6_plen));
                int32_t trailer = (m_pktlen(m) - ip_len);
                uint32_t swbytes = (uint32_t)trailer;
 
@@ -1145,7 +1174,7 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
 
                        if (IN6_IS_SCOPE_EMBED(&ip6->ip6_src)) {
                                s = ip6->ip6_src.s6_addr16[1];
-                               ip6->ip6_src.s6_addr16[1] = 0 ;
+                               ip6->ip6_src.s6_addr16[1] = 0;
                        }
                        if (IN6_IS_SCOPE_EMBED(&ip6->ip6_dst)) {
                                d = ip6->ip6_dst.s6_addr16[1];
@@ -1155,23 +1184,27 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                        /* callee folds in sum */
                        csum = m_adj_sum16(m, start, uoff,
                            (ip_len - uoff), csum);
-                       if (uoff > start)
+                       if (uoff > start) {
                                swbytes += (uoff - start);
-                       else
+                       } else {
                                swbytes += (start - uoff);
+                       }
 
-                       if (IN6_IS_SCOPE_EMBED(&ip6->ip6_src))
+                       if (IN6_IS_SCOPE_EMBED(&ip6->ip6_src)) {
                                ip6->ip6_src.s6_addr16[1] = s;
-                       if (IN6_IS_SCOPE_EMBED(&ip6->ip6_dst))
+                       }
+                       if (IN6_IS_SCOPE_EMBED(&ip6->ip6_dst)) {
                                ip6->ip6_dst.s6_addr16[1] = d;
-
+                       }
                }
                csum_flags = m->m_pkthdr.csum_flags;
 
-               if (swbytes != 0)
+               if (swbytes != 0) {
                        udp_in6_cksum_stats(swbytes);
-               if (trailer != 0)
+               }
+               if (trailer != 0) {
                        m_adj(m, -trailer);
+               }
        } else {
                csum = 0;
                csum_flags = 0;
@@ -1179,21 +1212,22 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
 
        /* Invalidate checksum */
        m->m_pkthdr.csum_flags &= ~CSUM_DATA_VALID;
-       
+
        /* strip off headers up to the fragment payload */
        m->m_data += frent->fr_ip6f_hlen;
        m->m_len -= frent->fr_ip6f_hlen;
-       
+
        /* Create a new reassembly queue for this packet */
        if (*frag == NULL) {
                *frag = pool_get(&pf_frag_pl, PR_NOWAIT);
                if (*frag == NULL) {
                        pf_flush_fragments();
                        *frag = pool_get(&pf_frag_pl, PR_NOWAIT);
-                       if (*frag == NULL)
+                       if (*frag == NULL) {
                                goto drop_fragment;
+                       }
                }
-               
+
                (*frag)->fr_flags = 0;
                (*frag)->fr_max = 0;
                (*frag)->fr_af = AF_INET6;
@@ -1207,10 +1241,10 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                        (*frag)->fr_csum = csum;
                }
                LIST_INIT(&(*frag)->fr_queue);
-               
+
                RB_INSERT(pf_frag_tree, &pf_frag_tree, *frag);
                TAILQ_INSERT_HEAD(&pf_fragqueue, *frag, frag_next);
-               
+
                /* We do not have a previous fragment */
                frep = NULL;
                goto insert;
@@ -1221,32 +1255,34 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
         * as that of the existing ones, accumulate checksum.  Otherwise,
         * invalidate checksum offload info for the entire datagram.
         */
-       if (csum_flags != 0 && csum_flags == (*frag)->fr_csum_flags)
+       if (csum_flags != 0 && csum_flags == (*frag)->fr_csum_flags) {
                (*frag)->fr_csum += csum;
-       else if ((*frag)->fr_csum_flags != 0)
+       } else if ((*frag)->fr_csum_flags != 0) {
                (*frag)->fr_csum_flags = 0;
-       
+       }
+
        /*
         * Find a fragment after the current one:
         *  - off contains the real shifted offset.
         */
        LIST_FOREACH(frea, &(*frag)->fr_queue, fr_next) {
-               if (FR_IP6_OFF(frea) > off)
+               if (FR_IP6_OFF(frea) > off) {
                        break;
+               }
                frep = frea;
        }
-       
+
        VERIFY(frep != NULL || frea != NULL);
-       
+
        if (frep != NULL &&
-           FR_IP6_OFF(frep) + FR_IP6_PLEN(frep) - frep->fr_ip6f_hlen > off)
-       {
+           FR_IP6_OFF(frep) + FR_IP6_PLEN(frep) - frep->fr_ip6f_hlen > off) {
                u_int16_t precut;
-               
+
                precut = FR_IP6_OFF(frep) + FR_IP6_PLEN(frep) -
                    frep->fr_ip6f_hlen - off;
-               if (precut >= plen)
+               if (precut >= plen) {
                        goto drop_fragment;
+               }
                m_adj(frent->fr_m, precut);
                DPFPRINTF(("overlap -%d\n", precut));
                /* Enforce 8 byte boundaries */
@@ -1257,22 +1293,22 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                plen -= precut;
                ip6->ip6_plen = htons(plen);
        }
-       
+
        for (; frea != NULL && plen + off > FR_IP6_OFF(frea); frea = next) {
-               u_int16_t       aftercut;
-               
+               u_int16_t       aftercut;
+
                aftercut = plen + off - FR_IP6_OFF(frea);
                DPFPRINTF(("adjust overlap %d\n", aftercut));
                if (aftercut < FR_IP6_PLEN(frea) - frea->fr_ip6f_hlen) {
                        frea->fr_ip6->ip6_plen = htons(FR_IP6_PLEN(frea) -
-                               aftercut);
+                           aftercut);
                        frea->fr_ip6f_opt.ip6f_offlg =
                            htons(ntohs(frea->fr_ip6f_opt.ip6f_offlg) +
                            (aftercut >> 3));
                        m_adj(frea->fr_m, aftercut);
                        break;
                }
-               
+
                /* This fragment is completely overlapped, lose it */
                next = LIST_NEXT(frea, fr_next);
                m_freem(frea->fr_m);
@@ -1280,44 +1316,49 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                pool_put(&pf_frent_pl, frea);
                pf_nfrents--;
        }
-       
-  insert:
+
+insert:
        /* Update maximum data size */
-       if ((*frag)->fr_max < fr_max)
+       if ((*frag)->fr_max < fr_max) {
                (*frag)->fr_max = fr_max;
+       }
        /* This is the last segment */
-       if (!mff)
+       if (!mff) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
-       
-       if (frep == NULL)
+       }
+
+       if (frep == NULL) {
                LIST_INSERT_HEAD(&(*frag)->fr_queue, frent, fr_next);
-       else
+       } else {
                LIST_INSERT_AFTER(frep, frent, fr_next);
-       
+       }
+
        /* Check if we are completely reassembled */
-       if (!((*frag)->fr_flags & PFFRAG_SEENLAST))
-               return (NULL);
-       
+       if (!((*frag)->fr_flags & PFFRAG_SEENLAST)) {
+               return NULL;
+       }
+
        /* Check if we have all the data */
        off = 0;
        for (frep = LIST_FIRST(&(*frag)->fr_queue); frep; frep = next) {
                next = LIST_NEXT(frep, fr_next);
                off += FR_IP6_PLEN(frep) - (frent->fr_ip6f_hlen - sizeof *ip6);
                DPFPRINTF(("frep at %d, next %d, max %d\n",
-                       off, next == NULL ? -1 : FR_IP6_OFF(next),
-                       (*frag)->fr_max));
+                   off, next == NULL ? -1 : FR_IP6_OFF(next),
+                   (*frag)->fr_max));
                if (off < (*frag)->fr_max &&
                    (next == NULL || FR_IP6_OFF(next) != off)) {
                        DPFPRINTF(("missing fragment at %d, next %d, max %d\n",
                            off, next == NULL ? -1 : FR_IP6_OFF(next),
                            (*frag)->fr_max));
-                       return (NULL);
+                       return NULL;
                }
        }
        DPFPRINTF(("%d < %d?\n", off, (*frag)->fr_max));
-       if (off < (*frag)->fr_max)
-               return (NULL);
-       
+       if (off < (*frag)->fr_max) {
+               return NULL;
+       }
+
        /* We have all the data */
        frent = LIST_FIRST(&(*frag)->fr_queue);
        VERIFY(frent != NULL);
@@ -1325,9 +1366,9 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                DPFPRINTF(("drop: too big: %d\n", off));
                pf_free_fragment(*frag);
                *frag = NULL;
-               return (NULL);
+               return NULL;
        }
-       
+
        ip6 = frent->fr_ip6;
        ip6->ip6_nxt = (*frag)->fr_p;
        ip6->ip6_plen = htons(off);
@@ -1340,7 +1381,7 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                ADDCARRY(csum);
 
                m->m_pkthdr.csum_rx_val = csum;
-               m->m_pkthdr.csum_rx_start = sizeof (struct ip6_hdr);
+               m->m_pkthdr.csum_rx_start = sizeof(struct ip6_hdr);
                m->m_pkthdr.csum_flags = (*frag)->fr_csum_flags;
        } else if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) ||
            (m->m_pkthdr.pkt_flags & PKTF_LOOP)) {
@@ -1349,16 +1390,16 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                m->m_pkthdr.csum_flags &= ~CSUM_PARTIAL;
                m->m_pkthdr.csum_flags = CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
        }
-       
+
        /* Remove from fragment queue */
        pf_remove_fragment(*frag);
        *frag = NULL;
-       
+
        m = frent->fr_m;
        m->m_len += sizeof(struct ip6_hdr);
        m->m_data -= sizeof(struct ip6_hdr);
        memmove(m->m_data, ip6, sizeof(struct ip6_hdr));
-       
+
        next = LIST_NEXT(frent, fr_next);
        pool_put(&pf_frent_pl, frent);
        pf_nfrents--;
@@ -1370,22 +1411,23 @@ pf_reassemble6(struct mbuf **m0, struct pf_fragment **frag,
                pool_put(&pf_frent_pl, frent);
                pf_nfrents--;
        }
-       
+
        /* XXX this should be done elsewhere */
        if (m->m_flags & M_PKTHDR) {
                int pktlen = 0;
-               for (m2 = m; m2; m2 = m2->m_next)
+               for (m2 = m; m2; m2 = m2->m_next) {
                        pktlen += m2->m_len;
+               }
                m->m_pkthdr.len = pktlen;
        }
-       
+
        DPFPRINTF(("complete: 0x%llx ip6_plen %d m_pkthdr.len %d\n",
            (uint64_t)VM_KERNEL_ADDRPERM(m), ntohs(ip6->ip6_plen),
            m->m_pkthdr.len));
 
        return m;
-       
- drop_fragment:
+
+drop_fragment:
        /* Oops - fail safe - drop packet */
        pool_put(&pf_frent_pl, frent);
        --pf_nfrents;
@@ -1401,7 +1443,7 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
        u_int16_t plen, off, fr_max;
        struct pf_frcache *frp, *fra, *cur = NULL;
        int hosed = 0;
-       
+
        VERIFY(*frag == NULL || !BUFFER_FRAGMENTS(*frag));
        m = *m0;
        off = ntohs(fh->ip6f_offlg & IP6F_OFF_MASK);
@@ -1409,7 +1451,7 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
 
        /*
         * Apple Modification: dimambro@apple.com. The hlen, being passed
-        * into this function Includes all the headers associated with 
+        * into this function Includes all the headers associated with
         * the packet, and may include routing headers, so to get to
         * the data payload as stored in the original IPv6 header we need
         * to subtract al those headers and the IP header.
@@ -1425,7 +1467,7 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
         *   of the IPv6 packet to the beginning of the data.
         */
        fr_max = off + plen;
-       
+
        DPFPRINTF(("0x%llx plen %u off %u fr_max %u\n",
            (uint64_t)VM_KERNEL_ADDRPERM(m), plen, off, fr_max));
 
@@ -1435,10 +1477,11 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                if (*frag == NULL) {
                        pf_flush_fragments();
                        *frag = pool_get(&pf_cache_pl, PR_NOWAIT);
-                       if (*frag == NULL)
+                       if (*frag == NULL) {
                                goto no_mem;
+                       }
                }
-               
+
                /* Get an entry for the queue */
                cur = pool_get(&pf_cent_pl, PR_NOWAIT);
                if (cur == NULL) {
@@ -1447,7 +1490,7 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                        goto no_mem;
                }
                pf_ncache++;
-               
+
                (*frag)->fr_flags = PFFRAG_NOBUFFER;
                (*frag)->fr_max = 0;
                (*frag)->fr_af = AF_INET6;
@@ -1456,37 +1499,38 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                (*frag)->fr_p = fh->ip6f_nxt;
                (*frag)->fr_id6 = fh->ip6f_ident;
                (*frag)->fr_timeout = pf_time_second();
-               
+
                cur->fr_off = off;
                cur->fr_end = fr_max;
                LIST_INIT(&(*frag)->fr_cache);
                LIST_INSERT_HEAD(&(*frag)->fr_cache, cur, fr_next);
-               
+
                RB_INSERT(pf_frag_tree, &pf_cache_tree, *frag);
                TAILQ_INSERT_HEAD(&pf_cachequeue, *frag, frag_next);
-               
+
                DPFPRINTF(("frag6cache[%d]: new %d-%d\n", ntohl(fh->ip6f_ident),
                    off, fr_max));
-               
+
                goto pass;
        }
-       
+
        /*
         * Find a fragment after the current one:
         *  - off contains the real shifted offset.
         */
        frp = NULL;
        LIST_FOREACH(fra, &(*frag)->fr_cache, fr_next) {
-               if (fra->fr_off > off)
+               if (fra->fr_off > off) {
                        break;
+               }
                frp = fra;
        }
-       
+
        VERIFY(frp != NULL || fra != NULL);
-       
+
        if (frp != NULL) {
                int precut;
-               
+
                precut = frp->fr_end - off;
                if (precut >= plen) {
                        /* Fragment is entirely a duplicate */
@@ -1508,16 +1552,16 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                         * But to do so easily, we need to create another
                         * mbuf to throw the original header into.
                         */
-                       
+
                        DPFPRINTF(("frag6cache[%u]: chop %d (%d-%d) %d-%d\n",
                            ntohl(fh->ip6f_ident), precut, frp->fr_off,
                            frp->fr_end, off, fr_max));
-                       
+
                        off += precut;
                        fr_max -= precut;
                        /* Update the previous frag to encompass this one */
                        frp->fr_end = fr_max;
-                       
+
                        if (!drop) {
                                /* XXX Optimization opportunity
                                 * This is a very heavy way to trim the payload.
@@ -1527,8 +1571,9 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                                 * I'll pull a rabbit out of my laptop.
                                 */
                                *m0 = m_copym(m, 0, hlen, M_NOWAIT);
-                               if (*m0 == NULL)
+                               if (*m0 == NULL) {
                                        goto no_mem;
+                               }
                                VERIFY((*m0)->m_next == NULL);
                                m_adj(m, precut + hlen);
                                m_cat(*m0, m);
@@ -1536,13 +1581,14 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                                if (m->m_flags & M_PKTHDR) {
                                        int pktlen = 0;
                                        struct mbuf *t;
-                                       for (t = m; t; t = t->m_next)
+                                       for (t = m; t; t = t->m_next) {
                                                pktlen += t->m_len;
+                                       }
                                        m->m_pkthdr.len = pktlen;
                                }
-                               
+
                                h = mtod(m, struct ip6_hdr *);
-                               
+
                                VERIFY((int)m->m_len ==
                                    ntohs(h->ip6_plen) - precut);
                                fh->ip6f_offlg &= ~IP6F_OFF_MASK;
@@ -1556,26 +1602,27 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                        }
                } else {
                        /* There is a gap between fragments */
-                       
+
                        DPFPRINTF(("frag6cache[%u]: gap %d (%d-%d) %d-%d\n",
                            ntohl(fh->ip6f_ident), -precut, frp->fr_off,
                            frp->fr_end, off, fr_max));
-                       
+
                        cur = pool_get(&pf_cent_pl, PR_NOWAIT);
-                       if (cur == NULL)
+                       if (cur == NULL) {
                                goto no_mem;
+                       }
                        pf_ncache++;
-                       
+
                        cur->fr_off = off;
                        cur->fr_end = fr_max;
                        LIST_INSERT_AFTER(frp, cur, fr_next);
                }
        }
-       
+
        if (fra != NULL) {
-               int     aftercut;
-               int     merge = 0;
-               
+               int     aftercut;
+               int     merge = 0;
+
                aftercut = fr_max - fra->fr_off;
                if (aftercut == 0) {
                        /* Adjacent fragments */
@@ -1591,16 +1638,17 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                            fra->fr_off, fra->fr_end));
                        fra->fr_off = off;
                        fr_max -= aftercut;
-                       
+
                        merge = 1;
-                       
+
                        if (!drop) {
                                m_adj(m, -aftercut);
                                if (m->m_flags & M_PKTHDR) {
                                        int pktlen = 0;
                                        struct mbuf *t;
-                                       for (t = m; t; t = t->m_next)
+                                       for (t = m; t; t = t->m_next) {
                                                pktlen += t->m_len;
+                                       }
                                        m->m_pkthdr.len = pktlen;
                                }
                                h = mtod(m, struct ip6_hdr *);
@@ -1616,17 +1664,18 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                        DPFPRINTF(("frag6cache[%u]: gap %d %d-%d (%d-%d)\n",
                            ntohl(fh->ip6f_ident), -aftercut, off, fr_max,
                            fra->fr_off, fra->fr_end));
-                       
+
                        cur = pool_get(&pf_cent_pl, PR_NOWAIT);
-                       if (cur == NULL)
+                       if (cur == NULL) {
                                goto no_mem;
+                       }
                        pf_ncache++;
-                       
+
                        cur->fr_off = off;
                        cur->fr_end = fr_max;
                        LIST_INSERT_BEFORE(fra, cur, fr_next);
                }
-               
+
                /* Need to glue together two separate fragment descriptors */
                if (merge) {
                        if (cur && fra->fr_off <= cur->fr_end) {
@@ -1657,7 +1706,7 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                        }
                }
        }
-       
+
        if (hosed) {
                /*
                 * We must keep tracking the overall fragment even when
@@ -1666,16 +1715,18 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                 */
                goto drop_fragment;
        }
-       
- pass:
+
+pass:
        /* Update maximum data size */
-       if ((*frag)->fr_max < fr_max)
+       if ((*frag)->fr_max < fr_max) {
                (*frag)->fr_max = fr_max;
-       
+       }
+
        /* This is the last segment */
-       if (!mff)
+       if (!mff) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
-       
+       }
+
        /* Check if we are completely reassembled */
        if (((*frag)->fr_flags & PFFRAG_SEENLAST) &&
            LIST_FIRST(&(*frag)->fr_cache)->fr_off == 0 &&
@@ -1686,100 +1737,107 @@ pf_frag6cache(struct mbuf **m0, struct ip6_hdr *h, struct ip6_frag *fh,
                pf_free_fragment(*frag);
                *frag = NULL;
        }
-       
-       return (m);
-       
- no_mem:
+
+       return m;
+
+no_mem:
        *nomem = 1;
-       
+
        /* Still need to pay attention to !IP_MF */
-       if (!mff && *frag != NULL)
+       if (!mff && *frag != NULL) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
-       
+       }
+
        m_freem(m);
-       return (NULL);
-       
- drop_fragment:
-       
+       return NULL;
+
+drop_fragment:
+
        /* Still need to pay attention to !IP_MF */
-       if (!mff && *frag != NULL)
+       if (!mff && *frag != NULL) {
                (*frag)->fr_flags |= PFFRAG_SEENLAST;
-       
+       }
+
        if (drop) {
                /* This fragment has been deemed bad.  Don't reass */
-               if (((*frag)->fr_flags & PFFRAG_DROP) == 0)
+               if (((*frag)->fr_flags & PFFRAG_DROP) == 0) {
                        DPFPRINTF(("frag6cache[%u]: dropping overall fragment\n",
                            ntohl(fh->ip6f_ident)));
+               }
                (*frag)->fr_flags |= PFFRAG_DROP;
        }
-       
+
        m_freem(m);
-       return (NULL);
+       return NULL;
 }
 
 int
 pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
     struct pf_pdesc *pd)
 {
-       struct mbuf             *m;
-       struct pf_rule          *r;
-       struct pf_frent         *frent;
-       struct pf_fragment      *frag = NULL;
-       struct ip               *h = pbuf->pb_data;
-       int                      mff = (ntohs(h->ip_off) & IP_MF);
-       int                      hlen = h->ip_hl << 2;
-       u_int16_t                fragoff = (ntohs(h->ip_off) & IP_OFFMASK) << 3;
-       u_int16_t                fr_max;
-       int                      ip_len;
-       int                      ip_off;
-       int                      asd = 0;
-       struct pf_ruleset       *ruleset = NULL;
-       struct ifnet            *ifp = pbuf->pb_ifp;
+       struct mbuf             *m;
+       struct pf_rule          *r;
+       struct pf_frent         *frent;
+       struct pf_fragment      *frag = NULL;
+       struct ip               *h = pbuf->pb_data;
+       int                      mff = (ntohs(h->ip_off) & IP_MF);
+       int                      hlen = h->ip_hl << 2;
+       u_int16_t                fragoff = (ntohs(h->ip_off) & IP_OFFMASK) << 3;
+       u_int16_t                fr_max;
+       int                      ip_len;
+       int                      ip_off;
+       int                      asd = 0;
+       struct pf_ruleset       *ruleset = NULL;
+       struct ifnet            *ifp = pbuf->pb_ifp;
 
        r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr);
        while (r != NULL) {
                r->evaluations++;
-               if (pfi_kif_match(r->kif, kif) == r->ifnot)
+               if (pfi_kif_match(r->kif, kif) == r->ifnot) {
                        r = r->skip[PF_SKIP_IFP].ptr;
-               else if (r->direction && r->direction != dir)
+               } else if (r->direction && r->direction != dir) {
                        r = r->skip[PF_SKIP_DIR].ptr;
-               else if (r->af && r->af != AF_INET)
+               } else if (r->af && r->af != AF_INET) {
                        r = r->skip[PF_SKIP_AF].ptr;
-               else if (r->proto && r->proto != h->ip_p)
+               } else if (r->proto && r->proto != h->ip_p) {
                        r = r->skip[PF_SKIP_PROTO].ptr;
-               else if (PF_MISMATCHAW(&r->src.addr,
+               else if (PF_MISMATCHAW(&r->src.addr,
                    (struct pf_addr *)&h->ip_src.s_addr, AF_INET,
-                   r->src.neg, kif))
+                   r->src.neg, kif)) {
                        r = r->skip[PF_SKIP_SRC_ADDR].ptr;
-               else if (PF_MISMATCHAW(&r->dst.addr,
+               else if (PF_MISMATCHAW(&r->dst.addr,
                    (struct pf_addr *)&h->ip_dst.s_addr, AF_INET,
-                   r->dst.neg, NULL))
+                   r->dst.neg, NULL)) {
                        r = r->skip[PF_SKIP_DST_ADDR].ptr;
-               else {
-                       if (r->anchor == NULL)
+               else {
+                       if (r->anchor == NULL) {
                                break;
-                       else
+                       } else {
                                pf_step_into_anchor(&asd, &ruleset,
                                    PF_RULESET_SCRUB, &r, NULL, NULL);
+                       }
                }
                if (r == NULL && pf_step_out_of_anchor(&asd, &ruleset,
-                   PF_RULESET_SCRUB, &r, NULL, NULL))
+                   PF_RULESET_SCRUB, &r, NULL, NULL)) {
                        break;
+               }
        }
 
-       if (r == NULL || r->action == PF_NOSCRUB)
-               return (PF_PASS);
-       else {
+       if (r == NULL || r->action == PF_NOSCRUB) {
+               return PF_PASS;
+       else {
                r->packets[dir == PF_OUT]++;
                r->bytes[dir == PF_OUT] += pd->tot_len;
        }
 
        /* Check for illegal packets */
-       if (hlen < (int)sizeof (struct ip))
+       if (hlen < (int)sizeof(struct ip)) {
                goto drop;
+       }
 
-       if (hlen > ntohs(h->ip_len))
+       if (hlen > ntohs(h->ip_len)) {
                goto drop;
+       }
 
        /* Clear IP_DF if the rule uses the no-df option */
        if (r->rule_flag & PFRULE_NODF && h->ip_off & htons(IP_DF)) {
@@ -1790,8 +1848,9 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
        }
 
        /* We will need other tests here */
-       if (!fragoff && !mff)
+       if (!fragoff && !mff) {
                goto no_fragment;
+       }
 
        /*
         * We're dealing with a fragment now. Don't allow fragments
@@ -1819,18 +1878,19 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
        }
        fr_max = fragoff + ip_len;
 
-       if ((r->rule_flag & (PFRULE_FRAGCROP|PFRULE_FRAGDROP)) == 0) {
+       if ((r->rule_flag & (PFRULE_FRAGCROP | PFRULE_FRAGDROP)) == 0) {
                /* Fully buffer all of the fragments */
 
                frag = pf_find_fragment_by_ipv4_header(h, &pf_frag_tree);
                /* Check if we saw the last fragment already */
                if (frag != NULL && (frag->fr_flags & PFFRAG_SEENLAST) &&
-                   fr_max > frag->fr_max)
+                   fr_max > frag->fr_max) {
                        goto bad;
+               }
 
                if ((m = pbuf_to_mbuf(pbuf, TRUE)) == NULL) {
                        REASON_SET(reason, PFRES_MEMORY);
-                       return (PF_DROP);
+                       return PF_DROP;
                }
 
                VERIFY(!pbuf_is_valid(pbuf));
@@ -1843,7 +1903,7 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
                if (frent == NULL) {
                        REASON_SET(reason, PFRES_MEMORY);
                        m_freem(m);
-                       return (PF_DROP);
+                       return PF_DROP;
                }
                pf_nfrents++;
                frent->fr_ip = h;
@@ -1854,8 +1914,9 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
                    fragoff, fr_max));
                m = pf_reassemble(m, &frag, frent, mff);
 
-               if (m == NULL)
-                       return (PF_DROP);
+               if (m == NULL) {
+                       return PF_DROP;
+               }
 
                VERIFY(m->m_flags & M_PKTHDR);
                pbuf_init_mbuf(pbuf, m, ifp);
@@ -1878,11 +1939,12 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
 
                h = mtod(m, struct ip *);
 
-               if (frag != NULL && (frag->fr_flags & PFFRAG_DROP))
+               if (frag != NULL && (frag->fr_flags & PFFRAG_DROP)) {
                        goto drop;
+               }
        } else {
                /* non-buffering fragment cache (drops or masks overlaps) */
-               int     nomem = 0;
+               int     nomem = 0;
 
                if (dir == PF_OUT && (pd->pf_mtag->pftag_flags & PF_TAG_FRAGCACHE)) {
                        /*
@@ -1898,8 +1960,9 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
                /* Check if we saw the last fragment already */
                if (frag != NULL && (frag->fr_flags & PFFRAG_SEENLAST) &&
                    fr_max > frag->fr_max) {
-                       if (r->rule_flag & PFRULE_FRAGDROP)
+                       if (r->rule_flag & PFRULE_FRAGDROP) {
                                frag->fr_flags |= PFFRAG_DROP;
+                       }
                        goto bad;
                }
 
@@ -1917,8 +1980,9 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
                    (r->rule_flag & PFRULE_FRAGDROP) ? 1 : 0, &nomem);
                if (m == NULL) {
                        // Note: pf_fragcache() has already m_freem'd the mbuf
-                       if (nomem)
+                       if (nomem) {
                                goto no_mem;
+                       }
                        goto drop;
                }
 
@@ -1940,11 +2004,13 @@ pf_normalize_ip(pbuf_t *pbuf, int dir, struct pfi_kif *kif, u_short *reason,
                }
 #endif
 #endif
-               if (dir == PF_IN)
+               if (dir == PF_IN) {
                        pd->pf_mtag->pftag_flags |= PF_TAG_FRAGCACHE;
+               }
 
-               if (frag != NULL && (frag->fr_flags & PFFRAG_DROP))
+               if (frag != NULL && (frag->fr_flags & PFFRAG_DROP)) {
                        goto drop;
+               }
 
                goto fragment_pass;
        }
@@ -1975,10 +2041,11 @@ no_fragment:
                }
                h->ip_sum = pf_cksum_fixup(h->ip_sum, oip_id, h->ip_id, 0);
        }
-       if ((r->rule_flag & (PFRULE_FRAGCROP|PFRULE_FRAGDROP)) == 0)
+       if ((r->rule_flag & (PFRULE_FRAGCROP | PFRULE_FRAGDROP)) == 0) {
                pd->flags |= PFDESC_IP_REAS;
+       }
 
-       return (PF_PASS);
+       return PF_PASS;
 
 fragment_pass:
        /* Enforce a minimum ttl, may cause endless packet loops */
@@ -1988,36 +2055,41 @@ fragment_pass:
                h->ip_ttl = r->min_ttl;
                h->ip_sum = pf_cksum_fixup(h->ip_sum, ip_ttl, h->ip_ttl, 0);
        }
-       if ((r->rule_flag & (PFRULE_FRAGCROP|PFRULE_FRAGDROP)) == 0)
+       if ((r->rule_flag & (PFRULE_FRAGCROP | PFRULE_FRAGDROP)) == 0) {
                pd->flags |= PFDESC_IP_REAS;
-       return (PF_PASS);
+       }
+       return PF_PASS;
 
 no_mem:
        REASON_SET(reason, PFRES_MEMORY);
-       if (r != NULL && r->log && pbuf_is_valid(pbuf))
+       if (r != NULL && r->log && pbuf_is_valid(pbuf)) {
                PFLOG_PACKET(kif, h, pbuf, AF_INET, dir, *reason, r,
                    NULL, NULL, pd);
-       return (PF_DROP);
+       }
+       return PF_DROP;
 
 drop:
        REASON_SET(reason, PFRES_NORM);
-       if (r != NULL && r->log && pbuf_is_valid(pbuf))
+       if (r != NULL && r->log && pbuf_is_valid(pbuf)) {
                PFLOG_PACKET(kif, h, pbuf, AF_INET, dir, *reason, r,
                    NULL, NULL, pd);
-       return (PF_DROP);
+       }
+       return PF_DROP;
 
 bad:
        DPFPRINTF(("dropping bad IPv4 fragment\n"));
 
        /* Free associated fragments */
-       if (frag != NULL)
+       if (frag != NULL) {
                pf_free_fragment(frag);
+       }
 
        REASON_SET(reason, PFRES_FRAG);
-       if (r != NULL && r->log && pbuf_is_valid(pbuf))
+       if (r != NULL && r->log && pbuf_is_valid(pbuf)) {
                PFLOG_PACKET(kif, h, pbuf, AF_INET, dir, *reason, r, NULL, NULL, pd);
+       }
 
-       return (PF_DROP);
+       return PF_DROP;
 }
 
 #if INET6
@@ -2025,77 +2097,82 @@ int
 pf_normalize_ip6(pbuf_t *pbuf, int dir, struct pfi_kif *kif,
     u_short *reason, struct pf_pdesc *pd)
 {
-       struct mbuf             *m;
-       struct pf_rule          *r;
-       struct ip6_hdr          *h = pbuf->pb_data;
-       int                      off;
-       struct ip6_ext           ext;
+       struct mbuf             *m;
+       struct pf_rule          *r;
+       struct ip6_hdr          *h = pbuf->pb_data;
+       int                      off;
+       struct ip6_ext           ext;
 /* adi XXX */
 #if 0
-       struct ip6_opt           opt;
-       struct ip6_opt_jumbo     jumbo;
-       int                      optend;
-       int                      ooff;
+       struct ip6_opt           opt;
+       struct ip6_opt_jumbo     jumbo;
+       int                      optend;
+       int                      ooff;
 #endif
-       struct ip6_frag          frag;
-       u_int32_t                jumbolen = 0, plen;
-       u_int16_t                fragoff = 0;
-       u_int8_t                 proto;
-       int                      terminal;
-       struct pf_frent         *frent;
-       struct pf_fragment      *pff = NULL;
-       int                      mff = 0, rh_cnt = 0;
-       u_int16_t                fr_max;
-       int                      asd = 0;
-       struct pf_ruleset       *ruleset = NULL;
-       struct ifnet            *ifp = pbuf->pb_ifp;
+       struct ip6_frag          frag;
+       u_int32_t                jumbolen = 0, plen;
+       u_int16_t                fragoff = 0;
+       u_int8_t                 proto;
+       int                      terminal;
+       struct pf_frent         *frent;
+       struct pf_fragment      *pff = NULL;
+       int                      mff = 0, rh_cnt = 0;
+       u_int16_t                fr_max;
+       int                      asd = 0;
+       struct pf_ruleset       *ruleset = NULL;
+       struct ifnet            *ifp = pbuf->pb_ifp;
 
        r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr);
        while (r != NULL) {
                r->evaluations++;
-               if (pfi_kif_match(r->kif, kif) == r->ifnot)
+               if (pfi_kif_match(r->kif, kif) == r->ifnot) {
                        r = r->skip[PF_SKIP_IFP].ptr;
-               else if (r->direction && r->direction != dir)
+               } else if (r->direction && r->direction != dir) {
                        r = r->skip[PF_SKIP_DIR].ptr;
-               else if (r->af && r->af != AF_INET6)
+               } else if (r->af && r->af != AF_INET6) {
                        r = r->skip[PF_SKIP_AF].ptr;
+               }
 #if 0 /* header chain! */
-               else if (r->proto && r->proto != h->ip6_nxt)
+               else if (r->proto && r->proto != h->ip6_nxt) {
                        r = r->skip[PF_SKIP_PROTO].ptr;
+               }
 #endif
                else if (PF_MISMATCHAW(&r->src.addr,
                    (struct pf_addr *)(uintptr_t)&h->ip6_src, AF_INET6,
-                   r->src.neg, kif))
+                   r->src.neg, kif)) {
                        r = r->skip[PF_SKIP_SRC_ADDR].ptr;
-               else if (PF_MISMATCHAW(&r->dst.addr,
+               else if (PF_MISMATCHAW(&r->dst.addr,
                    (struct pf_addr *)(uintptr_t)&h->ip6_dst, AF_INET6,
-                   r->dst.neg, NULL))
+                   r->dst.neg, NULL)) {
                        r = r->skip[PF_SKIP_DST_ADDR].ptr;
-               else {
-                       if (r->anchor == NULL)
+               else {
+                       if (r->anchor == NULL) {
                                break;
-                       else
+                       } else {
                                pf_step_into_anchor(&asd, &ruleset,
                                    PF_RULESET_SCRUB, &r, NULL, NULL);
+                       }
                }
                if (r == NULL && pf_step_out_of_anchor(&asd, &ruleset,
-                   PF_RULESET_SCRUB, &r, NULL, NULL))
+                   PF_RULESET_SCRUB, &r, NULL, NULL)) {
                        break;
+               }
        }
 
-       if (r == NULL || r->action == PF_NOSCRUB)
-               return (PF_PASS);
-       else {
+       if (r == NULL || r->action == PF_NOSCRUB) {
+               return PF_PASS;
+       else {
                r->packets[dir == PF_OUT]++;
                r->bytes[dir == PF_OUT] += pd->tot_len;
        }
 
        /* Check for illegal packets */
-       if ((uint32_t)(sizeof (struct ip6_hdr) + IPV6_MAXPACKET) <
-           pbuf->pb_packet_len)
+       if ((uint32_t)(sizeof(struct ip6_hdr) + IPV6_MAXPACKET) <
+           pbuf->pb_packet_len) {
                goto drop;
+       }
 
-       off = sizeof (struct ip6_hdr);
+       off = sizeof(struct ip6_hdr);
        proto = h->ip6_nxt;
        terminal = 0;
        do {
@@ -2106,9 +2183,10 @@ pf_normalize_ip6(pbuf_t *pbuf, int dir, struct pfi_kif *kif,
                case IPPROTO_AH:
                case IPPROTO_ROUTING:
                case IPPROTO_DSTOPTS:
-                       if (!pf_pull_hdr(pbuf, off, &ext, sizeof (ext), NULL,
-                           NULL, AF_INET6))
+                       if (!pf_pull_hdr(pbuf, off, &ext, sizeof(ext), NULL,
+                           NULL, AF_INET6)) {
                                goto shortpkt;
+                       }
                        /*
                         * <jhw@apple.com>
                         * Multiple routing headers not allowed.
@@ -2117,61 +2195,70 @@ pf_normalize_ip6(pbuf_t *pbuf, int dir, struct pfi_kif *kif,
                        if (proto == IPPROTO_ROUTING) {
                                const struct ip6_rthdr *rh =
                                    (const struct ip6_rthdr *)&ext;
-                               if (rh_cnt++)
+                               if (rh_cnt++) {
                                        goto drop;
-                               if (rh->ip6r_type == IPV6_RTHDR_TYPE_0)
+                               }
+                               if (rh->ip6r_type == IPV6_RTHDR_TYPE_0) {
                                        goto drop;
-                       }
-                       else
-                       if (proto == IPPROTO_AH)
+                               }
+                       } else if (proto == IPPROTO_AH) {
                                off += (ext.ip6e_len + 2) * 4;
-                       else
+                       } else {
                                off += (ext.ip6e_len + 1) * 8;
+                       }
                        proto = ext.ip6e_nxt;
                        break;
                case IPPROTO_HOPOPTS:
 /* adi XXX */
 #if 0
-                       if (!pf_pull_hdr(m, off, &ext, sizeof (ext), NULL,
-                           NULL, AF_INET6))
+                       if (!pf_pull_hdr(m, off, &ext, sizeof(ext), NULL,
+                           NULL, AF_INET6)) {
                                goto shortpkt;
+                       }
                        optend = off + (ext.ip6e_len + 1) * 8;
-                       ooff = off + sizeof (ext);
+                       ooff = off + sizeof(ext);
                        do {
                                if (!pf_pull_hdr(m, ooff, &opt.ip6o_type,
-                                   sizeof (opt.ip6o_type), NULL, NULL,
-                                   AF_INET6))
+                                   sizeof(opt.ip6o_type), NULL, NULL,
+                                   AF_INET6)) {
                                        goto shortpkt;
+                               }
                                if (opt.ip6o_type == IP6OPT_PAD1) {
                                        ooff++;
                                        continue;
                                }
-                               if (!pf_pull_hdr(m, ooff, &opt, sizeof (opt),
-                                   NULL, NULL, AF_INET6))
+                               if (!pf_pull_hdr(m, ooff, &opt, sizeof(opt),
+                                   NULL, NULL, AF_INET6)) {
                                        goto shortpkt;
-                               if (ooff + sizeof (opt) + opt.ip6o_len > optend)
+                               }
+                               if (ooff + sizeof(opt) + opt.ip6o_len > optend) {
                                        goto drop;
+                               }
                                switch (opt.ip6o_type) {
                                case IP6OPT_JUMBO:
-                                       if (h->ip6_plen != 0)
+                                       if (h->ip6_plen != 0) {
                                                goto drop;
+                                       }
                                        if (!pf_pull_hdr(m, ooff, &jumbo,
-                                           sizeof (jumbo), NULL, NULL,
-                                           AF_INET6))
+                                           sizeof(jumbo), NULL, NULL,
+                                           AF_INET6)) {
                                                goto shortpkt;
+                                       }
                                        memcpy(&jumbolen, jumbo.ip6oj_jumbo_len,
-                                           sizeof (jumbolen));
+                                           sizeof(jumbolen));
                                        jumbolen = ntohl(jumbolen);
-                                       if (jumbolen <= IPV6_MAXPACKET)
+                                       if (jumbolen <= IPV6_MAXPACKET) {
                                                goto drop;
-                                       if (sizeof (struct ip6_hdr) +
-                                           jumbolen != m->m_pkthdr.len)
+                                       }
+                                       if (sizeof(struct ip6_hdr) +
+                                           jumbolen != m->m_pkthdr.len) {
                                                goto drop;
+                                       }
                                        break;
                                default:
                                        break;
                                }
-                               ooff += sizeof (opt) + opt.ip6o_len;
+                               ooff += sizeof(opt) + opt.ip6o_len;
                        } while (ooff < optend);
 
                        off = optend;
@@ -2185,58 +2272,66 @@ pf_normalize_ip6(pbuf_t *pbuf, int dir, struct pfi_kif *kif,
        } while (!terminal);
 
        /* jumbo payload option must be present, or plen > 0 */
-       if (ntohs(h->ip6_plen) == 0)
+       if (ntohs(h->ip6_plen) == 0) {
                plen = jumbolen;
-       else
+       } else {
                plen = ntohs(h->ip6_plen);
-       if (plen == 0)
+       }
+       if (plen == 0) {
                goto drop;
-       if ((uint32_t)(sizeof (struct ip6_hdr) + plen) > pbuf->pb_packet_len)
+       }
+       if ((uint32_t)(sizeof(struct ip6_hdr) + plen) > pbuf->pb_packet_len) {
                goto shortpkt;
+       }
 
        /* Enforce a minimum ttl, may cause endless packet loops */
-       if (r->min_ttl && h->ip6_hlim < r->min_ttl)
+       if (r->min_ttl && h->ip6_hlim < r->min_ttl) {
                h->ip6_hlim = r->min_ttl;
+       }
 
-       return (PF_PASS);
+       return PF_PASS;
 
 fragment:
-       if (ntohs(h->ip6_plen) == 0 || jumbolen)
+       if (ntohs(h->ip6_plen) == 0 || jumbolen) {
                goto drop;
+       }
        plen = ntohs(h->ip6_plen);
 
-       if (!pf_pull_hdr(pbuf, off, &frag, sizeof (frag), NULL, NULL, AF_INET6))
+       if (!pf_pull_hdr(pbuf, off, &frag, sizeof(frag), NULL, NULL, AF_INET6)) {
                goto shortpkt;
+       }
        fragoff = ntohs(frag.ip6f_offlg & IP6F_OFF_MASK);
        pd->proto = frag.ip6f_nxt;
        mff = ntohs(frag.ip6f_offlg & IP6F_MORE_FRAG);
        off += sizeof frag;
-       if (fragoff + (plen - off) > IPV6_MAXPACKET)
-              goto badfrag;
-       
+       if (fragoff + (plen - off) > IPV6_MAXPACKET) {
+               goto badfrag;
+       }
+
        fr_max = fragoff + plen - (off - sizeof(struct ip6_hdr));
 // XXX SCW: mbuf-specific
 //     DPFPRINTF(("0x%llx IPv6 frag plen %u mff %d off %u fragoff %u "
 //         "fr_max %u\n", (uint64_t)VM_KERNEL_ADDRPERM(m), plen, mff, off,
 //         fragoff, fr_max));
-       
-       if ((r->rule_flag & (PFRULE_FRAGCROP|PFRULE_FRAGDROP)) == 0) {
+
+       if ((r->rule_flag & (PFRULE_FRAGCROP | PFRULE_FRAGDROP)) == 0) {
                /* Fully buffer all of the fragments */
                pd->flags |= PFDESC_IP_REAS;
-               
+
                pff = pf_find_fragment_by_ipv6_header(h, &frag,
-                  &pf_frag_tree);
-               
+                   &pf_frag_tree);
+
                /* Check if we saw the last fragment already */
                if (pff != NULL && (pff->fr_flags & PFFRAG_SEENLAST) &&
-                   fr_max > pff->fr_max)
+                   fr_max > pff->fr_max) {
                        goto badfrag;
+               }
 
                if ((m = pbuf_to_mbuf(pbuf, TRUE)) == NULL) {
                        REASON_SET(reason, PFRES_MEMORY);
-                       return (PF_DROP);
+                       return PF_DROP;
                }
-               
+
                /* Restore iph pointer after pbuf_to_mbuf() */
                h = mtod(m, struct ip6_hdr *);
 
@@ -2244,7 +2339,7 @@ fragment:
                frent = pool_get(&pf_frent_pl, PR_NOWAIT);
                if (frent == NULL) {
                        REASON_SET(reason, PFRES_MEMORY);
-                       return (PF_DROP);
+                       return PF_DROP;
                }
 
                pf_nfrents++;
@@ -2252,36 +2347,38 @@ fragment:
                frent->fr_m = m;
                frent->fr_ip6f_opt = frag;
                frent->fr_ip6f_hlen = off;
-               
+
                /* Might return a completely reassembled mbuf, or NULL */
                DPFPRINTF(("reass IPv6 frag %d @ %d-%d\n",
-                    ntohl(frag.ip6f_ident), fragoff, fr_max));
+                   ntohl(frag.ip6f_ident), fragoff, fr_max));
                m = pf_reassemble6(&m, &pff, frent, mff);
-               
-               if (m == NULL)
-                       return (PF_DROP);
+
+               if (m == NULL) {
+                       return PF_DROP;
+               }
 
                pbuf_init_mbuf(pbuf, m, ifp);
                h = pbuf->pb_data;
-               
-               if (pff != NULL && (pff->fr_flags & PFFRAG_DROP))
+
+               if (pff != NULL && (pff->fr_flags & PFFRAG_DROP)) {
                        goto drop;
-       }
-       else if (dir == PF_IN || !(pd->pf_mtag->pftag_flags & PF_TAG_FRAGCACHE)) {
+               }
+       else if (dir == PF_IN || !(pd->pf_mtag->pftag_flags & PF_TAG_FRAGCACHE)) {
                /* non-buffering fragment cache (overlaps: see RFC 5722) */
                int nomem = 0;
-               
+
                pff = pf_find_fragment_by_ipv6_header(h, &frag,
                    &pf_cache_tree);
-               
+
                /* Check if we saw the last fragment already */
                if (pff != NULL && (pff->fr_flags & PFFRAG_SEENLAST) &&
                    fr_max > pff->fr_max) {
-                      if (r->rule_flag & PFRULE_FRAGDROP)
+                       if (r->rule_flag & PFRULE_FRAGDROP) {
                                pff->fr_flags |= PFFRAG_DROP;
-                      goto badfrag;
+                       }
+                       goto badfrag;
                }
-               
+
                if ((m = pbuf_to_mbuf(pbuf, TRUE)) == NULL) {
                        goto no_mem;
                }
@@ -2290,53 +2387,59 @@ fragment:
                h = mtod(m, struct ip6_hdr *);
 
                m = pf_frag6cache(&m, h, &frag, &pff, off, mff,
-                    (r->rule_flag & PFRULE_FRAGDROP) ? 1 : 0, &nomem);
+                   (r->rule_flag & PFRULE_FRAGDROP) ? 1 : 0, &nomem);
                if (m == NULL) {
                        // Note: pf_frag6cache() has already m_freem'd the mbuf
-                       if (nomem)
+                       if (nomem) {
                                goto no_mem;
+                       }
                        goto drop;
                }
-               
+
                pbuf_init_mbuf(pbuf, m, ifp);
                pd->pf_mtag = pf_find_mtag_pbuf(pbuf);
                h = pbuf->pb_data;
 
-               if (dir == PF_IN)
+               if (dir == PF_IN) {
                        pd->pf_mtag->pftag_flags |= PF_TAG_FRAGCACHE;
-               
-               if (pff != NULL && (pff->fr_flags & PFFRAG_DROP))
+               }
+
+               if (pff != NULL && (pff->fr_flags & PFFRAG_DROP)) {
                        goto drop;
+               }
        }
-       
+
        /* Enforce a minimum ttl, may cause endless packet loops */
-       if (r->min_ttl && h->ip6_hlim < r->min_ttl)
+       if (r->min_ttl && h->ip6_hlim < r->min_ttl) {
                h->ip6_hlim = r->min_ttl;
-       return (PF_PASS);
+       }
+       return PF_PASS;
 
-  no_mem:
+no_mem:
        REASON_SET(reason, PFRES_MEMORY);
        goto dropout;
-       
-  shortpkt:
+
+shortpkt:
        REASON_SET(reason, PFRES_SHORT);
        goto dropout;
-       
-  drop:
+
+drop:
        REASON_SET(reason, PFRES_NORM);
        goto dropout;
-       
-  badfrag:
+
+badfrag:
        DPFPRINTF(("dropping bad IPv6 fragment\n"));
        REASON_SET(reason, PFRES_FRAG);
        goto dropout;
-       
-  dropout:
-       if (pff != NULL)
+
+dropout:
+       if (pff != NULL) {
                pf_free_fragment(pff);
-       if (r != NULL && r->log && pbuf_is_valid(pbuf))
+       }
+       if (r != NULL && r->log && pbuf_is_valid(pbuf)) {
                PFLOG_PACKET(kif, h, pbuf, AF_INET6, dir, *reason, r, NULL, NULL, pd);
-       return (PF_DROP);
+       }
+       return PF_DROP;
 }
 #endif /* INET6 */
 
@@ -2345,13 +2448,13 @@ pf_normalize_tcp(int dir, struct pfi_kif *kif, pbuf_t *pbuf, int ipoff,
     int off, void *h, struct pf_pdesc *pd)
 {
 #pragma unused(ipoff, h)
-       struct pf_rule  *r, *rm = NULL;
-       struct tcphdr   *th = pd->hdr.tcp;
-       int              rewrite = 0;
-       int              asd = 0;
-       u_short          reason;
-       u_int8_t         flags;
-       sa_family_t      af = pd->af;
+       struct pf_rule  *r, *rm = NULL;
+       struct tcphdr   *th = pd->hdr.tcp;
+       int              rewrite = 0;
+       int              asd = 0;
+       u_short          reason;
+       u_int8_t         flags;
+       sa_family_t      af = pd->af;
        struct pf_ruleset *ruleset = NULL;
        union pf_state_xport sxport, dxport;
 
@@ -2361,33 +2464,33 @@ pf_normalize_tcp(int dir, struct pfi_kif *kif, pbuf_t *pbuf, int ipoff,
        r = TAILQ_FIRST(pf_main_ruleset.rules[PF_RULESET_SCRUB].active.ptr);
        while (r != NULL) {
                r->evaluations++;
-               if (pfi_kif_match(r->kif, kif) == r->ifnot)
+               if (pfi_kif_match(r->kif, kif) == r->ifnot) {
                        r = r->skip[PF_SKIP_IFP].ptr;
-               else if (r->direction && r->direction != dir)
+               } else if (r->direction && r->direction != dir) {
                        r = r->skip[PF_SKIP_DIR].ptr;
-               else if (r->af && r->af != af)
+               } else if (r->af && r->af != af) {
                        r = r->skip[PF_SKIP_AF].ptr;
-               else if (r->proto && r->proto != pd->proto)
+               } else if (r->proto && r->proto != pd->proto) {
                        r = r->skip[PF_SKIP_PROTO].ptr;
-               else if (PF_MISMATCHAW(&r->src.addr, pd->src, af,
-                   r->src.neg, kif))
+               else if (PF_MISMATCHAW(&r->src.addr, pd->src, af,
+                   r->src.neg, kif)) {
                        r = r->skip[PF_SKIP_SRC_ADDR].ptr;
-               else if (r->src.xport.range.op &&
+               else if (r->src.xport.range.op &&
                    !pf_match_xport(r->src.xport.range.op, r->proto_variant,
-                   &r->src.xport, &sxport))
+                   &r->src.xport, &sxport)) {
                        r = r->skip[PF_SKIP_SRC_PORT].ptr;
-               else if (PF_MISMATCHAW(&r->dst.addr, pd->dst, af,
-                   r->dst.neg, NULL))
+               else if (PF_MISMATCHAW(&r->dst.addr, pd->dst, af,
+                   r->dst.neg, NULL)) {
                        r = r->skip[PF_SKIP_DST_ADDR].ptr;
-               else if (r->dst.xport.range.op &&
+               else if (r->dst.xport.range.op &&
                    !pf_match_xport(r->dst.xport.range.op, r->proto_variant,
-                   &r->dst.xport, &dxport))
+                   &r->dst.xport, &dxport)) {
                        r = r->skip[PF_SKIP_DST_PORT].ptr;
-               else if (r->os_fingerprint != PF_OSFP_ANY &&
+               else if (r->os_fingerprint != PF_OSFP_ANY &&
                    !pf_osfp_match(pf_osfp_fingerprint(pd, pbuf, off, th),
-                   r->os_fingerprint))
+                   r->os_fingerprint)) {
                        r = TAILQ_NEXT(r, entries);
-               else {
+               else {
                        if (r->anchor == NULL) {
                                rm = r;
                                break;
@@ -2397,47 +2500,54 @@ pf_normalize_tcp(int dir, struct pfi_kif *kif, pbuf_t *pbuf, int ipoff,
                        }
                }
                if (r == NULL && pf_step_out_of_anchor(&asd, &ruleset,
-                   PF_RULESET_SCRUB, &r, NULL, NULL))
+                   PF_RULESET_SCRUB, &r, NULL, NULL)) {
                        break;
+               }
        }
 
-       if (rm == NULL || rm->action == PF_NOSCRUB)
-               return (PF_PASS);
-       else {
+       if (rm == NULL || rm->action == PF_NOSCRUB) {
+               return PF_PASS;
+       else {
                r->packets[dir == PF_OUT]++;
                r->bytes[dir == PF_OUT] += pd->tot_len;
        }
 
-       if (rm->rule_flag & PFRULE_REASSEMBLE_TCP)
+       if (rm->rule_flag & PFRULE_REASSEMBLE_TCP) {
                pd->flags |= PFDESC_TCP_NORM;
+       }
 
        flags = th->th_flags;
        if (flags & TH_SYN) {
                /* Illegal packet */
-               if (flags & TH_RST)
+               if (flags & TH_RST) {
                        goto tcp_drop;
+               }
 
-               if (flags & TH_FIN)
+               if (flags & TH_FIN) {
                        flags &= ~TH_FIN;
+               }
        } else {
                /* Illegal packet */
-               if (!(flags & (TH_ACK|TH_RST)))
+               if (!(flags & (TH_ACK | TH_RST))) {
                        goto tcp_drop;
+               }
        }
 
        if (!(flags & TH_ACK)) {
                /* These flags are only valid if ACK is set */
-               if ((flags & TH_FIN) || (flags & TH_PUSH) || (flags & TH_URG))
+               if ((flags & TH_FIN) || (flags & TH_PUSH) || (flags & TH_URG)) {
                        goto tcp_drop;
+               }
        }
 
        /* Check for illegal header length */
-       if (th->th_off < (sizeof (struct tcphdr) >> 2))
+       if (th->th_off < (sizeof(struct tcphdr) >> 2)) {
                goto tcp_drop;
+       }
 
        /* If flags changed, or reserved data set, then adjust */
        if (flags != th->th_flags || th->th_x2 != 0) {
-               u_int16_t       ov, nv;
+               u_int16_t       ov, nv;
 
                ov = *(u_int16_t *)(&th->th_ack + 1);
                th->th_flags = flags;
@@ -2460,31 +2570,34 @@ pf_normalize_tcp(int dir, struct pfi_kif *kif, pbuf_t *pbuf, int ipoff,
        if (r->max_mss) {
                int rv = pf_normalize_tcpopt(r, dir, kif, pd, pbuf, th, off,
                    &rewrite);
-               if (rv == PF_DROP)
+               if (rv == PF_DROP) {
                        return rv;
+               }
                pbuf = pd->mp;
        }
 
        if (rewrite) {
                if (pf_lazy_makewritable(pd, pbuf,
-                   off + sizeof (*th)) == NULL) {
+                   off + sizeof(*th)) == NULL) {
                        REASON_SET(&reason, PFRES_MEMORY);
-                       if (r->log)
+                       if (r->log) {
                                PFLOG_PACKET(kif, h, pbuf, AF_INET, dir, reason,
                                    r, 0, 0, pd);
+                       }
                        return PF_DROP;
                }
 
-               pbuf_copy_back(pbuf, off, sizeof (*th), th);
+               pbuf_copy_back(pbuf, off, sizeof(*th), th);
        }
 
-       return (PF_PASS);
+       return PF_PASS;
 
 tcp_drop:
        REASON_SET(&reason, PFRES_NORM);
-       if (rm != NULL && r->log)
+       if (rm != NULL && r->log) {
                PFLOG_PACKET(kif, h, pbuf, AF_INET, dir, reason, r, NULL, NULL, pd);
-       return (PF_DROP);
+       }
+       return PF_DROP;
 }
 
 int
@@ -2499,9 +2612,10 @@ pf_normalize_tcp_init(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
        VERIFY(src->scrub == NULL);
 
        src->scrub = pool_get(&pf_state_scrub_pl, PR_NOWAIT);
-       if (src->scrub == NULL)
-               return (1);
-       bzero(src->scrub, sizeof (*src->scrub));
+       if (src->scrub == NULL) {
+               return 1;
+       }
+       bzero(src->scrub, sizeof(*src->scrub));
 
        switch (pd->af) {
 #if INET
@@ -2525,19 +2639,20 @@ pf_normalize_tcp_init(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
         * All normalizations below are only begun if we see the start of
         * the connections.  They must all set an enabled bit in pfss_flags
         */
-       if ((th->th_flags & TH_SYN) == 0)
-               return (0);
+       if ((th->th_flags & TH_SYN) == 0) {
+               return 0;
+       }
 
 
-       if (th->th_off > (sizeof (struct tcphdr) >> 2) && src->scrub &&
+       if (th->th_off > (sizeof(struct tcphdr) >> 2) && src->scrub &&
            pf_pull_hdr(pbuf, off, hdr, th->th_off << 2, NULL, NULL, pd->af)) {
                /* Diddle with TCP options */
                int hlen;
-               opt = hdr + sizeof (struct tcphdr);
-               hlen = (th->th_off << 2) - sizeof (struct tcphdr);
+               opt = hdr + sizeof(struct tcphdr);
+               hlen = (th->th_off << 2) - sizeof(struct tcphdr);
                while (hlen >= TCPOLEN_TIMESTAMP) {
                        switch (*opt) {
-                       case TCPOPT_EOL:        /* FALLTHROUGH */
+                       case TCPOPT_EOL:        /* FALLTHROUGH */
                        case TCPOPT_NOP:
                                opt++;
                                hlen--;
@@ -2551,15 +2666,15 @@ pf_normalize_tcp_init(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
 
                                        /* note PFSS_PAWS not set yet */
                                        memcpy(&tsval, &opt[2],
-                                           sizeof (u_int32_t));
+                                           sizeof(u_int32_t));
                                        memcpy(&tsecr, &opt[6],
-                                           sizeof (u_int32_t));
+                                           sizeof(u_int32_t));
                                        src->scrub->pfss_tsval0 = ntohl(tsval);
                                        src->scrub->pfss_tsval = ntohl(tsval);
                                        src->scrub->pfss_tsecr = ntohl(tsecr);
                                        getmicrouptime(&src->scrub->pfss_last);
                                }
-                               /* FALLTHROUGH */
+                       /* FALLTHROUGH */
                        default:
                                hlen -= MAX(opt[1], 2);
                                opt += MAX(opt[1], 2);
@@ -2568,16 +2683,18 @@ pf_normalize_tcp_init(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                }
        }
 
-       return (0);
+       return 0;
 }
 
 void
 pf_normalize_tcp_cleanup(struct pf_state *state)
 {
-       if (state->src.scrub)
+       if (state->src.scrub) {
                pool_put(&pf_state_scrub_pl, state->src.scrub);
-       if (state->dst.scrub)
+       }
+       if (state->dst.scrub) {
                pool_put(&pf_state_scrub_pl, state->dst.scrub);
+       }
 
        /* Someday... flush the TCP segment reassembly descriptors. */
 }
@@ -2607,8 +2724,9 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
        case AF_INET: {
                if (src->scrub) {
                        struct ip *h = pbuf->pb_data;
-                       if (h->ip_ttl > src->scrub->pfss_ttl)
+                       if (h->ip_ttl > src->scrub->pfss_ttl) {
                                src->scrub->pfss_ttl = h->ip_ttl;
+                       }
                        h->ip_ttl = src->scrub->pfss_ttl;
                }
                break;
@@ -2618,8 +2736,9 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
        case AF_INET6: {
                if (src->scrub) {
                        struct ip6_hdr *h = pbuf->pb_data;
-                       if (h->ip6_hlim > src->scrub->pfss_ttl)
+                       if (h->ip6_hlim > src->scrub->pfss_ttl) {
                                src->scrub->pfss_ttl = h->ip6_hlim;
+                       }
                        h->ip6_hlim = src->scrub->pfss_ttl;
                }
                break;
@@ -2627,17 +2746,17 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
 #endif /* INET6 */
        }
 
-       if (th->th_off > (sizeof (struct tcphdr) >> 2) &&
+       if (th->th_off > (sizeof(struct tcphdr) >> 2) &&
            ((src->scrub && (src->scrub->pfss_flags & PFSS_TIMESTAMP)) ||
            (dst->scrub && (dst->scrub->pfss_flags & PFSS_TIMESTAMP))) &&
            pf_pull_hdr(pbuf, off, hdr, th->th_off << 2, NULL, NULL, pd->af)) {
                /* Diddle with TCP options */
                int hlen;
-               opt = hdr + sizeof (struct tcphdr);
-               hlen = (th->th_off << 2) - sizeof (struct tcphdr);
+               opt = hdr + sizeof(struct tcphdr);
+               hlen = (th->th_off << 2) - sizeof(struct tcphdr);
                while (hlen >= TCPOLEN_TIMESTAMP) {
                        switch (*opt) {
-                       case TCPOPT_EOL:        /* FALLTHROUGH */
+                       case TCPOPT_EOL:        /* FALLTHROUGH */
                        case TCPOPT_NOP:
                                opt++;
                                hlen--;
@@ -2657,11 +2776,11 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                                                printf("\n");
                                        }
                                        REASON_SET(reason, PFRES_TS);
-                                       return (PF_DROP);
+                                       return PF_DROP;
                                }
                                if (opt[1] >= TCPOLEN_TIMESTAMP) {
                                        memcpy(&tsval, &opt[2],
-                                           sizeof (u_int32_t));
+                                           sizeof(u_int32_t));
                                        if (tsval && src->scrub &&
                                            (src->scrub->pfss_flags &
                                            PFSS_TIMESTAMP)) {
@@ -2676,7 +2795,7 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
 
                                        /* Modulate TS reply iff valid (!0) */
                                        memcpy(&tsecr, &opt[6],
-                                           sizeof (u_int32_t));
+                                           sizeof(u_int32_t));
                                        if (tsecr && dst->scrub &&
                                            (dst->scrub->pfss_flags &
                                            PFSS_TIMESTAMP)) {
@@ -2689,7 +2808,7 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                                        }
                                        got_ts = 1;
                                }
-                               /* FALLTHROUGH */
+                       /* FALLTHROUGH */
                        default:
                                hlen -= MAX(opt[1], 2);
                                opt += MAX(opt[1], 2);
@@ -2698,8 +2817,8 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                }
                if (copyback) {
                        /* Copyback the options, caller copys back header */
-                       int optoff = off + sizeof (*th);
-                       int optlen = (th->th_off << 2) - sizeof (*th);
+                       int optoff = off + sizeof(*th);
+                       int optlen = (th->th_off << 2) - sizeof(*th);
                        if (pf_lazy_makewritable(pd, pbuf, optoff + optlen) ==
                            NULL) {
                                REASON_SET(reason, PFRES_MEMORY);
@@ -2718,13 +2837,13 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
         * TS echo check only works for the first 12 days of a connection
         * when the TS has exhausted half its 32bit space
         */
-#define TS_MAX_IDLE    (24*24*60*60)
-#define TS_MAX_CONN    (12*24*60*60)   /* XXX remove when better tsecr check */
+#define TS_MAX_IDLE     (24*24*60*60)
+#define TS_MAX_CONN     (12*24*60*60)   /* XXX remove when better tsecr check */
 
        getmicrouptime(&uptime);
        if (src->scrub && (src->scrub->pfss_flags & PFSS_PAWS) &&
            (uptime.tv_sec - src->scrub->pfss_last.tv_sec > TS_MAX_IDLE ||
-           pf_time_second() - state->creation > TS_MAX_CONN))  {
+           pf_time_second() - state->creation > TS_MAX_CONN)) {
                if (pf_status.debug >= PF_DEBUG_MISC) {
                        DPFPRINTF(("src idled out of PAWS\n"));
                        pf_print_state(state);
@@ -2819,16 +2938,17 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                 * packet got delayed in transit for much longer than
                 * this packet.
                 */
-               if ((ts_fudge = state->rule.ptr->timeout[PFTM_TS_DIFF]) == 0)
+               if ((ts_fudge = state->rule.ptr->timeout[PFTM_TS_DIFF]) == 0) {
                        ts_fudge = pf_default_rule.timeout[PFTM_TS_DIFF];
+               }
 
 
                /* 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 */
+#define TS_MAXFREQ      1100            /* RFC max TS freq of 1Khz + 10% skew */
+#define TS_MICROSECS    1000000         /* microseconds per second */
                timersub(&uptime, &src->scrub->pfss_last, &delta_ts);
                tsval_from_last = (delta_ts.tv_sec + ts_fudge) * TS_MAXFREQ;
-               tsval_from_last += delta_ts.tv_usec / (TS_MICROSECS/TS_MAXFREQ);
+               tsval_from_last += delta_ts.tv_usec / (TS_MICROSECS / TS_MAXFREQ);
 
 
                if ((src->state >= TCPS_ESTABLISHED &&
@@ -2866,11 +2986,10 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                                printf("\n");
                        }
                        REASON_SET(reason, PFRES_TS);
-                       return (PF_DROP);
+                       return PF_DROP;
                }
 
                /* XXX I'd really like to require tsecr but it's optional */
-
        } else if (!got_ts && (th->th_flags & TH_RST) == 0 &&
            ((src->state == TCPS_ESTABLISHED && dst->state == TCPS_ESTABLISHED)
            || pd->p_len > 0 || (th->th_flags & TH_SYN)) &&
@@ -2917,7 +3036,7 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                                printf("\n");
                        }
                        REASON_SET(reason, PFRES_TS);
-                       return (PF_DROP);
+                       return PF_DROP;
                }
        }
 
@@ -2931,10 +3050,10 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
         * packets (seen in a WWW accelerator or cache).
         */
        if (pd->p_len > 0 && src->scrub && (src->scrub->pfss_flags &
-           (PFSS_TIMESTAMP|PFSS_DATA_TS|PFSS_DATA_NOTS)) == PFSS_TIMESTAMP) {
-               if (got_ts)
+           (PFSS_TIMESTAMP | PFSS_DATA_TS | PFSS_DATA_NOTS)) == PFSS_TIMESTAMP) {
+               if (got_ts) {
                        src->scrub->pfss_flags |= PFSS_DATA_TS;
-               else {
+               else {
                        src->scrub->pfss_flags |= PFSS_DATA_NOTS;
                        if (pf_status.debug >= PF_DEBUG_MISC && dst->scrub &&
                            (dst->scrub->pfss_flags & PFSS_TIMESTAMP)) {
@@ -2954,16 +3073,18 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
         * Update PAWS values
         */
        if (got_ts && src->scrub && PFSS_TIMESTAMP == (src->scrub->pfss_flags &
-           (PFSS_PAWS_IDLED|PFSS_TIMESTAMP))) {
+           (PFSS_PAWS_IDLED | PFSS_TIMESTAMP))) {
                getmicrouptime(&src->scrub->pfss_last);
                if (SEQ_GEQ(tsval, src->scrub->pfss_tsval) ||
-                   (src->scrub->pfss_flags & PFSS_PAWS) == 0)
+                   (src->scrub->pfss_flags & PFSS_PAWS) == 0) {
                        src->scrub->pfss_tsval = tsval;
+               }
 
                if (tsecr) {
                        if (SEQ_GEQ(tsecr, src->scrub->pfss_tsecr) ||
-                           (src->scrub->pfss_flags & PFSS_PAWS) == 0)
+                           (src->scrub->pfss_flags & PFSS_PAWS) == 0) {
                                src->scrub->pfss_tsecr = tsecr;
+                       }
 
                        if ((src->scrub->pfss_flags & PFSS_PAWS) == 0 &&
                            (SEQ_LT(tsval, src->scrub->pfss_tsval0) ||
@@ -2973,13 +3094,14 @@ pf_normalize_tcp_stateful(pbuf_t *pbuf, int off, struct pf_pdesc *pd,
                        }
 
                        /* Only fully initialized after a TS gets echoed */
-                       if ((src->scrub->pfss_flags & PFSS_PAWS) == 0)
+                       if ((src->scrub->pfss_flags & PFSS_PAWS) == 0) {
                                src->scrub->pfss_flags |= PFSS_PAWS;
+                       }
                }
        }
 
        /* I have a dream....  TCP segment reassembly.... */
-       return (0);
+       return 0;
 }
 
 static int
@@ -2989,32 +3111,36 @@ pf_normalize_tcpopt(struct pf_rule *r, int dir, struct pfi_kif *kif,
 {
 #pragma unused(dir, kif)
        sa_family_t af = pd->af;
-       u_int16_t       *mss;
-       int             thoff;
-       int             opt, cnt, optlen = 0;
-       int             rewrite = 0;
-       u_char          opts[MAX_TCPOPTLEN];
-       u_char          *optp = opts;
+       u_int16_t       *mss;
+       int             thoff;
+       int             opt, cnt, optlen = 0;
+       int             rewrite = 0;
+       u_char          opts[MAX_TCPOPTLEN];
+       u_char          *optp = opts;
 
        thoff = th->th_off << 2;
-       cnt = thoff - sizeof (struct tcphdr);
+       cnt = thoff - sizeof(struct tcphdr);
 
-       if (cnt > 0 && !pf_pull_hdr(pbuf, off + sizeof (*th), opts, cnt,
-           NULL, NULL, af))
+       if (cnt > 0 && !pf_pull_hdr(pbuf, off + sizeof(*th), opts, cnt,
+           NULL, NULL, af)) {
                return PF_DROP;
+       }
 
        for (; cnt > 0; cnt -= optlen, optp += optlen) {
                opt = optp[0];
-               if (opt == TCPOPT_EOL)
+               if (opt == TCPOPT_EOL) {
                        break;
-               if (opt == TCPOPT_NOP)
+               }
+               if (opt == TCPOPT_NOP) {
                        optlen = 1;
-               else {
-                       if (cnt < 2)
+               else {
+                       if (cnt < 2) {
                                break;
+                       }
                        optlen = optp[1];
-                       if (optlen < 2 || optlen > cnt)
+                       if (optlen < 2 || optlen > cnt) {
                                break;
+                       }
                }
                switch (opt) {
                case TCPOPT_MAXSEG:
@@ -3026,9 +3152,10 @@ pf_normalize_tcpopt(struct pf_rule *r, int dir, struct pfi_kif *kif,
                                 * checksum calculation will not be performed.
                                 */
                                if (pbuf->pb_ifp ||
-                                   !(*pbuf->pb_csum_flags & CSUM_TCP))
+                                   !(*pbuf->pb_csum_flags & CSUM_TCP)) {
                                        th->th_sum = pf_cksum_fixup(th->th_sum,
                                            *mss, htons(r->max_mss), 0);
+                               }
                                *mss = htons(r->max_mss);
                                rewrite = 1;
                        }
@@ -3044,16 +3171,17 @@ pf_normalize_tcpopt(struct pf_rule *r, int dir, struct pfi_kif *kif,
                VERIFY(pbuf == pd->mp);
 
                if (pf_lazy_makewritable(pd, pd->mp,
-                   off + sizeof (*th) + thoff) == NULL) {
+                   off + sizeof(*th) + thoff) == NULL) {
                        REASON_SET(&reason, PFRES_MEMORY);
-                       if (r->log)
+                       if (r->log) {
                                PFLOG_PACKET(kif, h, pbuf, AF_INET, dir, reason,
                                    r, 0, 0, pd);
+                       }
                        return PF_DROP;
                }
 
                *rewrptr = 1;
-               pbuf_copy_back(pd->mp, off + sizeof (*th), thoff - sizeof (*th), opts);
+               pbuf_copy_back(pd->mp, off + sizeof(*th), thoff - sizeof(*th), opts);
        }
 
        return PF_PASS;