tun: impossible to deassert IFF_ONE_QUEUE or IFF_NO_PI
Subsystems (3)
PATCH 2/2 tun: impossible to deassert IFF_ONE_QUEUE or IFF_NO_PI
From: "Nathaniel Filardo" <[email protected]>
Taken from http://bugzilla.kernel.org/show_bug.cgi?id=9806
The TUN/TAP driver only permits one-way transitions of IFF_NO_PI or IFF_ONE_QUEUE during the lifetime of a tap/tun interface. Note that tun_set_iff contains
541 if (ifr->ifr_flags & IFF_NO_PI)
542 tun->flags |= TUN_NO_PI;
543
544 if (ifr->ifr_flags & IFF_ONE_QUEUE)
545 tun->flags |= TUN_ONE_QUEUE;
This is easily fixed by adding else branches which clear these bits.
Steps to reproduce:
This is easily reproduced by setting an interface persistant using tunctl then attempting to open it as IFF_TAP or IFF_TUN, without asserting the IFF_NO_PI flag. The ioctl() will succeed and the ifr.flags word is not modified, but the interface remains in IFF_NO_PI mode (as it was set by tunctl).
---
drivers/net/tun.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/tun.c renamed from drivers/net/tun.c~tun-dev-impossible-to-deassert-iff_one_queue-or-iff_no_pi +4 -0
@@ -529,9 +529,13 @@ static int tun_set_iff(struct file *fileif (ifr->ifr_flags &IFF_NO_PI ) tun->flags |=TUN_NO_PI ; +else + tun->flags &= ~TUN_NO_PI ;if (ifr->ifr_flags &IFF_ONE_QUEUE ) tun->flags |=TUN_ONE_QUEUE ; +else + tun->flags &= ~TUN_ONE_QUEUE ; file->private_data = tun; tun->attached =1 ;
_
From: [email protected]
Date: Mon, 04 Feb 2008 23:45:21 -0800
Quoted 23 lines
From: "Nathaniel Filardo" <[email protected]>
Taken from http://bugzilla.kernel.org/show_bug.cgi?id=9806
The TUN/TAP driver only permits one-way transitions of
IFF_NO_PIorIFF_ONE_QUEUEduring the lifetime of a tap/tun interface. Note thattun_set_iffcontains541 if (
ifr->ifr_flags&IFF_NO_PI)
542tun->flags|=TUN_NO_PI;
543
544 if (ifr->ifr_flags&IFF_ONE_QUEUE)
545tun->flags|=TUN_ONE_QUEUE;This is easily fixed by adding else branches which clear these bits.
Steps to reproduce:
This is easily reproduced by setting an interface persistant using tunctl then attempting to open it as
IFF_TAPorIFF_TUN, without asserting theIFF_NO_PIflag. Theioctl()will succeed and the ifr.flags word is not modified, but the interface remains inIFF_NO_PImode (as it was set by tunctl).
Quoted 4 lines
Cc "David S. Miller" <[email protected]>Cc Jeff Garzik <[email protected]>Signed-off-by Andrew Morton <[email protected]>
Applied.