[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1318573288-18286-6-git-send-email-jeffrey.t.kirsher@intel.com>
Date: Thu, 13 Oct 2011 23:21:27 -0700
From: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
To: davem@...emloft.net
Cc: Jacob Keller <jacob.e.keller@...el.com>, netdev@...r.kernel.org,
gospo@...hat.com, sassmann@...hat.com,
Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Subject: [net-next 5/6] igb: fix timecompare_upate race condition
From: Jacob Keller <jacob.e.keller@...el.com>
This patch closes a possible race condition when timestamping using
the timecompare_update function as a method to detect clock skew of
the internal cycle counter. Because timecompare_update usually allows
skew detection no more than once a second, if ptpd or other software
performs a clock offset (for example, using the "date" command), there
is a small window of time where the clock skew will not match the
current kernel wall time. This patch forces the timecompare_update to
calculate skew every time we timestamp a packet, which removes the
possibility of this race condition.
Signed-off-by: Jacob E Keller <jacob.e.keller@...el.com>
Tested-by: Aaron Brown <aaron.f.brown@...el.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
---
drivers/net/ethernet/intel/igb/igb_main.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index c10cc71..8f3296d 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -5581,7 +5581,15 @@ static void igb_systim_to_hwtstamp(struct igb_adapter *adapter,
regval <<= IGB_82580_TSYNC_SHIFT;
ns = timecounter_cyc2time(&adapter->clock, regval);
- timecompare_update(&adapter->compare, ns);
+
+ /*
+ * force timecompare_update to calculate the skew (even if
+ * less than one second has passed since the last update) in
+ * order to prevent the possibility that an offset has been
+ * applied to the wall time. this ensures valid timestamps are
+ * passed to the network stack.
+ */
+ timecompare_update(&adapter->compare, 0);
memset(shhwtstamps, 0, sizeof(struct skb_shared_hwtstamps));
shhwtstamps->hwtstamp = ns_to_ktime(ns);
shhwtstamps->syststamp = timecompare_transform(&adapter->compare, ns);
--
1.7.6.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists