netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net-timestamp: cumulative tcp timestamping fixes
@ 2014-08-06 19:09 Willem de Bruijn
  2014-08-06 21:09 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Willem de Bruijn @ 2014-08-06 19:09 UTC (permalink / raw)
  To: netdev; +Cc: davem, eric.dumazet, richardcochran, Willem de Bruijn

A set of small fixes pointed out just after the merge:
- make tcp_tx_timestamp static
- make tcp_gso_tstamp static
- use before() to compare TCP seqno, instead of cast to u64
- add tstamp to tx_flags in GSO, instead of overwrite tx_flags
- record skb_shinfo(skb)->tskey for all timestamps, also HW.
- optimization in tcp_tx_timestamp:
  call sock_tx_timestamp only if a tstamp option is set.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Fixes: 4ed2d765dfac ("net-timestamp: TCP timestamping")

---

The sock_tx_timestamp optimization can also apply to others callers.
Basically, the following and related changes to net/socket.c

-void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags);
+void sock_tx_timestamp(struct sock *sk, __u8 *tx_flags) {
+       if (sk->sk_tsflags)
+               __sock_tx_timestamp(sk, tx_flags);
+}
+
+void __sock_tx_timestamp(struct sock *sk, __u8 *tx_flags);

But that is less critical and this patch combines enough items
already. I plan to send it as a separate patch once net-next
reopens, unless you prefer me to squash it into this one.
---
 net/ipv4/tcp.c         | 12 +++++++-----
 net/ipv4/tcp_offload.c |  8 ++++----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 744af67..181b70e 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -426,13 +426,15 @@ void tcp_init_sock(struct sock *sk)
 }
 EXPORT_SYMBOL(tcp_init_sock);
 
-void tcp_tx_timestamp(struct sock *sk, struct sk_buff *skb)
+static void tcp_tx_timestamp(struct sock *sk, struct sk_buff *skb)
 {
-	struct skb_shared_info *shinfo = skb_shinfo(skb);
+	if (sk->sk_tsflags) {
+		struct skb_shared_info *shinfo = skb_shinfo(skb);
 
-	sock_tx_timestamp(sk, &shinfo->tx_flags);
-	if (shinfo->tx_flags & SKBTX_ANY_SW_TSTAMP)
-		shinfo->tskey = TCP_SKB_CB(skb)->seq + skb->len - 1;
+		sock_tx_timestamp(sk, &shinfo->tx_flags);
+		if (shinfo->tx_flags & SKBTX_ANY_TSTAMP)
+			shinfo->tskey = TCP_SKB_CB(skb)->seq + skb->len - 1;
+	}
 }
 
 /*
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index f597119..bc1b83c 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -14,12 +14,12 @@
 #include <net/tcp.h>
 #include <net/protocol.h>
 
-void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq, unsigned int seq,
-		    unsigned int mss)
+static void tcp_gso_tstamp(struct sk_buff *skb, unsigned int ts_seq,
+			   unsigned int seq, unsigned int mss)
 {
 	while (skb) {
-		if (ts_seq < (__u64) seq + mss) {
-			skb_shinfo(skb)->tx_flags = SKBTX_SW_TSTAMP;
+		if (before(ts_seq, seq + mss)) {
+			skb_shinfo(skb)->tx_flags |= SKBTX_SW_TSTAMP;
 			skb_shinfo(skb)->tskey = ts_seq;
 			return;
 		}
-- 
2.0.0.526.g5318336

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net-timestamp: cumulative tcp timestamping fixes
  2014-08-06 19:09 [PATCH net-next] net-timestamp: cumulative tcp timestamping fixes Willem de Bruijn
@ 2014-08-06 21:09 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2014-08-06 21:09 UTC (permalink / raw)
  To: willemb; +Cc: netdev, eric.dumazet, richardcochran

From: Willem de Bruijn <willemb@google.com>
Date: Wed,  6 Aug 2014 15:09:44 -0400

> A set of small fixes pointed out just after the merge:
> - make tcp_tx_timestamp static
> - make tcp_gso_tstamp static
> - use before() to compare TCP seqno, instead of cast to u64
> - add tstamp to tx_flags in GSO, instead of overwrite tx_flags
> - record skb_shinfo(skb)->tskey for all timestamps, also HW.
> - optimization in tcp_tx_timestamp:
>   call sock_tx_timestamp only if a tstamp option is set.
> 
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> Fixes: 4ed2d765dfac ("net-timestamp: TCP timestamping")

Applied, thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-06 21:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-06 19:09 [PATCH net-next] net-timestamp: cumulative tcp timestamping fixes Willem de Bruijn
2014-08-06 21:09 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).