tcp: update the netstamp_needed counter when cloning sockets
authorOctavian Purdila <opurdila@ixiacom.com>
Fri, 8 Jan 2010 08:00:09 +0000 (00:00 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Jan 2010 08:00:09 +0000 (00:00 -0800)
This fixes a netstamp_needed accounting issue when the listen socket
has SO_TIMESTAMP set:

    s = socket(AF_INET, SOCK_STREAM, 0);
    setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, 1); -> netstamp_needed = 1
    bind(s, ...);
    listen(s, ...);
    s2 = accept(s, ...); -> netstamp_needed = 1
    close(s2); -> netstamp_needed = 0
    close(s); -> netstamp_needed = -1

Signed-off-by: Octavian Purdila <opurdila@ixiacom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c

index 76ff58d43e261c34e630034571d7c48f34d16ffc..e1f6f225f012eaa513ba556c8833fb85a5b5f575 100644 (file)
@@ -1205,6 +1205,10 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority)
 
                if (newsk->sk_prot->sockets_allocated)
                        percpu_counter_inc(newsk->sk_prot->sockets_allocated);
+
+               if (sock_flag(newsk, SOCK_TIMESTAMP) ||
+                   sock_flag(newsk, SOCK_TIMESTAMPING_RX_SOFTWARE))
+                       net_enable_timestamp();
        }
 out:
        return newsk;