static void domain_sched_timeout(void);
static void domain_timeout(void *);
-lck_grp_t *domain_proto_mtx_grp;
-lck_attr_t *domain_proto_mtx_attr;
-static lck_grp_attr_t *domain_proto_mtx_grp_attr;
-decl_lck_mtx_data(static, domain_proto_mtx);
-decl_lck_mtx_data(static, domain_timeout_mtx);
+static LCK_GRP_DECLARE(domain_proto_mtx_grp, "domain");
+static LCK_ATTR_DECLARE(domain_proto_mtx_attr, 0, 0);
+static LCK_MTX_DECLARE_ATTR(domain_proto_mtx,
+ &domain_proto_mtx_grp, &domain_proto_mtx_attr);
+static LCK_MTX_DECLARE_ATTR(domain_timeout_mtx,
+ &domain_proto_mtx_grp, &domain_proto_mtx_attr);
u_int64_t _net_uptime;
+u_int64_t _net_uptime_ms;
#if (DEVELOPMENT || DEBUG)
VERIFY(dp->dom_flags & DOM_ATTACHED);
if (!(dp->dom_flags & DOM_INITIALIZED)) {
- lck_mtx_init(&dp->dom_mtx_s, domain_proto_mtx_grp,
- domain_proto_mtx_attr);
+ lck_mtx_init(&dp->dom_mtx_s, &domain_proto_mtx_grp,
+ &domain_proto_mtx_attr);
dp->dom_mtx = &dp->dom_mtx_s;
TAILQ_INIT(&dp->dom_protosw);
if (dp->dom_init != NULL) {
/* NOTREACHED */
}
- dp = _MALLOC(sizeof(*dp), M_TEMP, M_WAITOK | M_ZERO);
+ dp = kheap_alloc(KHEAP_DEFAULT, sizeof(struct domain), Z_WAITOK | Z_ZERO);
if (dp == NULL) {
/*
* There is really nothing better than to panic here,
TAILQ_FOREACH_SAFE(pp1, &dp1->dom_protosw, pr_entry, pp2) {
detach_proto(pp1, dp1);
if (pp1->pr_usrreqs->pru_flags & PRUF_OLD) {
- FREE(pp1->pr_usrreqs, M_TEMP);
+ kheap_free(KHEAP_DEFAULT, pp1->pr_usrreqs, sizeof(struct pr_usrreqs));
}
if (pp1->pr_flags & PR_OLD) {
- FREE(pp1, M_TEMP);
+ kheap_free(KHEAP_DEFAULT, pp1, sizeof(struct protosw));
}
}
detach_domain(dp1);
- FREE(dp1, M_TEMP);
+ kheap_free(KHEAP_DEFAULT, dp1, sizeof(struct domain));
} else {
error = EPFNOSUPPORT;
}
/* NOTREACHED */
}
- pru = _MALLOC(sizeof(*pru), M_TEMP, M_WAITOK | M_ZERO);
+ pru = kheap_alloc(KHEAP_DEFAULT, sizeof(struct pr_usrreqs),
+ Z_WAITOK | Z_ZERO);
if (pru == NULL) {
error = ENOMEM;
goto done;
pru->pru_soreceive = opru->pru_soreceive;
pru->pru_sopoll = opru->pru_sopoll;
- pp = _MALLOC(sizeof(*pp), M_TEMP, M_WAITOK | M_ZERO);
+ pp = kheap_alloc(KHEAP_DEFAULT, sizeof(struct protosw), Z_WAITOK | Z_ZERO);
if (pp == NULL) {
error = ENOMEM;
goto done;
"error %d\n", __func__, odp->dom_family,
odp->dom_name, opp->pr_protocol, error);
- if (pru != NULL) {
- FREE(pru, M_TEMP);
- }
- if (pp != NULL) {
- FREE(pp, M_TEMP);
- }
+ kheap_free(KHEAP_DEFAULT, pru, sizeof(struct pr_usrreqs));
+ kheap_free(KHEAP_DEFAULT, pp, sizeof(struct protosw));
}
domain_guard_release(guard);
detach_proto(pp, dp);
if (pp->pr_usrreqs->pru_flags & PRUF_OLD) {
- FREE(pp->pr_usrreqs, M_TEMP);
+ kheap_free(KHEAP_DEFAULT, pp->pr_usrreqs, sizeof(struct pr_usrreqs));
}
if (pp->pr_flags & PR_OLD) {
- FREE(pp, M_TEMP);
+ kheap_free(KHEAP_DEFAULT, pp, sizeof(struct protosw));
}
return 0;
}
detach_proto(pp, dp);
if (pp->pr_usrreqs->pru_flags & PRUF_OLD) {
- FREE(pp->pr_usrreqs, M_TEMP);
+ kheap_free(KHEAP_DEFAULT, pp->pr_usrreqs, sizeof(struct pr_usrreqs));
}
if (pp->pr_flags & PR_OLD) {
- FREE(pp, M_TEMP);
+ kheap_free(KHEAP_DEFAULT, pp, sizeof(struct protosw));
}
done:
lck_mtx_unlock(&domain_timeout_mtx);
}
-#if INET6
extern struct domain inet6domain_s;
-#endif
#if IPSEC
extern struct domain keydomain_s;
#endif
extern struct domain routedomain_s, ndrvdomain_s, inetdomain_s;
extern struct domain systemdomain_s, localdomain_s;
+extern struct domain vsockdomain_s;
#if MULTIPATH
extern struct domain mpdomain_s;
domain_guard_t guard;
eventhandler_lists_ctxt_init(&protoctl_evhdlr_ctxt);
- /*
- * allocate lock group attribute and group for domain mutexes
- */
- domain_proto_mtx_grp_attr = lck_grp_attr_alloc_init();
-
- domain_proto_mtx_grp = lck_grp_alloc_init("domain",
- domain_proto_mtx_grp_attr);
-
- /*
- * allocate the lock attribute for per domain mutexes
- */
- domain_proto_mtx_attr = lck_attr_alloc_init();
-
- lck_mtx_init(&domain_proto_mtx, domain_proto_mtx_grp,
- domain_proto_mtx_attr);
- lck_mtx_init(&domain_timeout_mtx, domain_proto_mtx_grp,
- domain_proto_mtx_attr);
guard = domain_guard_deploy();
/*
* dom_rtattach() called on rt_tables[].
*/
attach_domain(&inetdomain_s);
-#if INET6
attach_domain(&inet6domain_s);
-#endif /* INET6 */
#if MULTIPATH
attach_domain(&mpdomain_s);
#endif /* MULTIPATH */
attach_domain(&keydomain_s);
#endif /* IPSEC */
attach_domain(&ndrvdomain_s);
+ attach_domain(&vsockdomain_s);
attach_domain(&routedomain_s); /* must be last domain */
/*
if (tvp->tv_usec > 500000) {
_net_uptime++;
}
+
+ /* update milliseconds variant */
+ _net_uptime_ms = (((u_int64_t)tvp->tv_sec * 1000) +
+ ((u_int64_t)tvp->tv_usec / 1000));
}
void
}
tv->tv_usec = 0;
- tv->tv_sec = net_uptime();
+ tv->tv_sec = (time_t)net_uptime();
}
/*
return _net_uptime;
}
+u_int64_t
+net_uptime_ms(void)
+{
+ if (_net_uptime_ms == 0) {
+ net_update_uptime();
+ }
+
+ return _net_uptime_ms;
+}
+
void
domain_proto_mtx_lock_assert_held(void)
{