]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/pf_if.c
xnu-4903.241.1.tar.gz
[apple/xnu.git] / bsd / net / pf_if.c
index 9dec8f7604d3a1eb1700026e7ff082fe9436b275..f67d06a5dd1334c2e5ae47d1ab90b6bcec7de2ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007-2013 Apple Inc. All rights reserved.
+ * Copyright (c) 2007-2016 Apple Inc. All rights reserved.
  *
  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  *
@@ -231,7 +231,7 @@ pfi_attach_ifnet(struct ifnet *ifp)
 {
        struct pfi_kif *kif;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        pfi_update++;
        if ((kif = pfi_kif_get(if_name(ifp))) == NULL)
@@ -253,7 +253,7 @@ pfi_detach_ifnet(struct ifnet *ifp)
 {
        struct pfi_kif          *kif;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        if ((kif = (struct pfi_kif *)ifp->if_pf_kif) == NULL)
                return;
@@ -284,7 +284,6 @@ pfi_match_addr(struct pfi_dynaddr *dyn, struct pf_addr *a, sa_family_t af)
                default:
                        return (pfr_match_addr(dyn->pfid_kt, a, AF_INET));
                }
-               break;
 #endif /* INET */
 #if INET6
        case AF_INET6:
@@ -297,7 +296,6 @@ pfi_match_addr(struct pfi_dynaddr *dyn, struct pf_addr *a, sa_family_t af)
                default:
                        return (pfr_match_addr(dyn->pfid_kt, a, AF_INET6));
                }
-               break;
 #endif /* INET6 */
        default:
                return (0);
@@ -312,7 +310,7 @@ pfi_dynaddr_setup(struct pf_addr_wrap *aw, sa_family_t af)
        struct pf_ruleset       *ruleset = NULL;
        int                      rv = 0;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        if (aw->type != PF_ADDR_DYNIFTL)
                return (0);
@@ -380,7 +378,7 @@ pfi_kif_update(struct pfi_kif *kif)
 {
        struct pfi_dynaddr      *p;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        /* update all dynaddr */
        TAILQ_FOREACH(p, &kif->pfik_dynaddrs, entry)
@@ -578,7 +576,7 @@ pfi_kifaddr_update(void *v)
 {
        struct pfi_kif          *kif = (struct pfi_kif *)v;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        pfi_update++;
        pfi_kif_update(kif);
@@ -597,31 +595,30 @@ pfi_update_status(const char *name, struct pf_status *pfs)
        struct pfi_kif_cmp       key;
        int                      i, j, k;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        strlcpy(key.pfik_name, name, sizeof (key.pfik_name));
        p = RB_FIND(pfi_ifhead, &pfi_ifs, (struct pfi_kif *)(void *)&key);
        if (p == NULL)
                return;
 
-       if (pfs) {
+       if (pfs != NULL) {
                bzero(pfs->pcounters, sizeof (pfs->pcounters));
                bzero(pfs->bcounters, sizeof (pfs->bcounters));
-       }
-       /* just clear statistics */
-       if (pfs == NULL) {
+               for (i = 0; i < 2; i++)
+                       for (j = 0; j < 2; j++)
+                               for (k = 0; k < 2; k++) {
+                                       pfs->pcounters[i][j][k] +=
+                                               p->pfik_packets[i][j][k];
+                                       pfs->bcounters[i][j] +=
+                                               p->pfik_bytes[i][j][k];
+                               }
+       } else {
+               /* just clear statistics */
                bzero(p->pfik_packets, sizeof (p->pfik_packets));
                bzero(p->pfik_bytes, sizeof (p->pfik_bytes));
                p->pfik_tzero = pf_calendar_time_second();
        }
-       for (i = 0; i < 2; i++)
-               for (j = 0; j < 2; j++)
-                       for (k = 0; k < 2; k++) {
-                               pfs->pcounters[i][j][k] +=
-                                   p->pfik_packets[i][j][k];
-                               pfs->bcounters[i][j] +=
-                                   p->pfik_bytes[i][j][k];
-                       }
 }
 
 int
@@ -630,7 +627,7 @@ pfi_get_ifaces(const char *name, user_addr_t buf, int *size)
        struct pfi_kif   *p, *nextp;
        int              n = 0;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        for (p = RB_MIN(pfi_ifhead, &pfi_ifs); p; p = nextp) {
                nextp = RB_NEXT(pfi_ifhead, &pfi_ifs, p);
@@ -692,7 +689,7 @@ pfi_set_flags(const char *name, int flags)
 {
        struct pfi_kif  *p;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        RB_FOREACH(p, pfi_ifhead, &pfi_ifs) {
                if (pfi_skip_if(name, p))
@@ -707,7 +704,7 @@ pfi_clear_flags(const char *name, int flags)
 {
        struct pfi_kif  *p;
 
-       lck_mtx_assert(pf_lock, LCK_MTX_ASSERT_OWNED);
+       LCK_MTX_ASSERT(pf_lock, LCK_MTX_ASSERT_OWNED);
 
        RB_FOREACH(p, pfi_ifhead, &pfi_ifs) {
                if (pfi_skip_if(name, p))