aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2018-12-17 12:24:00 -0500
committerDavid S. Miller <davem@davemloft.net>2018-12-18 02:27:00 -0500
commit8f932f762e7928d250e21006b00ff9b7718b0a64 (patch)
treee40f35dc20a9d45d774b78b9d42e2f4b0e8b2a64
parentfbfb2321e950918b430e7225546296b2dcadf725 (diff)
net: add missing SOF_TIMESTAMPING_OPT_ID support
SOF_TIMESTAMPING_OPT_ID is supported on TCP, UDP and RAW sockets. But it was missing on RAW with IPPROTO_IP, PF_PACKET and CAN. Add skb_setup_tx_timestamp that configures both tx_flags and tskey for these paths that do not need corking or use bytestream keys. Fixes: 09c2d251b707 ("net-timestamp: add key to disambiguate concurrent datagrams") Signed-off-by: Willem de Bruijn <willemb@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sock.h25
-rw-r--r--net/can/raw.c2
-rw-r--r--net/ipv4/raw.c2
-rw-r--r--net/ipv6/raw.c2
-rw-r--r--net/packet/af_packet.c6
5 files changed, 27 insertions, 10 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index f665d74ae509..0e3a09380655 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2340,22 +2340,39 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
2340void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags); 2340void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags);
2341 2341
2342/** 2342/**
2343 * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped 2343 * _sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
2344 * @sk: socket sending this packet 2344 * @sk: socket sending this packet
2345 * @tsflags: timestamping flags to use 2345 * @tsflags: timestamping flags to use
2346 * @tx_flags: completed with instructions for time stamping 2346 * @tx_flags: completed with instructions for time stamping
2347 * @tskey: filled in with next sk_tskey (not for TCP, which uses seqno)
2347 * 2348 *
2348 * Note: callers should take care of initial ``*tx_flags`` value (usually 0) 2349 * Note: callers should take care of initial ``*tx_flags`` value (usually 0)
2349 */ 2350 */
2350static inline void sock_tx_timestamp(const struct sock *sk, __u16 tsflags, 2351static inline void _sock_tx_timestamp(struct sock *sk, __u16 tsflags,
2351 __u8 *tx_flags) 2352 __u8 *tx_flags, __u32 *tskey)
2352{ 2353{
2353 if (unlikely(tsflags)) 2354 if (unlikely(tsflags)) {
2354 __sock_tx_timestamp(tsflags, tx_flags); 2355 __sock_tx_timestamp(tsflags, tx_flags);
2356 if (tsflags & SOF_TIMESTAMPING_OPT_ID && tskey &&
2357 tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK)
2358 *tskey = sk->sk_tskey++;
2359 }
2355 if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS))) 2360 if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS)))
2356 *tx_flags |= SKBTX_WIFI_STATUS; 2361 *tx_flags |= SKBTX_WIFI_STATUS;
2357} 2362}
2358 2363
2364static inline void sock_tx_timestamp(struct sock *sk, __u16 tsflags,
2365 __u8 *tx_flags)
2366{
2367 _sock_tx_timestamp(sk, tsflags, tx_flags, NULL);
2368}
2369
2370static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags)
2371{
2372 _sock_tx_timestamp(skb->sk, tsflags, &skb_shinfo(skb)->tx_flags,
2373 &skb_shinfo(skb)->tskey);
2374}
2375
2359/** 2376/**
2360 * sk_eat_skb - Release a skb if it is no longer needed 2377 * sk_eat_skb - Release a skb if it is no longer needed
2361 * @sk: socket to eat this skb from 2378 * @sk: socket to eat this skb from
diff --git a/net/can/raw.c b/net/can/raw.c
index 3aab7664933f..c70207537488 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -771,7 +771,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
771 if (err < 0) 771 if (err < 0)
772 goto free_skb; 772 goto free_skb;
773 773
774 sock_tx_timestamp(sk, sk->sk_tsflags, &skb_shinfo(skb)->tx_flags); 774 skb_setup_tx_timestamp(skb, sk->sk_tsflags);
775 775
776 skb->dev = dev; 776 skb->dev = dev;
777 skb->sk = sk; 777 skb->sk = sk;
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 8ca3eb06ba04..169a652b3dd1 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -391,7 +391,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
391 391
392 skb->ip_summed = CHECKSUM_NONE; 392 skb->ip_summed = CHECKSUM_NONE;
393 393
394 sock_tx_timestamp(sk, sockc->tsflags, &skb_shinfo(skb)->tx_flags); 394 skb_setup_tx_timestamp(skb, sockc->tsflags);
395 395
396 if (flags & MSG_CONFIRM) 396 if (flags & MSG_CONFIRM)
397 skb_set_dst_pending_confirm(skb, 1); 397 skb_set_dst_pending_confirm(skb, 1);
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
index c8562432fcc3..fc2b5e845fdf 100644
--- a/net/ipv6/raw.c
+++ b/net/ipv6/raw.c
@@ -658,7 +658,7 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
658 658
659 skb->ip_summed = CHECKSUM_NONE; 659 skb->ip_summed = CHECKSUM_NONE;
660 660
661 sock_tx_timestamp(sk, sockc->tsflags, &skb_shinfo(skb)->tx_flags); 661 skb_setup_tx_timestamp(skb, sockc->tsflags);
662 662
663 if (flags & MSG_CONFIRM) 663 if (flags & MSG_CONFIRM)
664 skb_set_dst_pending_confirm(skb, 1); 664 skb_set_dst_pending_confirm(skb, 1);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index a74650e98f42..6655793765b2 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1965,7 +1965,7 @@ retry:
1965 skb->mark = sk->sk_mark; 1965 skb->mark = sk->sk_mark;
1966 skb->tstamp = sockc.transmit_time; 1966 skb->tstamp = sockc.transmit_time;
1967 1967
1968 sock_tx_timestamp(sk, sockc.tsflags, &skb_shinfo(skb)->tx_flags); 1968 skb_setup_tx_timestamp(skb, sockc.tsflags);
1969 1969
1970 if (unlikely(extra_len == 4)) 1970 if (unlikely(extra_len == 4))
1971 skb->no_fcs = 1; 1971 skb->no_fcs = 1;
@@ -2460,7 +2460,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
2460 skb->priority = po->sk.sk_priority; 2460 skb->priority = po->sk.sk_priority;
2461 skb->mark = po->sk.sk_mark; 2461 skb->mark = po->sk.sk_mark;
2462 skb->tstamp = sockc->transmit_time; 2462 skb->tstamp = sockc->transmit_time;
2463 sock_tx_timestamp(&po->sk, sockc->tsflags, &skb_shinfo(skb)->tx_flags); 2463 skb_setup_tx_timestamp(skb, sockc->tsflags);
2464 skb_zcopy_set_nouarg(skb, ph.raw); 2464 skb_zcopy_set_nouarg(skb, ph.raw);
2465 2465
2466 skb_reserve(skb, hlen); 2466 skb_reserve(skb, hlen);
@@ -2898,7 +2898,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
2898 goto out_free; 2898 goto out_free;
2899 } 2899 }
2900 2900
2901 sock_tx_timestamp(sk, sockc.tsflags, &skb_shinfo(skb)->tx_flags); 2901 skb_setup_tx_timestamp(skb, sockc.tsflags);
2902 2902
2903 if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) && 2903 if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) &&
2904 !packet_extra_vlan_len_allowed(dev, skb)) { 2904 !packet_extra_vlan_len_allowed(dev, skb)) {