Merge branch 'net-SO_TIMESTAMPING-fixes'

Willem de Bruijn says:

====================
net: SO_TIMESTAMPING fixes

Fix two omissions:

- tx timestamping is missing for AF_INET6/SOCK_RAW/IPPROTO_RAW
- SOF_TIMESTAMPING_OPT_ID is missing for IPPROTO_RAW, PF_PACKET, CAN

Discovered while expanding the selftest in

  tools/testing/selftests/networking/timestamping/txtimestamp.c

Will send the test patchset to net-next once the fixes make it to that
branch. For now, it is available at

  https://github.com/wdebruij/linux/commits/txtimestamp-test-1
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
David S. Miller 2018-12-17 23:27:01 -08:00
Родитель 255fe81a6a 8f932f762e
Коммит b33299017c
5 изменённых файлов: 28 добавлений и 9 удалений

Просмотреть файл

@ -2340,22 +2340,39 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags); void __sock_tx_timestamp(__u16 tsflags, __u8 *tx_flags);
/** /**
* sock_tx_timestamp - checks whether the outgoing packet is to be time stamped * _sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
* @sk: socket sending this packet * @sk: socket sending this packet
* @tsflags: timestamping flags to use * @tsflags: timestamping flags to use
* @tx_flags: completed with instructions for time stamping * @tx_flags: completed with instructions for time stamping
* @tskey: filled in with next sk_tskey (not for TCP, which uses seqno)
* *
* Note: callers should take care of initial ``*tx_flags`` value (usually 0) * Note: callers should take care of initial ``*tx_flags`` value (usually 0)
*/ */
static inline void sock_tx_timestamp(const struct sock *sk, __u16 tsflags, static inline void _sock_tx_timestamp(struct sock *sk, __u16 tsflags,
__u8 *tx_flags) __u8 *tx_flags, __u32 *tskey)
{ {
if (unlikely(tsflags)) if (unlikely(tsflags)) {
__sock_tx_timestamp(tsflags, tx_flags); __sock_tx_timestamp(tsflags, tx_flags);
if (tsflags & SOF_TIMESTAMPING_OPT_ID && tskey &&
tsflags & SOF_TIMESTAMPING_TX_RECORD_MASK)
*tskey = sk->sk_tskey++;
}
if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS))) if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS)))
*tx_flags |= SKBTX_WIFI_STATUS; *tx_flags |= SKBTX_WIFI_STATUS;
} }
static inline void sock_tx_timestamp(struct sock *sk, __u16 tsflags,
__u8 *tx_flags)
{
_sock_tx_timestamp(sk, tsflags, tx_flags, NULL);
}
static inline void skb_setup_tx_timestamp(struct sk_buff *skb, __u16 tsflags)
{
_sock_tx_timestamp(skb->sk, tsflags, &skb_shinfo(skb)->tx_flags,
&skb_shinfo(skb)->tskey);
}
/** /**
* sk_eat_skb - Release a skb if it is no longer needed * sk_eat_skb - Release a skb if it is no longer needed
* @sk: socket to eat this skb from * @sk: socket to eat this skb from

Просмотреть файл

@ -771,7 +771,7 @@ static int raw_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
if (err < 0) if (err < 0)
goto free_skb; goto free_skb;
sock_tx_timestamp(sk, sk->sk_tsflags, &skb_shinfo(skb)->tx_flags); skb_setup_tx_timestamp(skb, sk->sk_tsflags);
skb->dev = dev; skb->dev = dev;
skb->sk = sk; skb->sk = sk;

Просмотреть файл

@ -391,7 +391,7 @@ static int raw_send_hdrinc(struct sock *sk, struct flowi4 *fl4,
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
sock_tx_timestamp(sk, sockc->tsflags, &skb_shinfo(skb)->tx_flags); skb_setup_tx_timestamp(skb, sockc->tsflags);
if (flags & MSG_CONFIRM) if (flags & MSG_CONFIRM)
skb_set_dst_pending_confirm(skb, 1); skb_set_dst_pending_confirm(skb, 1);

Просмотреть файл

@ -658,6 +658,8 @@ static int rawv6_send_hdrinc(struct sock *sk, struct msghdr *msg, int length,
skb->ip_summed = CHECKSUM_NONE; skb->ip_summed = CHECKSUM_NONE;
skb_setup_tx_timestamp(skb, sockc->tsflags);
if (flags & MSG_CONFIRM) if (flags & MSG_CONFIRM)
skb_set_dst_pending_confirm(skb, 1); skb_set_dst_pending_confirm(skb, 1);

Просмотреть файл

@ -1965,7 +1965,7 @@ retry:
skb->mark = sk->sk_mark; skb->mark = sk->sk_mark;
skb->tstamp = sockc.transmit_time; skb->tstamp = sockc.transmit_time;
sock_tx_timestamp(sk, sockc.tsflags, &skb_shinfo(skb)->tx_flags); skb_setup_tx_timestamp(skb, sockc.tsflags);
if (unlikely(extra_len == 4)) if (unlikely(extra_len == 4))
skb->no_fcs = 1; skb->no_fcs = 1;
@ -2460,7 +2460,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb,
skb->priority = po->sk.sk_priority; skb->priority = po->sk.sk_priority;
skb->mark = po->sk.sk_mark; skb->mark = po->sk.sk_mark;
skb->tstamp = sockc->transmit_time; skb->tstamp = sockc->transmit_time;
sock_tx_timestamp(&po->sk, sockc->tsflags, &skb_shinfo(skb)->tx_flags); skb_setup_tx_timestamp(skb, sockc->tsflags);
skb_zcopy_set_nouarg(skb, ph.raw); skb_zcopy_set_nouarg(skb, ph.raw);
skb_reserve(skb, hlen); skb_reserve(skb, hlen);
@ -2898,7 +2898,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
goto out_free; goto out_free;
} }
sock_tx_timestamp(sk, sockc.tsflags, &skb_shinfo(skb)->tx_flags); skb_setup_tx_timestamp(skb, sockc.tsflags);
if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) && if (!vnet_hdr.gso_type && (len > dev->mtu + reserve + extra_len) &&
!packet_extra_vlan_len_allowed(dev, skb)) { !packet_extra_vlan_len_allowed(dev, skb)) {