aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2013-07-19 13:40:10 -0400
committerDavid S. Miller <davem@davemloft.net>2013-07-22 17:58:19 -0400
commiteda297729171fe16bf34fe5b0419dfb69060f623 (patch)
treec87ac0a1a125bb99bdffdcc4e33c84a2a8d75b2e
parentcb820f8e4b7f73d1a32175e6591735b25bb5398d (diff)
tun: Support software transmit time stamping.
This patch adds transmit time stamping to the tun/tap driver. Similar support already exists for UDP, can, and raw packets. Signed-off-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tun.c14
-rw-r--r--include/uapi/linux/if_tun.h3
2 files changed, 15 insertions, 2 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index db690a372260..a72d141047cb 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -739,6 +739,11 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)
739 >= dev->tx_queue_len / tun->numqueues) 739 >= dev->tx_queue_len / tun->numqueues)
740 goto drop; 740 goto drop;
741 741
742 if (skb->sk) {
743 sock_tx_timestamp(skb->sk, &skb_shinfo(skb)->tx_flags);
744 sw_tx_timestamp(skb);
745 }
746
742 /* Orphan the skb - required as we might hang on to it 747 /* Orphan the skb - required as we might hang on to it
743 * for indefinite time. */ 748 * for indefinite time. */
744 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC))) 749 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
@@ -1476,7 +1481,6 @@ static int tun_sendmsg(struct kiocb *iocb, struct socket *sock,
1476 return ret; 1481 return ret;
1477} 1482}
1478 1483
1479
1480static int tun_recvmsg(struct kiocb *iocb, struct socket *sock, 1484static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
1481 struct msghdr *m, size_t total_len, 1485 struct msghdr *m, size_t total_len,
1482 int flags) 1486 int flags)
@@ -1488,10 +1492,15 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
1488 if (!tun) 1492 if (!tun)
1489 return -EBADFD; 1493 return -EBADFD;
1490 1494
1491 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) { 1495 if (flags & ~(MSG_DONTWAIT|MSG_TRUNC|MSG_ERRQUEUE)) {
1492 ret = -EINVAL; 1496 ret = -EINVAL;
1493 goto out; 1497 goto out;
1494 } 1498 }
1499 if (flags & MSG_ERRQUEUE) {
1500 ret = sock_recv_errqueue(sock->sk, m, total_len,
1501 SOL_PACKET, TUN_TX_TIMESTAMP);
1502 goto out;
1503 }
1495 ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len, 1504 ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len,
1496 flags & MSG_DONTWAIT); 1505 flags & MSG_DONTWAIT);
1497 if (ret > total_len) { 1506 if (ret > total_len) {
@@ -2274,6 +2283,7 @@ static const struct ethtool_ops tun_ethtool_ops = {
2274 .get_msglevel = tun_get_msglevel, 2283 .get_msglevel = tun_get_msglevel,
2275 .set_msglevel = tun_set_msglevel, 2284 .set_msglevel = tun_set_msglevel,
2276 .get_link = ethtool_op_get_link, 2285 .get_link = ethtool_op_get_link,
2286 .get_ts_info = ethtool_op_get_ts_info,
2277}; 2287};
2278 2288
2279 2289
diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
index 82334f88967e..1870ee29bb37 100644
--- a/include/uapi/linux/if_tun.h
+++ b/include/uapi/linux/if_tun.h
@@ -71,6 +71,9 @@
71/* read-only flag */ 71/* read-only flag */
72#define IFF_PERSIST 0x0800 72#define IFF_PERSIST 0x0800
73 73
74/* Socket options */
75#define TUN_TX_TIMESTAMP 1
76
74/* Features for GSO (TUNSETOFFLOAD). */ 77/* Features for GSO (TUNSETOFFLOAD). */
75#define TUN_F_CSUM 0x01 /* You can hand me unchecksummed packets. */ 78#define TUN_F_CSUM 0x01 /* You can hand me unchecksummed packets. */
76#define TUN_F_TSO4 0x02 /* I can handle TSO for IPv4 packets */ 79#define TUN_F_TSO4 0x02 /* I can handle TSO for IPv4 packets */