Netdev List
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Gerard Garcia <ggarcia@abra.uab.cat>
Cc: netdev@vger.kernel.org, jhansen@vmware.com
Subject: Re: [RFC 1/3] vsockmon: Add tap functions.
Date: Fri, 10 Jun 2016 16:44:45 +0100	[thread overview]
Message-ID: <20160610154445.GE3855@stefanha-x1.localdomain> (raw)
In-Reply-To: <969687fe-f812-7412-bd06-89b159daa88a@deic.uab.cat>

[-- Attachment #1: Type: text/plain, Size: 2390 bytes --]

On Thu, Jun 09, 2016 at 05:02:47PM +0200, Gerard Garcia wrote:
> On 06/01/2016 11:07 PM, Stefan Hajnoczi wrote:
> > On Sat, May 28, 2016 at 06:29:05PM +0200, ggarcia@abra.uab.cat wrote:
> > > diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
> > > index 6b158ab..ec7a05d 100644
> > > --- a/net/vmw_vsock/af_vsock.c
> > > +++ b/net/vmw_vsock/af_vsock.c
> > > @@ -96,6 +96,7 @@
> > >   #include <linux/unistd.h>
> > >   #include <linux/wait.h>
> > >   #include <linux/workqueue.h>
> > > +#include <linux/if_arp.h>
> > >   #include <net/sock.h>
> > >   #include <net/af_vsock.h>
> > > @@ -2012,6 +2013,110 @@ const struct vsock_transport *vsock_core_get_transport(void)
> > >   }
> > >   EXPORT_SYMBOL_GPL(vsock_core_get_transport);
> > > +/**** TAP ****/
> > Feel free to put this in a separate source file.  The Kbuild can link
> > multiple objects into a single kernel module.  That would be cleaner
> > than using a big comment to separate it from af_vsock.c code.
> I'm following the af_vsock.c style, where different logic is separated using
> this style of comments. It is not a lot of code
> so I thought it would be cleaner to have it in the same file.

It's up to the af_vsock.c maintainer, but if we keep appending
independent chunks of code to one file it becomes hard to manage and
chances of conflicts during patch merging increases.

> > > +int vsock_add_tap(struct vsock_tap *vt) {
> > > +	if (unlikely(vt->dev->type != ARPHRD_VSOCKMON))
> > > +		return -EINVAL;
> > > +
> > > +	spin_lock(&vsock_tap_lock);
> > > +	list_add_rcu(&vt->list, &vsock_tap_all);
> > > +	spin_unlock(&vsock_tap_lock);
> > > +
> > > +	__module_get(vt->module);
> > It's slightly safer to get the module before publishing it on the list.
> > But in practice I guess the caller is the module so the module won't
> > disappear underneath us.
> This function is equal to the function in af_netlink.c used by nlmon. As you
> said, in practice the caller is the module
> so it won't disappear.

Yes, there isn't a huge win right now but given that it's easy to
resolve the issue I'd do it.  The problem comes when people copy-paste
code that contains assumptions and the assumption no longer holds.
Better to write it in the safe way, eliminating the assumption, so that
derived code will be correct under more conditions.  There is no
drawback to moving __module_get() above the spin_lock().

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2016-06-10 15:44 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-28 16:29 [RFC 0/3] vsockmon: virtual device to monitor AF_VSOCK sockets ggarcia
2016-05-28 16:29 ` [RFC 1/3] vsockmon: Add tap functions ggarcia
2016-06-01 21:07   ` Stefan Hajnoczi
2016-06-09 15:02     ` Gerard Garcia
2016-06-10 15:44       ` Stefan Hajnoczi [this message]
2016-06-14 12:05         ` Jorgen S. Hansen
2016-05-28 16:29 ` [RFC 2/3] vsockmon: Add vsockmon device ggarcia
2016-06-01 21:15   ` Stefan Hajnoczi
2016-06-09 15:21     ` Gerard Garcia
2016-06-10 15:37       ` Stefan Hajnoczi
2016-05-28 16:29 ` [RFC 3/3] vsockmon: Add vsock hooks ggarcia
2016-06-01 21:19   ` Stefan Hajnoczi
2016-06-09 15:27     ` Gerard Garcia

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=20160610154445.GE3855@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=ggarcia@abra.uab.cat \
    --cc=jhansen@vmware.com \
    --cc=netdev@vger.kernel.org \
    /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