On Wed, Jun 27, 2018 at 6:07 PM Jesus Sanchez-Palencia <jesus.sanchez-palen...@intel.com> wrote: > > Add a transmit_time field to struct inet_cork, then copy the > timestamp from the CMSG cookie at ip_setup_cork() so we can > safely copy it into the skb later during __ip_make_skb(). > > For the raw fast path, just perform the copy at raw_send_hdrinc(). > > Signed-off-by: Richard Cochran <rcoch...@linutronix.de> > Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palen...@intel.com> > --- > include/net/inet_sock.h | 1 + > net/ipv4/ip_output.c | 3 +++ > net/ipv4/raw.c | 2 ++ > net/ipv4/udp.c | 1 +
Also support the feature for ipv6 > 4 files changed, 7 insertions(+) > > diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h > index 83d5b3c2ac42..314be484c696 100644 > --- a/include/net/inet_sock.h > +++ b/include/net/inet_sock.h > @@ -148,6 +148,7 @@ struct inet_cork { > __s16 tos; > char priority; > __u16 gso_size; > + u64 transmit_time; > }; > > struct inet_cork_full { > diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c > index b3308e9d9762..904a54a090e9 100644 > --- a/net/ipv4/ip_output.c > +++ b/net/ipv4/ip_output.c > @@ -1153,6 +1153,7 @@ static int ip_setup_cork(struct sock *sk, struct > inet_cork *cork, > cork->tos = ipc->tos; > cork->priority = ipc->priority; > cork->tx_flags = ipc->tx_flags; > + cork->transmit_time = ipc->sockc.transmit_time; Initialize ipc->sockc.transmit_time in all possible paths to avoid bugs like the one fixed in commit 9887cba19978 ("ip: limit use of gso_size to udp"). > return 0; > } > @@ -1413,6 +1414,7 @@ struct sk_buff *__ip_make_skb(struct sock *sk, > > skb->priority = (cork->tos != -1) ? cork->priority: sk->sk_priority; > skb->mark = sk->sk_mark; > + skb->tstamp = cork->transmit_time; > /* > * Steal rt from cork.dst to avoid a pair of atomic_inc/atomic_dec > * on dst refcount > @@ -1495,6 +1497,7 @@ struct sk_buff *ip_make_skb(struct sock *sk, > cork->flags = 0; > cork->addr = 0; > cork->opt = NULL; > + cork->transmit_time = 0; Not needed when unconditionally overwriting the field in ip_setup_cork. > err = ip_setup_cork(sk, cork, ipc, rtp); > if (err) > return ERR_PTR(err);