netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: TX timestamps for IPv6 UDP packets
@ 2011-02-22 21:43 Anders Berggren
  2011-02-28 20:31 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Anders Berggren @ 2011-02-22 21:43 UTC (permalink / raw)
  To: John Ronciak; +Cc: netdev

Enabling TX timestamps (SO_TIMESTAMPING) for IPv6 UDP packets, in 
the same fashion as for IPv4. Necessary in order for NICs such as
Intel 82580 to timestamp IPv6 packets.

Signed-off-by: Anders Berggren <anders@halon.se>
---

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 94b5bf1..74d9343 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1115,6 +1115,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
 	int err;
 	int offset = 0;
 	int csummode = CHECKSUM_NONE;
+	__u8 tx_flags = 0;
 
 	if (flags&MSG_PROBE)
 		return 0;
@@ -1199,6 +1200,13 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
 		}
 	}
 
+	/* For UDP, check if TX timestamp is enabled */
+	if (sk->sk_type == SOCK_DGRAM) {
+		err = sock_tx_timestamp(sk, &tx_flags);
+		if (err)
+			goto error;
+	}
+
 	/*
 	 * Let's try using as much space as possible.
 	 * Use MTU if total length of the message fits into the MTU.
@@ -1303,6 +1311,10 @@ alloc_new_skb:
 							   sk->sk_allocation);
 				if (unlikely(skb == NULL))
 					err = -ENOBUFS;
+				else
+					/* only the initial fragment is
+					   time stamped */
+					tx_flags = 0;
 			}
 			if (skb == NULL)
 				goto error;
@@ -1314,6 +1326,9 @@ alloc_new_skb:
 			/* reserve for fragmentation */
 			skb_reserve(skb, hh_len+sizeof(struct frag_hdr));
 
+			if (sk->sk_type == SOCK_DGRAM)
+				skb_shinfo(skb)->tx_flags = tx_flags;
+
 			/*
 			 *	Find where to start putting bytes
 			 */

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

* Re: [PATCH] net: TX timestamps for IPv6 UDP packets
  2011-02-22 21:43 [PATCH] net: TX timestamps for IPv6 UDP packets Anders Berggren
@ 2011-02-28 20:31 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-02-28 20:31 UTC (permalink / raw)
  To: anders; +Cc: john.ronciak, netdev

From: Anders Berggren <anders@halon.se>
Date: Tue, 22 Feb 2011 22:43:47 +0100

> Enabling TX timestamps (SO_TIMESTAMPING) for IPv6 UDP packets, in 
> the same fashion as for IPv4. Necessary in order for NICs such as
> Intel 82580 to timestamp IPv6 packets.
> 
> Signed-off-by: Anders Berggren <anders@halon.se>

I'll apply this, thanks.

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

end of thread, other threads:[~2011-02-28 20:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-22 21:43 [PATCH] net: TX timestamps for IPv6 UDP packets Anders Berggren
2011-02-28 20:31 ` 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).