History

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.

Richard Cochran committed 13 years ago

Commit eda29771 parent cb820f82 files · +15 −2Browse files

Unified · Split

2 files
  1. drivers/net/tun.c +12 −2
  2. include/uapi/linux/if_tun.h +3 −0
drivers/net/tun.c+12−2
@@ -739,6 +739,11 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev) · 738 unmodified lines
739739 >= dev->tx_queue_len / tun->numqueues)
740740 goto drop;
741741
742+ if (skb->sk) {
743+ sock_tx_timestamp(skb->sk, &skb_shinfo(skb)->tx_flags);
744+ sw_tx_timestamp(skb);
745+ }
746+
742747 /* Orphan the skb - required as we might hang on to it
743748 * for indefinite time. */
744749 if (unlikely(skb_orphan_frags(skb, GFP_ATOMIC)))
@@ -1476,7 +1481,6 @@ static int tun_sendmsg(struct kiocb *iocb, struct socket *sock, · 731 unmodified lines
14761481 return ret;
14771482 }
14781483
1479−
14801484 static int tun_recvmsg(struct kiocb *iocb, struct socket *sock,
14811485 struct msghdr *m, size_t total_len,
14821486 int flags)
@@ -1488,10 +1492,15 @@ static int tun_recvmsg(struct kiocb *iocb, struct socket *sock, · 5 unmodified lines
14881492 if (!tun)
14891493 return -EBADFD;
14901494
1491− if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) {
1495+ if (flags & ~(MSG_DONTWAIT|MSG_TRUNC|MSG_ERRQUEUE)) {
14921496 ret = -EINVAL;
14931497 goto out;
14941498 }
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+ }
14951504 ret = tun_do_read(tun, tfile, iocb, m->msg_iov, total_len,
14961505 flags & MSG_DONTWAIT);
14971506 if (ret > total_len) {
@@ -2274,6 +2283,7 @@ static const struct ethtool_ops tun_ethtool_ops = { · 776 unmodified lines
22742283 .get_msglevel = tun_get_msglevel,
22752284 .set_msglevel = tun_set_msglevel,
22762285 .get_link = ethtool_op_get_link,
2286+ .get_ts_info = ethtool_op_get_ts_info,
22772287 };
22782288
22792289
include/uapi/linux/if_tun.h+3−0
@@ -71,6 +71,9 @@ · 70 unmodified lines
7171 /* read-only flag */
7272 #define IFF_PERSIST 0x0800
7373
74+/* Socket options */
75+#define TUN_TX_TIMESTAMP 1
76+
7477 /* Features for GSO (TUNSETOFFLOAD). */
7578 #define TUN_F_CSUM 0x01 /* You can hand me unchecksummed packets. */
7679 #define TUN_F_TSO4 0x02 /* I can handle TSO for IPv4 packets */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t