aboutsummaryrefslogtreecommitdiffstats
path: root/net/core
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2015-01-30 13:29:31 -0500
committerDavid S. Miller <davem@davemloft.net>2015-02-02 21:46:51 -0500
commit49ca0d8bfaf3bc46d5eef60ce67b00eb195bd392 (patch)
treed2f55a32923f6d91fcb2e0d0e0b6d2d4eb6f9abd /net/core
parent9766e97af1b901ffbb36fcc648e50626d926bb24 (diff)
net-timestamp: no-payload option
Add timestamping option SOF_TIMESTAMPING_OPT_TSONLY. For transmit timestamps, this loops timestamps on top of empty packets. Doing so reduces the pressure on SO_RCVBUF. Payload inspection and cmsg reception (aside from timestamps) are no longer possible. This works together with a follow on patch that allows administrators to only allow tx timestamping if it does not loop payload or metadata. Signed-off-by: Willem de Bruijn <willemb@google.com> ---- Changes (rfc -> v1) - add documentation - remove unnecessary skb->len test (thanks to Richard Cochran) Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/skbuff.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 56db472e9b86..65a3798f43e6 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3710,19 +3710,28 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
3710 struct sock *sk, int tstype) 3710 struct sock *sk, int tstype)
3711{ 3711{
3712 struct sk_buff *skb; 3712 struct sk_buff *skb;
3713 bool tsonly = sk->sk_tsflags & SOF_TIMESTAMPING_OPT_TSONLY;
3713 3714
3714 if (!sk) 3715 if (!sk)
3715 return; 3716 return;
3716 3717
3717 if (hwtstamps) 3718 if (tsonly)
3718 *skb_hwtstamps(orig_skb) = *hwtstamps; 3719 skb = alloc_skb(0, GFP_ATOMIC);
3719 else 3720 else
3720 orig_skb->tstamp = ktime_get_real(); 3721 skb = skb_clone(orig_skb, GFP_ATOMIC);
3721
3722 skb = skb_clone(orig_skb, GFP_ATOMIC);
3723 if (!skb) 3722 if (!skb)
3724 return; 3723 return;
3725 3724
3725 if (tsonly) {
3726 skb_shinfo(skb)->tx_flags = skb_shinfo(orig_skb)->tx_flags;
3727 skb_shinfo(skb)->tskey = skb_shinfo(orig_skb)->tskey;
3728 }
3729
3730 if (hwtstamps)
3731 *skb_hwtstamps(skb) = *hwtstamps;
3732 else
3733 skb->tstamp = ktime_get_real();
3734
3726 __skb_complete_tx_timestamp(skb, sk, tstype); 3735 __skb_complete_tx_timestamp(skb, sk, tstype);
3727} 3736}
3728EXPORT_SYMBOL_GPL(__skb_tstamp_tx); 3737EXPORT_SYMBOL_GPL(__skb_tstamp_tx);