From: Miroslav Lichvar <mlichvar@redhat.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Network Development <netdev@vger.kernel.org>,
Richard Cochran <richardcochran@gmail.com>,
Willem de Bruijn <willemb@google.com>,
Soheil Hassas Yeganeh <soheil@google.com>,
"Keller, Jacob E" <jacob.e.keller@intel.com>,
Denny Page <dennypage@me.com>, Jiri Benc <jbenc@redhat.com>
Subject: Re: [PATCH v1 net-next 3/6] net: add new control message for incoming HW-timestamped packets
Date: Thu, 27 Apr 2017 12:15:54 +0200 [thread overview]
Message-ID: <20170427101554.GF5654@localhost> (raw)
In-Reply-To: <CAF=yD-+XKGnGASVN4+W2u2A7CBqS9CRN2Jkvx6UoPQQ6jLpMkQ@mail.gmail.com>
Thanks for the comments.
On Wed, Apr 26, 2017 at 07:34:49PM -0400, Willem de Bruijn wrote:
> > +struct net_device *dev_get_by_napi_id(unsigned int napi_id)
> > +{
> > + struct net_device *dev = NULL;
> > + struct napi_struct *napi;
> > +
> > + rcu_read_lock();
> > +
> > + napi = napi_by_id(napi_id);
> > + if (napi)
> > + dev = napi->dev;
> > +
> > + rcu_read_unlock();
> > +
> > + return dev;
> > +}
> > +EXPORT_SYMBOL(dev_get_by_napi_id);
>
> Returning dev without holding a reference is not safe. You'll probably
> have to call this with rcu_read_lock held instead.
How about changing the function to simply return the index instead of
the device (e.g. dev_get_ifindex_by_napi_id())? Would that be too
specific?
> > /*
> > * called from sock_recv_timestamp() if sock_flag(sk, SOCK_RCVTSTAMP)
> > */
> > @@ -699,8 +719,12 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
> > empty = 0;
> > if (shhwtstamps &&
> > (sk->sk_tsflags & SOF_TIMESTAMPING_RAW_HARDWARE) &&
>
> This information is also informative with software timestamps.
But is it useful and worth the cost? If I have two interfaces and only
one has HW timestamping, or just one interface which can timestamp
incoming packets at a limited rate, I would prefer to not waste CPU
cycles preparing and processing useless data.
> And getting the real iif is definitely useful outside timestamps.
Do you have an example? We have asked that in the original thread,
but no one suggested anything. For AF_PACKET there is PACKET_ORIGDEV.
When I was searching the Internet on how to get the index with INET
sockets, it looked like I was the only one who had this problem :).
> An
> alternative approach is to add versioning to IP_PKTINFO with a new
> setsockopt IP_PKTINFO_VERSION plus a new struct in_pktinfo_v2
> that extends in_pktinfo. Just a thought.
The struct would contain both the original and last interface index,
and the length as well? And similarly with in6_pktinfo?
If there is an agreement that the information would useful also for
other things than timestamping, I can try that. If not, I think it
would be better to keep it tied to HW timestamping.
--
Miroslav Lichvar
next prev parent reply other threads:[~2017-04-27 10:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-26 14:50 [PATCH v1 net-next 0/6] Extend socket timestamping API Miroslav Lichvar
2017-04-26 14:50 ` [PATCH v1 net-next 1/6] net: define receive timestamp filter for NTP Miroslav Lichvar
2017-04-26 14:50 ` [PATCH v1 net-next 2/6] net: ethernet: update drivers to handle HWTSTAMP_FILTER_NTP_ALL Miroslav Lichvar
2017-04-26 14:50 ` [PATCH v1 net-next 3/6] net: add new control message for incoming HW-timestamped packets Miroslav Lichvar
2017-04-26 23:34 ` Willem de Bruijn
2017-04-27 10:15 ` Miroslav Lichvar [this message]
2017-04-27 11:38 ` Willem de Bruijn
2017-04-27 4:09 ` kbuild test robot
2017-04-26 14:50 ` [PATCH v1 net-next 4/6] net: don't make false software transmit timestamps Miroslav Lichvar
2017-04-26 14:50 ` [PATCH v1 net-next 5/6] net: allow simultaneous SW and HW transmit timestamping Miroslav Lichvar
2017-04-27 0:00 ` Willem de Bruijn
2017-04-27 16:17 ` Miroslav Lichvar
2017-04-27 16:21 ` Willem de Bruijn
2017-04-27 16:39 ` Miroslav Lichvar
2017-04-27 16:48 ` Willem de Bruijn
2017-04-28 8:54 ` Miroslav Lichvar
2017-04-28 15:50 ` Willem de Bruijn
2017-04-28 16:23 ` Miroslav Lichvar
2017-04-28 20:07 ` Willem de Bruijn
2017-05-02 9:56 ` Miroslav Lichvar
2017-04-26 14:50 ` [PATCH v1 net-next 6/6] net: ethernet: update drivers to make both SW and HW TX timestamps Miroslav Lichvar
2017-04-26 16:54 ` [PATCH v1 net-next 0/6] Extend socket timestamping API Richard Cochran
2017-04-27 9:28 ` Miroslav Lichvar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170427101554.GF5654@localhost \
--to=mlichvar@redhat.com \
--cc=dennypage@me.com \
--cc=jacob.e.keller@intel.com \
--cc=jbenc@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@gmail.com \
--cc=soheil@google.com \
--cc=willemb@google.com \
--cc=willemdebruijn.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).