diff mbox

TX timestamp IPv6 support

Message ID 41D1D4BB-0CED-4396-B0FA-1DC42296DBCF@halon.se
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Anders Berggren Feb. 15, 2011, 1:56 p.m. UTC
This patch enables UDP IPv6 TX timestamping (using SO_TIMESTAMPING, enabled by CONFIG_NETWORK_PHY_TIMESTAMPING) as Marcus D. Leech suggested in http://kerneltrap.org/mailarchive/linux-netdev/2009/11/10/6260604 and http://kerneltrap.org/mailarchive/linux-netdev/2009/11/11/6260643 

It's mostly copied from net/ipv4/udp.c. I guess it would be better to run sock_tx_timestamp in ipv6/udp.c and pass it to ipv6/ip6_output.c's ip6_append_data somehow, but I didn't find a suitable struct to extend for this purpose. 

Anders Berggren
Halon Security


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

David Miller Feb. 22, 2011, 5:36 p.m. UTC | #1
From: Anders Berggren <anders@halon.se>
Date: Tue, 15 Feb 2011 14:56:21 +0100

> This patch enables UDP IPv6 TX timestamping (using SO_TIMESTAMPING,
> enabled by CONFIG_NETWORK_PHY_TIMESTAMPING) as Marcus D. Leech
> suggested in
> http://kerneltrap.org/mailarchive/linux-netdev/2009/11/10/6260604
> and
> http://kerneltrap.org/mailarchive/linux-netdev/2009/11/11/6260643
> 
> It's mostly copied from net/ipv4/udp.c. I guess it would be better
> to run sock_tx_timestamp in ipv6/udp.c and pass it to
> ipv6/ip6_output.c's ip6_append_data somehow, but I didn't find a
> suitable struct to extend for this purpose.

Please submit your change properly, as per Documentation/SubmittingPatches,
in particular you need to provide a proper Signed-off-by: tag for your
change.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Anders Berggren Feb. 22, 2011, 9:50 p.m. UTC | #2
> Please submit your change properly, as per Documentation/SubmittingPatches,
> in particular you need to provide a proper Signed-off-by: tag for your
> change.

Thank you. I made a second try:

http://marc.info/?l=linux-netdev&m=129841103607145&w=2
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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