Re: [PATCH net] tuntap: raise EPOLLOUT on device up
From: Michael S. Tsirkin
Date: Fri May 18 2018 - 09:10:16 EST
On Fri, May 18, 2018 at 10:00:31PM +0800, Jason Wang wrote:
>
>
> On 2018å05æ18æ 21:26, Jason Wang wrote:
> >
> >
> > On 2018å05æ18æ 21:13, Michael S. Tsirkin wrote:
> > > On Fri, May 18, 2018 at 09:00:43PM +0800, Jason Wang wrote:
> > > > We return -EIO on device down but can not raise EPOLLOUT after it was
> > > > up. This may confuse user like vhost which expects tuntap to raise
> > > > EPOLLOUT to re-enable its TX routine after tuntap is down. This could
> > > > be easily reproduced by transmitting packets from VM while down and up
> > > > the tap device. Fixing this by set SOCKWQ_ASYNC_NOSPACE on -EIO.
> > > >
> > > > Cc: Hannes Frederic Sowa <hannes@xxxxxxxxxxxxxxxxxxx>
> > > > Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
> > > > Fixes: 1bd4978a88ac2 ("tun: honor IFF_UP in tun_get_user()")
> > > > Signed-off-by: Jason Wang <jasowang@xxxxxxxxxx>
> > > > ---
> > > > Â drivers/net/tun.c | 4 +++-
> > > > Â 1 file changed, 3 insertions(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > > > index d45ac37..1b29761 100644
> > > > --- a/drivers/net/tun.c
> > > > +++ b/drivers/net/tun.c
> > > > @@ -1734,8 +1734,10 @@ static ssize_t tun_get_user(struct
> > > > tun_struct *tun, struct tun_file *tfile,
> > > > ÂÂÂÂÂ int skb_xdp = 1;
> > > > ÂÂÂÂÂ bool frags = tun_napi_frags_enabled(tun);
> > > > Â -ÂÂÂ if (!(tun->dev->flags & IFF_UP))
> > > > +ÂÂÂ if (!(tun->dev->flags & IFF_UP)) {
> > > Isn't this racy? What if flag is cleared at this point?
> >
> > I think you mean "set at this point"? Then yes, so we probably need to
> > set the bit during tun_net_close().
> >
> > Thanks
>
> Looks no need, vhost will poll socket after it see EIO. So we are ok here?
>
> Thanks
In fact I don't even understand why does this help any longer.
--
MST