  /*
   * This structure really needs to be cleaned up.
   * Most of it is for TCP, and not used by any of
-@@ -301,6 +305,12 @@ struct sock {
+@@ -301,6 +305,11 @@ struct sock {
    	int			(*sk_backlog_rcv)(struct sock *sk,
  						  struct sk_buff *skb);  
  	void                    (*sk_destruct)(struct sock *sk);
 +
 +#ifdef CONFIG_FFCLOCK
 +	ffcounter_t		sk_ffclock_stamp;
-+	ktime_t			sk_stamp_fair; /* FFClock Fair Compare Mode */
 +	int			sk_ffclock_tsmode;
 +#endif
  };
  
  /*
 diff --git a/net/core/dev.c b/net/core/dev.c
-index fe10551..a095229 100644
+index fe10551..7345938 100644
 --- a/net/core/dev.c
 +++ b/net/core/dev.c
-@@ -1362,6 +1362,11 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
- {
- 	struct packet_type *ptype;
- 
-+#ifdef CONFIG_FFCLOCK
-+	ktime_t tv_fair;
-+	ffcounter_t ffcount;
-+#endif
-+
- #ifdef CONFIG_NET_CLS_ACT
- 	if (!(skb->tstamp.tv64 && (G_TC_FROM(skb->tc_verd) & AT_INGRESS)))
- 		net_timestamp(skb);
-@@ -1369,6 +1374,21 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
+@@ -1369,6 +1369,13 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev)
  	net_timestamp(skb);
  #endif
  
 +#ifdef CONFIG_FFCLOCK
-+	/* At this point, we have no way of knowing if we tap the packets
-+	 * in FFCLOCK_TSMODE_FAIRCOMPARE mode or not. So we take another
-+	 * timestamp we ensure to be 'fair'.
-+	 */
-+	rdtsc_barrier(); /* Make sure GCC doesn't mess up the compare */
-+	tv_fair = ktime_get_real();
-+	ffcount = read_ffcounter();
-+	rdtsc_barrier(); /* Make sure GCC doesn't mess up the compare */
-+
-+	/* Copy the two specific FFclock timestamps to the skbuff */
-+	skb->ffclock_stamp = ffcount;
-+	skb->tstamp_fair = tv_fair;
++	/* Updated the counter */
++	rdtsc_barrier();
++	skb->ffclock_stamp = read_ffcounter();
++	rdtsc_barrier();
 +#endif /* CONFIG_FFCLOCK */
 +
  	rcu_read_lock();
  	list_for_each_entry_rcu(ptype, &ptype_all, list) {
  		/* Never send packets back to the socket
-@@ -1998,10 +2018,30 @@ int netif_rx(struct sk_buff *skb)
- 	struct softnet_data *queue;
- 	unsigned long flags;
- 
-+#ifdef CONFIG_FFCLOCK
-+	/* At this point, we have no way of knowing if we tap the packets
-+	 * in FFCLOCK_TSMODE_FAIRCOMPARE mode or not. So we take another
-+	 * timestamp we ensure to be 'fair'.
-+	 */
-+	ktime_t tv_fair;
-+	ffcounter_t ffcount;
-+
-+	rdtsc_barrier(); /* Make sure GCC doesn't mess up the compare */
-+	ffcount = read_ffcounter();
-+	tv_fair = ktime_get_real();
-+	rdtsc_barrier(); /* Make sure GCC doesn't mess up the compare */
-+#endif /* CONFIG_FFCLOCK */
-+
- 	/* if netpoll wants it, pretend we never saw it */
+@@ -2002,6 +2009,13 @@ int netif_rx(struct sk_buff *skb)
  	if (netpoll_rx(skb))
  		return NET_RX_DROP;
  
 +#ifdef CONFIG_FFCLOCK
-+	/* Copy the two specific FFClock timestamps to the skbuff */
-+	skb->ffclock_stamp = ffcount;
-+	skb->tstamp_fair = tv_fair;
++	/* Update the counter */
++	rdtsc_barrier();
++	skb->ffclock_stamp = read_ffcounter();
++	rdtsc_barrier();
 +#endif
 +
  	if (!skb->tstamp.tv64)
  		net_timestamp(skb);
  
-@@ -2289,9 +2329,29 @@ int netif_receive_skb(struct sk_buff *skb)
+@@ -2289,6 +2303,13 @@ int netif_receive_skb(struct sk_buff *skb)
  	int ret = NET_RX_DROP;
  	__be16 type;
  
 +#ifdef CONFIG_FFCLOCK
-+	/* At this point, we have no way of knowing if we tap the packets
-+	 * in FFCLOCK_TSMODE_FAIRCOMPARE mode or not. So we take another
-+	 * timestamp we ensure to be 'fair'.
-+	 */
-+	ktime_t tv_fair;
-+	ffcounter_t ffcount;
-+
-+	rdtsc_barrier(); /* Make sure GCC doesn't mess up the compare */
-+	ffcount = read_ffcounter();
-+	tv_fair = ktime_get_real();
-+	rdtsc_barrier(); /* Make sure GCC doesn't mess up the compare */
++	/* Update the counter */
++	rdtsc_barrier();
++	skb->ffclock_stamp = read_ffcounter();
++	rdtsc_barrier();
 +#endif /* CONFIG_FFCLOCK */
 +
  	if (!skb->tstamp.tv64)
  		net_timestamp(skb);
  
-+#ifdef CONFIG_FFCLOCK
-+	/* Copy the two specific FFClock timestamps to the skbuff */
-+	skb->ffclock_stamp = ffcount;
-+	skb->tstamp_fair = tv_fair;
-+#endif
-+
- 	if (skb->vlan_tci && vlan_hwaccel_do_receive(skb))
- 		return NET_RX_SUCCESS;
- 
 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
-index ec85681..2610af1 100644
+index ec85681..e9c6812 100644
 --- a/net/core/skbuff.c
 +++ b/net/core/skbuff.c
-@@ -207,6 +207,10 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
+@@ -207,6 +207,9 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask,
  #ifdef NET_SKBUFF_DATA_USES_OFFSET
  	skb->mac_header = ~0U;
  #endif
 +#ifdef CONFIG_FFCLOCK
 +	skb->ffclock_stamp = 0;
-+	skb->tstamp_fair = ktime_set(-1L, -1L);
 +#endif
  
  	/* make sure we initialize shinfo sequentially */
  	shinfo = skb_shinfo(skb);
-@@ -526,6 +530,10 @@ EXPORT_SYMBOL(skb_recycle_check);
+@@ -526,6 +529,9 @@ EXPORT_SYMBOL(skb_recycle_check);
  static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
  {
  	new->tstamp		= old->tstamp;
 +#ifdef CONFIG_FFCLOCK
 +	new->ffclock_stamp	= old->ffclock_stamp;
-+	new->tstamp_fair	= old->tstamp_fair;
 +#endif
  	new->dev		= old->dev;
  	new->transport_header	= old->transport_header;
  	new->network_header	= old->network_header;
 diff --git a/net/core/sock.c b/net/core/sock.c
-index 7626b6a..103265c 100644
+index 7626b6a..0dd3657 100644
 --- a/net/core/sock.c
 +++ b/net/core/sock.c
 @@ -130,6 +130,10 @@

+#ifdef CONFIG_FFCLOCK
+static int rw_long_long(unsigned int fd, unsigned int cmd, unsigned long arg)
+{
+	int err;
+	__u64 val;
+	mm_segment_t old_fs = get_fs();
+	u64 __user *argptr = compat_ptr(arg);
+
+	if (get_user(val, argptr))
+		return -EFAULT;

 	switch (cmd) {
 	case SIOCOUTQ:
 	{
@@ -1999,9 +2077,42 @@ static int packet_ioctl(struct socket *sock, unsigned int cmd,
 		return put_user(amount, (int __user *)arg);
 	}
 	case SIOCGSTAMP:
