[PATCH] net: TX timestamps for IPv6 UDP packets

Subsystems: networking [general], networking [ipv4/ipv6], the rest

STALE5638d

2 messages, 2 authors, 2011-02-28 · open the first message on its own page

[PATCH] net: TX timestamps for IPv6 UDP packets

From: Anders Berggren <hidden>
Date: 2011-02-22 21:43:53

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 <redacted>
---
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
 			 */

Re: [PATCH] net: TX timestamps for IPv6 UDP packets

From: David Miller <davem@davemloft.net>
Date: 2011-02-28 20:30:24

From: Anders Berggren <redacted>
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 <redacted>
I'll apply this, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help