tcp: update the netstamp_needed counter when cloning sockets

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Tuesday, January 12, 2010 - 10:59 pm

Gitweb:     http://git.kernel.org/linus/704da560c0a0120d8869187f511491a00951a1d3
Commit:     704da560c0a0120d8869187f511491a00951a1d3
Parent:     1ca518b64b4b5865b677f292322e893fa89997d4
Author:     Octavian Purdila <opurdila@ixiacom.com>
AuthorDate: Fri Jan 8 00:00:09 2010 -0800
Committer:  David S. Miller <davem@davemloft.net>
CommitDate: Fri Jan 8 00:00:09 2010 -0800

    tcp: update the netstamp_needed counter when cloning sockets
    
    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 |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index 76ff58d..e1f6f22 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -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;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
tcp: update the netstamp_needed counter when cloning sockets, Linux Kernel Mailing ..., (Tue Jan 12, 10:59 pm)