On Thu, Apr 13, 2017 at 11:18 AM, Miroslav Lichvar <mlich...@redhat.com> wrote: > On Thu, Apr 13, 2017 at 10:37:07AM -0400, Willem de Bruijn wrote: >> On Wed, Apr 12, 2017 at 10:17 AM, Miroslav Lichvar <mlich...@redhat.com> >> wrote: >> > Extend the skb_shared_hwtstamps structure with the index of the >> > real interface which received or transmitted the packet and the length >> > of the packet at layer 2. >> >> The original packet is received along with the timestamp. > > But only outgoing packets, right?
Timestamps for incoming packets are also passed alongside the original packet. >> Why is this L2 length needed? > > It's needed for incoming packets to allow converting of preamble > timestamps to trailer timestamps. Receiving the mac length of a packet sounds like a feature independent from timestamping. Either an ioctl similar to SIOCGIFMTU or, if it may vary due to existince of vlan headers, a new independent cmsg at the SOL_SOCKET layer. >> > Add a SOF_TIMESTAMPING_OPT_PKTINFO flag to >> > the SO_TIMESTAMPING option to allow applications to get this information >> > as struct scm_ts_pktinfo in SCM_TIMESTAMPING_PKTINFO control message. >> >> This patch saves skb->dev->ifindex, which is the same as existing >> SOF_TIMESTAMPING_OPT_CMSG. See also the bug fix for that >> feature I sent yesterday: http://patchwork.ozlabs.org/patch/750197/ > > The main point is that it provides the index of the device which > received the packet. It does duplicate the functionality of OPT_CMSG + > IP_PKTINFO for outgoing packets, but I thought it might be useful with > the TSONLY option. Agreed. I'd prefer to reuse the existing option for that and just extend it to work together with TSONLY. We will have to set serr->header.h4.iif from something other than skb->dev if the skb was allocated fresh in __skb_tstamp_tx without the device association.