diff options
author | Soheil Hassas Yeganeh <soheil@google.com> | 2016-04-02 23:08:12 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-04-04 15:50:30 -0400 |
commit | c14ac9451c34832554db33386a4393be8bba3a7b (patch) | |
tree | 99f4d7c46d01732fcbfdf8de89e1d9846d56c3b3 /include/net | |
parent | ad1e46a837163a3e7160a1250825bcfafd2e714b (diff) |
sock: enable timestamping using control messages
Currently, SOL_TIMESTAMPING can only be enabled using setsockopt.
This is very costly when users want to sample writes to gather
tx timestamps.
Add support for enabling SO_TIMESTAMPING via control messages by
using tsflags added in `struct sockcm_cookie` (added in the previous
patches in this series) to set the tx_flags of the last skb created in
a sendmsg. With this patch, the timestamp recording bits in tx_flags
of the skbuff is overridden if SO_TIMESTAMPING is passed in a cmsg.
Please note that this is only effective for overriding the recording
timestamps flags. Users should enable timestamp reporting (e.g.,
SOF_TIMESTAMPING_SOFTWARE | SOF_TIMESTAMPING_OPT_ID) using
socket options and then should ask for SOF_TIMESTAMPING_TX_*
using control messages per sendmsg to sample timestamps for each
write.
Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r-- | include/net/ipv6.h | 6 | ||||
-rw-r--r-- | include/net/sock.h | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index d0aeb97aec5d..55ee1eb7d026 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -867,7 +867,8 @@ int ip6_append_data(struct sock *sk, | |||
867 | int odd, struct sk_buff *skb), | 867 | int odd, struct sk_buff *skb), |
868 | void *from, int length, int transhdrlen, int hlimit, | 868 | void *from, int length, int transhdrlen, int hlimit, |
869 | int tclass, struct ipv6_txoptions *opt, struct flowi6 *fl6, | 869 | int tclass, struct ipv6_txoptions *opt, struct flowi6 *fl6, |
870 | struct rt6_info *rt, unsigned int flags, int dontfrag); | 870 | struct rt6_info *rt, unsigned int flags, int dontfrag, |
871 | const struct sockcm_cookie *sockc); | ||
871 | 872 | ||
872 | int ip6_push_pending_frames(struct sock *sk); | 873 | int ip6_push_pending_frames(struct sock *sk); |
873 | 874 | ||
@@ -884,7 +885,8 @@ struct sk_buff *ip6_make_skb(struct sock *sk, | |||
884 | void *from, int length, int transhdrlen, | 885 | void *from, int length, int transhdrlen, |
885 | int hlimit, int tclass, struct ipv6_txoptions *opt, | 886 | int hlimit, int tclass, struct ipv6_txoptions *opt, |
886 | struct flowi6 *fl6, struct rt6_info *rt, | 887 | struct flowi6 *fl6, struct rt6_info *rt, |
887 | unsigned int flags, int dontfrag); | 888 | unsigned int flags, int dontfrag, |
889 | const struct sockcm_cookie *sockc); | ||
888 | 890 | ||
889 | static inline struct sk_buff *ip6_finish_skb(struct sock *sk) | 891 | static inline struct sk_buff *ip6_finish_skb(struct sock *sk) |
890 | { | 892 | { |
diff --git a/include/net/sock.h b/include/net/sock.h index af012da5e608..e91b87f54f99 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -2057,19 +2057,21 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, | |||
2057 | sk->sk_stamp = skb->tstamp; | 2057 | sk->sk_stamp = skb->tstamp; |
2058 | } | 2058 | } |
2059 | 2059 | ||
2060 | void __sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags); | 2060 | void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags); |
2061 | 2061 | ||
2062 | /** | 2062 | /** |
2063 | * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped | 2063 | * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped |
2064 | * @sk: socket sending this packet | 2064 | * @sk: socket sending this packet |
2065 | * @tsflags: timestamping flags to use | ||
2065 | * @tx_flags: completed with instructions for time stamping | 2066 | * @tx_flags: completed with instructions for time stamping |
2066 | * | 2067 | * |
2067 | * Note : callers should take care of initial *tx_flags value (usually 0) | 2068 | * Note : callers should take care of initial *tx_flags value (usually 0) |
2068 | */ | 2069 | */ |
2069 | static inline void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags) | 2070 | static inline void sock_tx_timestamp(const struct sock *sk, __u16 tsflags, |
2071 | __u8 *tx_flags) | ||
2070 | { | 2072 | { |
2071 | if (unlikely(sk->sk_tsflags)) | 2073 | if (unlikely(tsflags)) |
2072 | __sock_tx_timestamp(sk, tx_flags); | 2074 | __sock_tx_timestamp(tsflags, tx_flags); |
2073 | if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS))) | 2075 | if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS))) |
2074 | *tx_flags |= SKBTX_WIFI_STATUS; | 2076 | *tx_flags |= SKBTX_WIFI_STATUS; |
2075 | } | 2077 | } |