<html>
    <head>
      <base href="https://bugzilla.netfilter.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:fw@strlen.de" title="Florian Westphal <fw@strlen.de>"> <span class="fn">Florian Westphal</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - nfq_get_timestamp() not setting timeval struc"
   href="https://bugzilla.netfilter.org/show_bug.cgi?id=1066">bug 1066</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>NEW
           </td>
           <td>ASSIGNED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">CC</td>
           <td>
                
           </td>
           <td>fw@strlen.de
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Assignee</td>
           <td>netfilter-buglog@lists.netfilter.org
           </td>
           <td>fw@strlen.de
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - nfq_get_timestamp() not setting timeval struc"
   href="https://bugzilla.netfilter.org/show_bug.cgi?id=1066#c1">Comment # 1</a>
              on <a class="bz_bug_link 
          bz_status_ASSIGNED "
   title="ASSIGNED - nfq_get_timestamp() not setting timeval struc"
   href="https://bugzilla.netfilter.org/show_bug.cgi?id=1066">bug 1066</a>
              from <span class="vcard"><a class="email" href="mailto:fw@strlen.de" title="Florian Westphal <fw@strlen.de>"> <span class="fn">Florian Westphal</span></a>
</span></b>
        <pre>(In reply to emacsuser123 from <a href="show_bug.cgi?id=1066#c0">comment #0</a>)
<span class="quote">> Hi.

> I'm developing an application that makes use of NFQUEUE functionality.

> When using Ubuntu with recent kernels (4.4 and onwards), I'm having trouble
> trying to get the packet timestamp by means of nfq_get_timestamp.
> It seems that it does nothing with the timeval struct passed as an input
> parameter. So, I always get 0 on both tv_sec and tv_usec fields.

> If I use older kernels (3.3, for instance), I have no problem at all. The
> timeval struct is filled in successfully and I get the proper timestamp from
> the kernel.

> I have also tried to set the queue socket options to SO_TIMESTAMP
> explicitly, just in case. The call to setsockopt goes smoothly, but it seems
> that nfq_get_timestamp is not taking that into account.

> I'm not sure what else could be done here, to be honest.

> Any ideas?

> Thanks a lot.
> -Bob</span >

Kernel bug, this should fix it:

diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -557,7 +557,7 @@ nfqnl_build_packet_message(struct net *net, struct
nfqnl_instance *queue,

        if (entskb->tstamp.tv64) {
                struct nfqnl_msg_packet_timestamp ts;
-               struct timespec64 kts = ktime_to_timespec64(skb->tstamp);
+               struct timespec64 kts = ktime_to_timespec64(entskb->tstamp);

                ts.sec = cpu_to_be64(kts.tv_sec);
                ts.usec = cpu_to_be64(kts.tv_nsec / NSEC_PER_USEC);</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are watching all bug changes.</li>
      </ul>
    </body>
</html>