diff options
author | Josef 'Jeff' Sipek <josef.sipek@nexenta.com> | 2014-05-07 10:58:45 -0400 |
---|---|---|
committer | Richard Lowe <richlowe@richlowe.net> | 2014-05-14 19:37:59 -0400 |
commit | 4d6a58d3c7586ed5866f9309d460081a9102c5e6 (patch) | |
tree | e60aa05eb40b46328b0d049a6022411f4bca814a | |
parent | 12928d597a28b7743c3fc254b6fcfc05560c1720 (diff) | |
download | illumos-joyent-4d6a58d3c7586ed5866f9309d460081a9102c5e6.tar.gz |
4788 mac shouldn't abuse ddi_get_time(9f)
Reviewed by: Hans Rosenfeld <hans.rosenfeld@nexenta.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
-rw-r--r-- | usr/src/uts/common/io/mac/mac_protect.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/usr/src/uts/common/io/mac/mac_protect.c b/usr/src/uts/common/io/mac/mac_protect.c index 0dc825492e..15e6b3de6f 100644 --- a/usr/src/uts/common/io/mac/mac_protect.c +++ b/usr/src/uts/common/io/mac/mac_protect.c @@ -22,6 +22,9 @@ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. */ +/* + * Copyright 2014 Nexenta Systems, Inc. All rights reserved. + */ #include <sys/strsun.h> #include <sys/sdt.h> @@ -141,7 +144,7 @@ */ static ulong_t dhcp_max_pending_txn = 512; static ulong_t dhcp_max_completed_txn = 512; -static time_t txn_cleanup_interval = 60; +static hrtime_t txn_cleanup_interval = 60 * NANOSEC; /* * DHCPv4 transaction. It may be added to three different tables @@ -149,7 +152,7 @@ static time_t txn_cleanup_interval = 60; */ typedef struct dhcpv4_txn { uint32_t dt_xid; - time_t dt_timestamp; + hrtime_t dt_timestamp; uint8_t dt_cid[DHCP_MAX_OPT_SIZE]; uint8_t dt_cid_len; ipaddr_t dt_ipaddr; @@ -186,7 +189,7 @@ typedef struct dhcpv6_cid { */ typedef struct dhcpv6_txn { uint32_t dt_xid; - time_t dt_timestamp; + hrtime_t dt_timestamp; dhcpv6_cid_t *dt_cid; avl_node_t dt_node; struct dhcpv6_txn *dt_next; @@ -455,7 +458,7 @@ create_dhcpv4_txn(uint32_t xid, uint8_t *cid, uint8_t cid_len, ipaddr_t ipaddr) return (NULL); txn->dt_xid = xid; - txn->dt_timestamp = ddi_get_time(); + txn->dt_timestamp = gethrtime(); if (cid_len > 0) bcopy(cid, &txn->dt_cid, cid_len); txn->dt_cid_len = cid_len; @@ -512,8 +515,7 @@ txn_cleanup_v4(mac_client_impl_t *mcip) */ for (txn = avl_first(&mcip->mci_v4_pending_txn); txn != NULL; txn = avl_walk(&mcip->mci_v4_pending_txn, txn, AVL_AFTER)) { - if (ddi_get_time() - txn->dt_timestamp > - txn_cleanup_interval) { + if (gethrtime() - txn->dt_timestamp > txn_cleanup_interval) { DTRACE_PROBE2(found__expired__txn, mac_client_impl_t *, mcip, dhcpv4_txn_t *, txn); @@ -617,7 +619,7 @@ intercept_dhcpv4_outbound(mac_client_impl_t *mcip, ipha_t *ipha, uchar_t *end) if ((txn = find_dhcpv4_pending_txn(mcip, dh4->xid)) != NULL) { DTRACE_PROBE2(update, mac_client_impl_t *, mcip, dhcpv4_txn_t *, txn); - txn->dt_timestamp = ddi_get_time(); + txn->dt_timestamp = gethrtime(); goto done; } @@ -1116,7 +1118,7 @@ create_dhcpv6_txn(uint32_t xid, dhcpv6_cid_t *cid) txn->dt_xid = xid; txn->dt_cid = cid; - txn->dt_timestamp = ddi_get_time(); + txn->dt_timestamp = gethrtime(); return (txn); } @@ -1183,8 +1185,7 @@ txn_cleanup_v6(mac_client_impl_t *mcip) */ for (txn = avl_first(&mcip->mci_v6_pending_txn); txn != NULL; txn = avl_walk(&mcip->mci_v6_pending_txn, txn, AVL_AFTER)) { - if (ddi_get_time() - txn->dt_timestamp > - txn_cleanup_interval) { + if (gethrtime() - txn->dt_timestamp > txn_cleanup_interval) { DTRACE_PROBE2(found__expired__txn, mac_client_impl_t *, mcip, dhcpv6_txn_t *, txn); @@ -1248,7 +1249,7 @@ intercept_dhcpv6_outbound(mac_client_impl_t *mcip, ip6_t *ip6h, uchar_t *end) if ((txn = find_dhcpv6_pending_txn(mcip, xid)) != NULL) { DTRACE_PROBE2(update, mac_client_impl_t *, mcip, dhcpv6_txn_t *, txn); - txn->dt_timestamp = ddi_get_time(); + txn->dt_timestamp = gethrtime(); goto done; } if ((txn = create_dhcpv6_txn(xid, cid)) == NULL) @@ -1357,7 +1358,7 @@ txn_cleanup_timer(void *arg) DTRACE_PROBE1(restarting__timer, mac_client_impl_t *, mcip); mcip->mci_txn_cleanup_tid = timeout(txn_cleanup_timer, mcip, - drv_usectohz(txn_cleanup_interval * 1000000)); + drv_usectohz(txn_cleanup_interval / (NANOSEC / MICROSEC))); } mutex_exit(&mcip->mci_protect_lock); } @@ -1368,7 +1369,7 @@ start_txn_cleanup_timer(mac_client_impl_t *mcip) ASSERT(MUTEX_HELD(&mcip->mci_protect_lock)); if (mcip->mci_txn_cleanup_tid == 0) { mcip->mci_txn_cleanup_tid = timeout(txn_cleanup_timer, mcip, - drv_usectohz(txn_cleanup_interval * 1000000)); + drv_usectohz(txn_cleanup_interval / (NANOSEC / MICROSEC))); } } |